OpenCV: Detect a cat with a specific color. Trivial?

I have a problem with my cat mocking the annoying cat to such an extent that the cat enters our house in the summer and ate our cats food and slept in our furniture.

My cat is gray and the problem is brown.

I would like to make a warning system using the WiFi action cam and OpenCV detection in the Linux box, but I no longer encode.

So my question. Is this a trivial task using standard OpenCV modules?

Or does this require a large amount of source code?

I know that there is an OpenCV Cascade Classifier, but I have never used it.

Yours faithfully

Jacob

+6
source share
1 answer

This is a very simple answer to show how to start your project.

You can try to find trained classifiers for cats. for example, I found this and checked out some cat images using the code below.

#include <iostream> #include "opencv2/highgui.hpp" #include "opencv2/objdetect.hpp" #include "opencv2/imgproc.hpp" using namespace std; using namespace cv; int main( int argc, const char** argv ) { if (argc < 3) { cerr << "usage:\n" << argv[0] << " <image_file_name> <model_file_name>" << endl; return 0; } // Read in the input arguments string model = argv[2]; CascadeClassifier detector(model); if(detector.empty()) { cerr << "The model could not be loaded." << endl; } Mat current_image, grayscale; // Read in image and perform preprocessing current_image = imread(argv[1]); cvtColor(current_image, grayscale, CV_BGR2GRAY); vector<Rect> objects; detector.detectMultiScale(grayscale, objects, 1.05, 1); for(int i = 0; i < objects.size(); i++) { rectangle(current_image, objects[i], Scalar(0, 255, 0),2); } imshow("result",current_image); waitKey(); return 0; } 

some images of the result are obtained

enter image description here enter image description here enter image description here

when you find a satisfactory classifier, you can use it with video frames, and you can filter on detected cats with their colors.

also you can take a look at

cat detection using hidden svm in opencv

Black Cat Detector (I don't know if it works)

+1
source

All Articles