Ask Your Question
0

program will stuck when using detectMultiScale

asked 2017-02-16 00:19:19 -0500

lqj1990 gravatar image

I trained a cascade classifier to detect cars. I have 415 positive samples and 544 negative samples. After I trained the classifier, I got cascade.xml. When I use it in my program, the program will stuck when execute detectMultiScale function. But if I used trained classifier by others, there is no problem. I compare the xml file, there are some difference. I don't know whether the problem is caused by the version of xml file.

Dose any one have some idea?

edit retag flag offensive close merge delete

Comments

Some comments

  • POS/NEG ratio is never going to work, You always need more negative samples than positives to differentiate your object from the background robustly. Try to get a couple of thousand negative samples first.
  • Is it stuck, or just taking a very long time? Some of my models take an hour to process very large images multiscale...
  • Give us all your configuration setups: sample creation, training parameters, models, test image, ...

Once we have this data, we may be able to debug this issue.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-16 08:24:54 -0500 )edit

I use OPenCV 3.1.The test image is not very large. When I change the xml file, for example https://github.com/andrewssobral/vehicle_detection_haarcascades/blob/master/cars.xml, my program works well. The format of this file is different with the one trained by myself. I don't know whether the problem is related to the format of xml file.

lqj1990 gravatar imagelqj1990 ( 2017-02-16 09:01:38 -0500 )edit

You did not even care to answer my questions. That being said, I cannot help you until I have that information.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-16 09:08:16 -0500 )edit

I'm sorry I misunderstood your words.

I create samples using opencv_createsamples -info road\road.txt -image road -vec road.vec -num 374 -w 32 -h 32

I train the classifier using opencv_traincascade -data classifier -vec road.vec -bg list.txt -numStages 10 -numPos 374 -numNeg 560 -w 32 -h 32 -featureType LBP

The test image is https://raw.githubusercontent.com/lqj1990/TestCascade/master/test/test.jpg (image)

I try the sample code facedetect.cpp, it also does not work on my computer with the same problem.

lqj1990 gravatar imagelqj1990 ( 2017-02-16 09:43:35 -0500 )edit

Ok some remarks

  1. You cannot combine -info and -image in the create_samples utility. Either stick to a list of images with annotated bounding boxes OR use a single image and apply deformations [bad option anyway, proved not to work decently].
  2. Can you at least try OpenCV 3.2 latest version to see whether you are not using any broken version of OpenCV?
StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-17 03:15:14 -0500 )edit
  1. I only use -info
  2. I downloaded the latest source code and complied by myself. I try to train cascade classifier using opencv3.2 and opencv2.4.10.I use the http://cogcomp.cs.illinois.edu/Data/Car/ (dataset) provided by UIUC. The dataset contains 550 positive samples and 500 negative samples.

When I use haartraining, the trained 5-stage classifier works well but very slow.

In this case, what can I do to improve the detection speed? Do I need to use more positive and negative samples to train the classifier?

However, when I use cascade training (both 2.4.10 and 3.2), the problem still exists. The test image size is 210*115. It's hard to judge whether it is too slow or stuck.

In this case, what can I do? Do I need to do more experiment or provide more information?

lqj1990 gravatar imagelqj1990 ( 2017-02-18 00:12:21 -0500 )edit
  1. If I use the xml file in old format, the classifier trained by myself will generate a huge number of candidate. I suspect it is probably caused by some wrong settings in training process. But I don't know what should I do. I trained the classifier using 673 positive samples and 1044 negative samples.The setting is opencv_haartraining.exe -data data -vec cars.vec -bg list.txt -npos 605 -nneg 1044 -nstages 11 -w 20 -h 20. Detection code is cascade.detectMultiScale(frame_gray, cars, 1.01, 3, 0, Size(30,30));

  2. When using xml file in new format, the problem is caused by Mat(1, (int)(v.size()*sizeof(v[0])), CV_8U, (void*)&v[0]).copyTo(um); in function copyVectorToUMat in cascadedetect.cpp. It does not return a result, so the program stuck. I don't know why.

lqj1990 gravatar imagelqj1990 ( 2017-02-19 04:00:35 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-03-13 21:20:41 -0500

lqj1990 gravatar image

Already solved. Disable OpenCl when compiling OpenCv.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-02-16 00:19:19 -0500

Seen: 333 times

Last updated: Mar 13 '17