Commit 69e62948 authored by Yannick Verdie's avatar Yannick Verdie

Qt ticket #537

Forgot to update so code after previous fix
parent 6cafec88
...@@ -2342,6 +2342,11 @@ void ViewPort::updateImage(const CvArr *arr) ...@@ -2342,6 +2342,11 @@ void ViewPort::updateImage(const CvArr *arr)
cvReleaseMat(&image2Draw_mat); cvReleaseMat(&image2Draw_mat);
//the image in ipl (to do a deep copy with cvCvtColor) //the image in ipl (to do a deep copy with cvCvtColor)
image2Draw_mat = cvCreateMat( mat->rows, mat->cols, CV_8UC3 ); image2Draw_mat = cvCreateMat( mat->rows, mat->cols, CV_8UC3 );
image2Draw_qt = QImage((uchar*) image2Draw_mat->data.ptr, image2Draw_mat->cols, image2Draw_mat->rows,QImage::Format_RGB888);
//use to compute mouse coordinate, I need to update the ratio here and in resizeEvent
ratioX=width()/float(image2Draw_mat->cols);
ratioY=height()/float(image2Draw_mat->rows);
updateGeometry(); updateGeometry();
} }
...@@ -2618,6 +2623,8 @@ void ViewPort::resizeEvent ( QResizeEvent *event) ...@@ -2618,6 +2623,8 @@ void ViewPort::resizeEvent ( QResizeEvent *event)
{ {
controlImagePosition(); controlImagePosition();
//use to compute mouse coordinate, I need to update the ratio here and in resizeEvent
ratioX=width()/float(image2Draw_mat->cols); ratioX=width()/float(image2Draw_mat->cols);
ratioY=height()/float(image2Draw_mat->rows); ratioY=height()/float(image2Draw_mat->rows);
...@@ -2713,10 +2720,14 @@ void ViewPort::draw2D(QPainter *painter) ...@@ -2713,10 +2720,14 @@ void ViewPort::draw2D(QPainter *painter)
//only if CV_8UC1 or CV_8UC3 //only if CV_8UC1 or CV_8UC3
void ViewPort::drawStatusBar() void ViewPort::drawStatusBar()
{ {
if (mouseCoordinate.x()>=0 && if (nbChannelOriginImage!=CV_8UC1 && nbChannelOriginImage!=CV_8UC3)
mouseCoordinate.y()>=0 && return;
mouseCoordinate.x()<image2Draw_mat->cols &&
mouseCoordinate.y()<image2Draw_mat->rows) //if (mouseCoordinate.x()>=0 &&
// mouseCoordinate.y()>=0 &&
// mouseCoordinate.x()<image2Draw_qt.width() &&
// mouseCoordinate.y()<image2Draw_qt.height())
if (mouseCoordinate.x()>=0 && mouseCoordinate.y()>=0)
{ {
QRgb rgbValue = image2Draw_qt.pixel(mouseCoordinate); QRgb rgbValue = image2Draw_qt.pixel(mouseCoordinate);
...@@ -2743,9 +2754,13 @@ void ViewPort::drawStatusBar() ...@@ -2743,9 +2754,13 @@ void ViewPort::drawStatusBar()
} }
} }
//accept only CV_8UC1 and CV_8UC8 image for now
void ViewPort::drawImgRegion(QPainter *painter) void ViewPort::drawImgRegion(QPainter *painter)
{ {
if (nbChannelOriginImage!=CV_8UC1 && nbChannelOriginImage!=CV_8UC3)
return;
qreal offsetX = param_matrixWorld.dx()/param_matrixWorld.m11(); qreal offsetX = param_matrixWorld.dx()/param_matrixWorld.m11();
offsetX = offsetX - floor(offsetX); offsetX = offsetX - floor(offsetX);
qreal offsetY = param_matrixWorld.dy()/param_matrixWorld.m11(); qreal offsetY = param_matrixWorld.dy()/param_matrixWorld.m11();
...@@ -2789,7 +2804,7 @@ void ViewPort::drawImgRegion(QPainter *painter) ...@@ -2789,7 +2804,7 @@ void ViewPort::drawImgRegion(QPainter *painter)
else else
rgbValue = qRgb(0,0,0); rgbValue = qRgb(0,0,0);
if (nbChannelOriginImage==3) if (nbChannelOriginImage==CV_8UC3)
{ {
//for debug //for debug
/* /*
...@@ -2815,7 +2830,8 @@ void ViewPort::drawImgRegion(QPainter *painter) ...@@ -2815,7 +2830,8 @@ void ViewPort::drawImgRegion(QPainter *painter)
Qt::AlignCenter, val); Qt::AlignCenter, val);
} }
else
if (nbChannelOriginImage==CV_8UC1)
{ {
val = tr("%1").arg(qRed(rgbValue)); val = tr("%1").arg(qRed(rgbValue));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment