1 | initial version |
i tried some simple code and get this image
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
Mat image, gray,dst_img;
String image_file_name = "15035807843241733.jpg";//argv[1];
image = imread(image_file_name);
if (image.empty())
{
cout << "\nunable to open " << image_file_name << "\nprogram terminated!\n";
return 1;
}
imshow("source", image);
cvtColor(image, gray, COLOR_BGR2GRAY);
Canny(gray, dst_img, 50, 150);
blur(dst_img, dst_img, Size(5, 5));
threshold(dst_img, dst_img, 0, 255, THRESH_OTSU);
vector<Point> pts;
vector<Point> hull;
findNonZero(dst_img, pts);
convexHull(pts, hull, true);
polylines(image, hull, true, Scalar(0, 0, 255), 2);
imshow("dest", image);
waitKey();
return 0;
}
2 | No.2 Revision |
i tried some simple code and get this image
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
Mat image, gray,dst_img;
String image_file_name = "15035807843241733.jpg";//argv[1];
image = imread(image_file_name);
if (image.empty())
{
cout << "\nunable to open " << image_file_name << "\nprogram terminated!\n";
return 1;
}
imshow("source", image);
cvtColor(image, gray, COLOR_BGR2GRAY);
Canny(gray, dst_img, 50, 150);
blur(dst_img, dst_img, Size(5, 5));
threshold(dst_img, dst_img, 0, 255, THRESH_OTSU);
vector<Point> pts;
vector<Point> hull;
findNonZero(dst_img, pts);
convexHull(pts, hull, true);
polylines(image, hull, true, Scalar(0, 0, 255), 2);
imshow("dest", image);
waitKey();
return 0;
}
another test image and result:
....
3 | No.3 Revision |
i tried some simple code and get this image
another test image and result:
....
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
Mat image, gray,dst_img;
String image_file_name = "15035807843241733.jpg";//argv[1];
image = imread(image_file_name);
if (image.empty())
{
cout << "\nunable to open " << image_file_name << "\nprogram terminated!\n";
return 1;
}
imshow("source", image);
cvtColor(image, gray, COLOR_BGR2GRAY);
Canny(gray, dst_img, 50, 150);
blur(dst_img, dst_img, Size(5, 5));
threshold(dst_img, dst_img, 0, 255, THRESH_OTSU);
vector<Point> pts;
vector<Point> hull;
findNonZero(dst_img, pts);
convexHull(pts, hull, true);
polylines(image, hull, true, Scalar(0, 0, 255), 2);
imshow("dest", image);
waitKey();
return 0;
}
another test image and result:
....