我正在尝试定位框架的某些区域,该框架位于Ycbcr颜色空间中。我必须根据其Y值选择这些区域。

所以我写了这段代码:

Mat frame. ychannel;
VideoCapture cap(1);
int key =0;
int maxV , minV;
Point max, min;
while(key != 27){
     cap >> frame;
     cvtColor(frame,yframe,CV_RGB_YCrCb); // converting to YCbCr color space
     extractChannel(yframe, yframe, 0); // extracting the Y channel
     cv::minMaxLoc(yframe,&minV,&maxV,&min,&max);
     cv::threshold(outf,outf,(maxV-10),(maxV),CV_THRESH_TOZERO);
/**
Now I want to use :
cv::rectangle()
but I want to draw a rect around any pixel (see the picture bellow)that's higher than (maxV-10)
and that during the streaming
**/
     key = waitKey(1);
}

我画这幅画是跳跃的,这有助于理解我该做什么。

谢谢你的帮助。

最佳答案

您必须找到每个connected components,并绘制其边界框。

关于c++ - 在某些像素上绘制矩形openCV,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13974735/

10-12 23:05