简体   繁体   中英

OpenCv: How to set a marker at a certain coordinate in a video stream open cv

I'm working with NITE/OPENNI and opencv in xcode 4 to work with the kinect. I'm able to get the coordinates of the head for example this is done by :

In the main, outside the wile(true):

 IplImage *rgbimg = cvCreateImageHeader(cvSize(640,480), 8, 3);

Then in the wile(true)

XnSkeletonJointPosition Head;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition( aUsers[i], XN_SKEL_HEAD, Head); 
printf("%d: (%f,%f,%f) [%f]\n", aUsers[i], Head.position.X, Head.position.Y, Head.position.Z, Head.fConfidence); }

I also have a video stream :

    // Take current image
    const XnRGB24Pixel* pImage = Xn_image.GetRGB24ImageMap();

    //process image data
    XnRGB24Pixel* ucpImage = const_cast<XnRGB24Pixel*> (pImage);
    cvSetData(rgbimg,ucpImage, 640*3);
    cvCvtColor(rgbimg,rgbimg,CV_RGB2BGR);
    cvShowImage("RGB",rgbimg);

This is all done in the main in a while(true).

Now my question is how can i set some kind of marker (eg: *,cross-hair, X ) at the position of the coordinates of the hand in the video stream ?

EDIT

i tried:

XnRGB24Pixel* ucpImage = const_cast<XnRGB24Pixel*> (pImage);
cvSetData(rgbimg,ucpImage, 640*3);
cvCvtColor(rgbimg,rgbimg,CV_RGB2BGR);
cvCircle(rgbimg, cvPoint(Head.position.X,Head.position.Y), 20, cvScalar(0,255,0), 1);
cvShowImage("RGB",rgbimg);

and i get :

在此处输入图片说明

as you can see the circle stays in the top left corner for some reason. Any ideas how to change this ?

Try the display functions in OpenCV:

line(), circle(), drawPoly() and apply them to every frame in your video

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM