疑似小米3真机曝光 看小米手机酷玩激光虚拟键盘
//unsigned int frameNumber = 0;
unsigned int blobNumber = 0;
bool quit = false;
while (!quit&&cvGrabFrame(capture))
{
IplImage *img = cvRetrieveFrame(capture);
cvConvertScale(img, frame, 1, 0);
IplImage *segmentated = cvCreateImage(imgSize, 8, 1);
// Detecting red pixels:
// (This is very slow, use direct access better...)
for (unsigned int j=0; j<imgSize.height; j++)
for (unsigned int i=0; i<imgSize.width; i++)
{
CvScalar c = cvGet2D(frame, j, i);
double b = ((double)c.val[0])/255.;
double g = ((double)c.val[1])/255.;
double r = ((double)c.val[2])/255.;
// unsigned char f = 255*((r>0.2+g)&&(r>0.2+b));
// cvSet2D(segmentated, j, i, CV_RGB(f, f, f));
if(b>0.4 || g>0.4 || r>0.4)
cvSet2D(segmentated, j, i, CV_RGB(255, 255, 255));
else
cvSet2D(segmentated, j, i, CV_RGB(0, 0, 0));
}
cvMorphologyEx(segmentated, segmentated, NULL, morphKernel, CV_MOP_OPEN, 1);
cvShowImage("segmentated", segmentated);
IplImage *labelImg = cvCreateImage(cvGetSize(frame), IPL_DEPTH_LABEL, 1);
CvBlobs blobs;
unsigned int result = cvLabel(segmentated, labelImg, blobs);
cvFilterByArea(blobs, 500, 1000000);
cvRenderBlobs(labelImg, blobs, frame, frame, CV_BLOB_RENDER_BOUNDING_BOX);
cvUpdateTracks(blobs, tracks, 200., 5);
cvRenderTracks(tracks, frame, frame, CV_TRACK_RENDER_ID|CV_TRACK_RENDER_BOUNDING_BOX);
cvShowImage("red_object_tracking", frame);
// print key
for (CvTracks::const_iterator it=tracks.begin(); it!=tracks.end(); ++it)
{
int xx = (int)it->second->centroid.x;
int yy = (int)it->second->centroid.y;
//std::cout << xx << ',' << yy << std::endl;
图片新闻
最新活动更多
-
限时免费立即试用>> 燧石技术,赋光智慧,超越感知
-
7月30-31日报名参会>>> 全数会2025中国激光产业高质量发展峰会
-
7.30-8.1马上报名>>> 【展会】全数会 2025先进激光及工业光电展
-
精彩回顾立即查看>> 筑梦启光 砺行致远 | 新天激光数字化产研基地奠基仪式
-
精彩回顾立即查看>> 抗冻不流汗——锐科激光『智能自冷却激光器』重磅发布
-
精彩回顾立即查看>> 宾采尔激光焊接领域一站式应用方案在线研讨会
推荐专题
发表评论
请输入评论内容...
请输入评论/评论长度6~500个字
暂无评论
暂无评论