資源簡介
通過編程識別特定的顏色區域,并進行圈定。
代碼片段和文件信息
#include?
#include?“opencv2/opencv.hpp“
#include?“opencv2/imgproc/imgproc.hpp“
#include?“opencv2/core/core.hpp“
#include
#include
#include
#define?IMAGE_WIDTH?640??????//圖像寬度
#define?IMAGE_HEIGHT?480?????//圖像高度
#define?pi?3.14159265?????//圖像高度
using?namespace?cv;
using?namespace?std;
#define?WINDOW_NAME1?“【結果圖】“
int?main(?int?argc?char**?argv?)
{
VideoCapture?cap(0);
Mat?HSVImage?dstImage;
int?flag?=?0;
while?(1)
{
Mat?frame;
cap?>>?frame;??//讀取當前幀
if?(cap.read(frame)?!=?1)
{
cout?<“Error“?< break;
}
cvtColor(frame?HSVImage?COLOR_BGR2HSV);
//imshow(“處理后的視頻“?HSVImage);
dilate(HSVImage?HSVImage?Mat(77CV_8U)?Point(-1-1)2);
erode(HSVImage?HSVImage?Mat(88CV_8U)?Point(-1-1)1);
inRange(HSVImage?Scalar(35?43?46)?Scalar(77?255?255)?dstImage);
vector?>?contours;
findContours(dstImage?contours?CV_RETR_CCOMP?CV_CHAIN_APPROX_SIMPLE);
Mat?drawImage?=?Mat?::?zeros(?dstImage.size()?CV_8UC3?);
int?Area?maxArea;
maxArea?=?10;
Scalar?color(0?0?255);
for(int?index?=?0;?index? {
Area?=?fabs(contourArea(?contours[index]));
if(Area?>?maxArea)
maxArea?=?Area;
drawContours(drawImage?contours?index?color?3?8);
}
if?(maxArea?>?80000)
{
cout?<“啟動補彈程序“?< flag?=?1;
}
else
{
cout?<“Waiting“?< }
imshow(“讀取視頻“?frame);??//顯示當前幀
imshow(WINDOW_NAME1?drawImage);
waitKey(1);
}
system(“pause“);
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3916??2016-06-08?14:43??Bullet\Bullet\Bullet.vcxproj
?????文件????????942??2016-06-08?14:43??Bullet\Bullet\Bullet.vcxproj.filters
?????文件????????143??2016-06-08?14:37??Bullet\Bullet\Bullet.vcxproj.user
?????文件????????406??2016-06-08?16:08??Bullet\Bullet\Debug\Bullet.exe.em
?????文件????????472??2016-06-08?16:08??Bullet\Bullet\Debug\Bullet.exe.em
?????文件????????381??2016-06-08?17:14??Bullet\Bullet\Debug\Bullet.exe.intermediate.manifest
?????文件?????????49??2016-06-08?17:14??Bullet\Bullet\Debug\Bullet.lastbuildstate
?????文件???????2968??2016-06-08?17:14??Bullet\Bullet\Debug\Bullet.log
?????文件????????707??2016-06-08?14:43??Bullet\Bullet\Debug\Bullet.vcxprojResolveAssemblyReference.cache
?????文件??????????0??2016-06-08?14:43??Bullet\Bullet\Debug\Bullet.write.1.tlog
?????文件????????202??2016-06-08?16:08??Bullet\Bullet\Debug\Bullet_manifest.rc
?????文件????????602??2016-06-08?17:14??Bullet\Bullet\Debug\cl.command.1.tlog
?????文件??????13010??2016-06-08?17:14??Bullet\Bullet\Debug\CL.read.1.tlog
?????文件????????264??2016-06-08?17:14??Bullet\Bullet\Debug\CL.write.1.tlog
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
?????文件??????????2??2016-06-08?17:14??Bullet\Bullet\Debug\li
............此處省略43個文件信息
評論
共有 條評論