1

I'm trying to get the people detector provided by the OpenCV library running. So far I get decent performance on my iPhone 6 but the detection is super bad and almost never correct and I'm not really sure why this is since you can find example videos using the same default HOG descriptor with way better detection.

Here is the code:

- (void)processImage:(Mat&)image { cv::Mat cvImg, result; cvtColor(image, cvImg, COLOR_BGR2HSV); cv::vector<cv::Rect> found, found_filtered; hog.detectMultiScale(cvImg, found, 0, cv::Size(4,4), cv::Size(8,8), 1.5, 0); size_t i; for (i=0; i < found.size(); i++) { cv::Rect r = found[i]; rectangle(image, r.tl(), r.br(), Scalar(0,255,0), 2); } } 

The video input comes from the iPhone camera itself and "processImage:" is called for every frame. For the HOGDescriptor I use the default people detector:

_hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector()); 

I appreciate any help. :)

3
  • remove the line cvtColor(image, cvImg, COLOR_BGR2HSV); and try again. Commented Sep 12, 2016 at 22:14
  • naturally hog.detectMultiScale(image... Commented Sep 12, 2016 at 22:17
  • I tried that before, I get this error then: OpenCV Error: Assertion failed (img.type() == CV_8U || img.type() == CV_8UC3) in computeGradient Commented Sep 13, 2016 at 7:25

1 Answer 1

2

I'm new to openCV, so take this with a grain of salt: The line cvtColor(image, cvImg, COLOR_BGR2HSV); converts the image from the BGR color space to the HSV color space. Essentially, it changes each pixel from being represented by how much blue, green, and red it has, to being represented by the components hue (color), saturation (how much color) and value (how bright). Clearly, the hogDescriptor acts on a BGR image, not an HSV image. You need to pass it a type CV_8UC3 image: An image with 3 channels per pixel (C3), ex. BGR, and an 8bit unsigned number for each channel (8U), This part is less important. What are you passing into the method processImage()? It should be one of those types. If not, you need to know the type and convert it to CV_8UC3 using the cvtColor() method

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.