-
Notifications
You must be signed in to change notification settings - Fork 25
/
4183.cpp
37 lines (27 loc) · 784 Bytes
/
4183.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "qa.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
using namespace cv;
using namespace std;
#if QA_MULTI_DEMO
int main( int argc, char** argv )
{
a4183( argc, argv );
}
#endif
int a4183(int argc, char** argv)
{
char* filename = argc >= 2 ? argv[1] : (char*)"65164.png";
Mat src = imread( filename ,1 ),gray,temp;
Mat mSource_Bgr,mSource_Gray,mThreshold;
mSource_Bgr= src;
cvtColor(mSource_Bgr,mSource_Gray,COLOR_BGR2GRAY);
threshold(mSource_Gray,mThreshold,254,255,THRESH_BINARY_INV);
Mat Points;
findNonZero(mThreshold,Points);
Rect Min_Rect=boundingRect(Points);
rectangle(mSource_Bgr,Min_Rect.tl(),Min_Rect.br(),Scalar(0,255,0),2);
imshow("Result",mSource_Bgr);
waitKey(0);
return 0;
}