16 Star 1 Fork 1

UCAS-SAS-Robot-Team/算法组作业

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
RM03.cpp 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
Junyan721113 提交于 2022-10-08 19:42 . feat: 2nd Class
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
Mat imgProc(Mat imgIn) {
Mat imgOut;
imgIn.copyTo(imgOut);
int thre = 40, maxv = 255;
cvtColor(imgOut, imgOut, COLOR_BGR2GRAY);//BGR
//ֵ
threshold(imgOut, imgOut, thre, maxv, THRESH_BINARY);//pixel = (pixel < thre) ? 0 : maxv;
dilate(imgOut, imgOut, Mat());
floodFill(imgOut, Point(5, 50), Scalar(255), 0, FLOODFILL_FIXED_RANGE);
erode(imgOut, imgOut, Mat());
erode(imgOut, imgOut, Mat());
return imgOut;
}
void imageIO() {
//input image path
string imgPath;
cout << "Select a file to Open: \n";
cin >> imgPath;
//Ctrl + D
if(imgPath.empty()) imgPath = "../TestFiles/Energy02.jpg";
//read image
Mat img = imread(imgPath);
//show image
imshow("Display Image", imgProc(img));
//quit
while(waitKey(0) != 'q') cout << "Press Q to Quit\n";//ASCII
}
void videoIO() {
Mat frame;
VideoCapture video;
video.open("../TestFiles/Energy.mp4");
do {
video >> frame;//cin >> a;
if(frame.empty()) break;
imshow("Video", frame);
imshow("Proc", imgProc(frame));
}
while(waitKey(0) != 'q');//100ms
}
int main() {
imageIO();
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ucas-sas-robot-team/RMhomework.git
git@gitee.com:ucas-sas-robot-team/RMhomework.git
ucas-sas-robot-team
RMhomework
算法组作业
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385