March 2019
Intermediate to advanced
312 pages
7h 37m
English
The program for detecting the green ball is named ObjectDetection.cpp and I have saved it inside the OpenCV_codes folder. I have also copied the greenball.png image to this folder. You can download the ObjectDetection.cpp program from the Chapter07 folder of the GitHub repository. So, the program for detecting the green ball is as follows:
#include <iostream>#include<opencv2/opencv.hpp>#include<opencv2/core/core.hpp>#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgproc/imgproc.hpp>using namespace cv;using namespace std;int main(){ Mat img, resizeimg,thresimage; img = imread("greenball.png"); imshow("Green Ball Image", img); waitKey(0); resize(img, resizeimg, cvSize(640, 480)); imshow("Resized Image", ...