slightly improved code to show preview

This commit is contained in:
boyska 2017-01-05 18:27:27 +01:00
parent f0e6d947a1
commit 72cf30bf07

View file

@ -1,5 +1,10 @@
#include<opencv2/opencv.hpp>
// all those colors are still visible on b/w (the first component is not so low)
auto WHITE = cv::Scalar(255,255,255);
auto BLUE = cv::Scalar(200,10,10);
auto MAGENTA = cv::Scalar(110,10,200);
int main(int argc, char *argv[])
{
char const *fname = "files/masckera.png";
@ -64,19 +69,20 @@ int main(int argc, char *argv[])
}
}
cv::circle(img,hull[idx[0]],30,255,-1);
cv::circle(img,hull[(idx[0]+1)%hull.size()],30,255,-1);
cv::circle(img,hull[idx[1]],20,255,-1);
cv::circle(img,hull[(idx[1]+1)%hull.size()],20,255,-1);
std::cout << hull.size() << ", " << contours[0].size() << std::endl;
std::cout
<< "(" << idx[0] << "," << distance[0] << ") -- "
<< "(" << idx[1] << "," << distance[1] << ")" << std::endl;
cv::namedWindow("test",CV_WINDOW_NORMAL);
cv::imshow("test",img);
//img = cv::imread(fname,CV_LOAD_IMAGE_COLOR); // uncomment to this to display image with colors
unsigned short dotwidth = img.cols >> 6; // divide by 64, so efficient
cv::circle(img,hull[idx[0]],dotwidth,MAGENTA,-1);
cv::circle(img,hull[(idx[0]+1)%hull.size()],dotwidth,MAGENTA,-1);
cv::circle(img,hull[idx[1]],dotwidth>>1,BLUE,-1);
cv::circle(img,hull[(idx[1]+1)%hull.size()],dotwidth>>1,BLUE,-1);
cv::namedWindow("4 corners",CV_WINDOW_NORMAL);
cv::imshow("4 corners",img);
cv::waitKey(0);
return 0;