电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

OpenCV学习笔记之二

OpenCV学习笔记之二_第1页
1/6
OpenCV学习笔记之二_第2页
2/6
OpenCV学习笔记之二_第3页
3/6
精品文档---下载后可任意编辑本节对应-----第 3 章 Processing Imageswith Classes 中的 Using a Controller to communicate with processing modules 的部分。本节把书中的提要详细化,给自已备份的同时也希望给别人一点启发。开始一、打开 VS2024,建立项目二、下一步后,原来的“使用 Unicode 库”勾去掉。三、完成后,出现编辑界面四、编辑对话框,设计成如下界面。精品文档---下载后可任意编辑五、点开“解决方案资源管理器”,添加头文件 colordetector.h#if !defined COLORDETECT#define COLORDETECT#includeclass ColorDetector{private://minimum acceptable distanceint minDist;//target colorcv::Vec3b target;//image containing resulting binary mapcv::Mat result;//inline private member function//Computes the distance from target color.int getDistance(const cv::Vec3b& color)const;public://empty constructorColorDetector():minDist(100) {// default parameter initialization heretarget[0] = target[1] = target[2] = 0; }//Getters and setters//Sets the color distance threshold//Threshold must be positive,otherwise distance threshold is set to 0.void setColorDistanceThreshold(int distance);精品文档---下载后可任意编辑//Gets the color distance thresholdint getColorDistanceThreshold() const;// Sets the color to be detectedvoid setTargetColor(unsignedchar red,unsignedchar green,unsignedchar blue);// Sets the color to be detectedvoid setTargetColor(cv::Vec3b color);// Gets the color to be detectedcv::Vec3b getTargetColor() const;// Processes the image. Returns a 1-channel binary image.cv::Mat proecess(const cv::Mat &image);};#endif六、添加源文件#include"StdAfx.h"#include"colordetector.h"int ColorDetector::getDistance(const cv::Vec3b& color) const{return abs(color[0]-target[0])+abs(color[1]-target[1])+abs(color[2]-target[2]);}void ColorDetector::setColorDistanceThreshold(int distance){if ( distance < 0 ){distance = 0;}minDist = distance;}int ColorDetector::getCo...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

OpenCV学习笔记之二

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部