I have a my_mouse_callback
example function that works with IplImage*:
void my_mouse_callback(int event, int x, int y, int flags, void* param)
{
IplImage* image = (IplImage*) param;
switch( event )
{
case CV_EVENT_LBUTTONDOWN:
drawing_box = true;
box = cvRect(x, y, 0, 0);
break;
...
draw_box(image, box);
break;
}
which is implemented in main
like this:
cvSetMouseCallback(Box Example,my_mouse_callback,(void*) image);
The problem is, in my code I'm using Mat object and it can't be transfered this way to the setMouseCallback
function.
I'm looking for a solution that doesn't involve transfering Mat to IplImage*.
Or if there is no solution, how can I correctly convert Mat to IplImage*?
I tried that already with this code from the opencv documentation:
Mat I;
IplImage* pI = &I.operator IplImage();
and it didn't work.
There's no equivalent of that function in the C++ interface as far as I can tell.
But you can convert a cv::Mat
to an IplImage*
like this, and the other way around like this:
cv::Mat mat(my_IplImage);