Software Archive
Read-only legacy content
17061 Discussions

OpenCV, IntelSDK and user input

Christopher_C_
Beginner
396 Views

Right now, I'm currently using tutorial 2 (main_raw_color_streams) as my base. However inside my while loop, 

while (psm->AcquireFrame(true) >= PXC_STATUS_NO_ERROR){

I want to use a mouse click in order to manipulate (in particular, draw) on my opencv image stream.

I had initially planned to put something along the lines of: 

for (char user_input = cv::waitKey(20); user_input != 28; user_input = cv::waitKey(20)){
            rgb |= Circle.drawing_canvas;
            imshow("Color_cv2", rgb);
        }

due to the fact that my program displays through imshow, it needs to be followed up with a wait key or nothing will show up on the screen because highgui doesn't have enough time to process the drawn requests from imshow(). But by doing this:

I get a bug seeing how it will never reach my if(!renderColor-> Renderframe... (NOTE: I have this here just to check if my code ever reaches here)

If you have suggestions on how to implement the part where I follow up my imshow("Color_cv2", rgb) with a wait key please comment below!

Thanks in advance!

0 Kudos
3 Replies
Christopher_C_
Beginner
396 Views

If it helps, this is the original code I had before trying to implement the for loop for the wait key

0 Kudos
Christopher_C_
Beginner
396 Views

bumping for help

0 Kudos
samontab
Valued Contributor II
396 Views

Hi Chistopher,

There are a few things not quite right:

- You are mixing the old OpenCV C interface (cvWaitKey) mixed with the new C++ interface (cv::imshow). It may not be the cause, but either way, I suggest you to use the new OpenCV C++ interface.

- Why are you using ACCESS_READ_WRITE?, you should be using ACCESS_READ, as you are only reading from the camera.

- There is no need to manually allocate the memory, with memCopy, the cv::Mat constructor should do all that work for you.

- You should separate the image acquisiton from the camera with the processing of the frame, and its display. You should be using a thread to grab the images from the camera, and the main thread should be the one displaying it, and reading the user input.

Probably there are other things going on with your code as well, but at least this would give you a starting point to debug it.

0 Kudos
Reply