侵权投诉
订阅
纠错
加入自媒体

疑似小米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;

<上一页  1  2  3  4  5  6  7  8  下一页>  余下全文
声明: 本网站所刊载信息,不代表OFweek观点。刊用本站稿件,务经书面授权。未经授权禁止转载、摘编、复制、翻译及建立镜像,违者将依法追究法律责任。

发表评论

0条评论,0人参与

请输入评论内容...

请输入评论/评论长度6~500个字

您提交的评论过于频繁,请输入验证码继续

暂无评论

暂无评论

激光 猎头职位 更多
文章纠错
x
*文字标题:
*纠错内容:
联系邮箱:
*验 证 码:

粤公网安备 44030502002758号