Hi, I have the following problem: I must find a red ball on a field. I transformed my picture to HSV colorspace and used the inRange function to separate the red color. Now I'm trying to draw an rectangle at the position, where the red colored object is and to show it in the original video, but I have no plan how I can do this.
Thank you Dennis
Here is my actual code
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap("test.mp4");
// Define Color
Scalar upperRed(180, 255, 255);
Scalar lowerRed(125, 52, 67);
while (1) {
Mat frame, hsv;
// Capture frame-by-frame
cap >> frame;
// If the frame is empty, break immediately
if (frame.empty())
break;
GaussianBlur(frame, frame,Size(5,5) , 0);
// Display the resulting frame in HSV
cvtColor(frame, hsv, COLOR_BGR2HSV);
// Color detection
inRange(hsv, lowerRed, upperRed, frame);
// Show images
imshow("bye", hsv);
imshow("hallo", frame);
// Press ESC on keyboard to exit
char c = (char)waitKey(25);
if (c == 27)
break;
}
cap.release();
destroyAllWindows;
return 0;
}