OpenCV and ARToolkit

TimoR
Posts: 7
Joined: Wed Feb 22, 2017 6:28 am

OpenCV and ARToolkit

Postby TimoR » Wed Feb 22, 2017 6:44 am

Hello, I am using the multimarker example for ARToolkit and modified it for my benefit. Now I want to use openCV for some edge detection and image processing. I tried the approaches from http://vgl-ait.org/cvwiki/doku.php?id=opencv:tutorial:integrate_opencv_and_artoolkit and https://artoolkit.org/blog/2016/05/opencv-with-artoolkit but every time I get an exception thrown in the highgui.lib of opencv.

Exception thrown at 0x00F2F201 (opencv_highgui2413d.dll) in viMo.exe: 0xC0000005: Access violation reading location 0x03A9F000.

This is my code of the first example:

/* grab a video frame */
if ((dataPtr = (ARUint8 *)arVideoGetImage()) == NULL) {
arUtilSleep(2);
return;
}
IplImage* imgTest;
imgTest = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 4);
imgTest->imageData = (char *)dataPtr;
cvShowImage("Test", imgTest);

And this is the code from the second (dataPtr is achieved as shown above):

cv::Mat imgOpenCV;
imgOpenCV = cv::Mat(xsize, ysize, CV_8UC4);
imgOpenCV.data = (uchar *)dataPtr;
cv::imshow("OpenCV Image", imgOpenCV);

The exception is thrown in cv::imshow. But i don't know what I am doing wrong. The code samples are in my opinion exactly like the examples of the tutorials. I tried to change the location of my opencv path but it seems that the dlls, includes and libraries are correct. I loaded an image and showed it with cv::imshow and no problems there, so it seems the problem lies in the conversion.

What am I overlooking?

Thanks in advanced for any suggestions and help.

MrDaniel
Posts: 381
Joined: Wed Nov 18, 2015 9:07 pm

Re: OpenCV and ARToolkit

Postby MrDaniel » Wed Feb 22, 2017 12:45 pm

Can you inspect imgOpencv Mat?

Perhaps try cv::cvtColor() from BGRA to BGR?

Regards,

Daniel

TimoR
Posts: 7
Joined: Wed Feb 22, 2017 6:28 am

Re: OpenCV and ARToolkit

Postby TimoR » Thu Mar 02, 2017 7:01 am

The Problem was, that I used CV_8UC4. With CV_8UC3 it works fine. Thank you for your help!


Return to “ARToolKit for Desktop v5.x”

Who is online

Users browsing this forum: No registered users and 2 guests