#include <opencv2/opencv.hpp>
int main() {
std::vector<cv::String> file_names;
cv::glob("images/", file_names);
int cnt = 0;
for (auto it = file_names.begin(); it != file_names.end(); ++it) {
cv::Mat src_image, hsv_image, maskimg;
src_image = cv::imread(*it);
cv::cvtColor(src_image, hsv_image, CV_BGR2HSV);
cv::inRange(hsv_image, cv::Scalar(0, 43, 46), cv::Scalar(34, 255, 255), maskimg);
std::vector<std::vector<cv::Point>> contours;
cv::findContours(maskimg, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
for (int i = 0; i < contours.size(); i++) {
float area = cv::contourArea(contours[i]);
cv::Scalar color;
if (area < 100.0) {
color = cv::Scalar(255, 0, 0);
}
else{
color = cv::Scalar(0, 255, 0);
cv::Rect rect = cv::boundingRect(contours[i]);
cv::rectangle(src_image, rect, color,3);
}
//cv::drawContours(src_image, contours, i, color,-1);
}
cv::imwrite("res/"+std::to_string(cnt) + ".jpg",src_image);
cnt++;
//
}
return 0;
}
my_notebook's Introduction
my_notebook's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.