Haar Adaboost Detection Vehicle

Source: Internet
Author: User
Tags radar

Resources:

http://blog.csdn.net/zhuangxiaobin/article/details/25476833 "image processing" Haar Adaboost detection of custom targets (video vehicle detection algorithm code)

http://www.cnblogs.com/ello/archive/2012/04/28/2475419.html Analysis of human Face detection Haar Classifier method

http://blog.csdn.net/zhuangxiaobin/article/details/26075667"machine learning" AdaBoost algorithm detailed

?

Three steps:

    1. Create a sample
    2. Training classifier
    3. Target detection using a well-trained classifier

?

1, what is the Haar classifier

The Haar classifier belongs to unsupervised learning, which belongs to the cluster, and does not know the number of the original classification of the data. This should be distinguished from the classification. It belongs to a clustering algorithm, which is based on statistical clustering algorithm.

Haar classifier = haar-like feature + Integration Graph method + AdaBoost + Cascade

Key points of the algorithm:

    1. Using Haar-like feature detection
    2. Use the integration graph to haar-like and accelerate the request
    3. Using the AdaBoost algorithm to distinguish the strong classifiers of faces and non-human faces
    4. Use filtered cascading to cascade classifiers together to improve accuracy

?

Haar-like Features:

Boundary features, line features, central features

Boosting do is to use what kind of rectangular features together to distinguish between non-human face and face of an algorithm.

It is a weak learning classification algorithm, but it can be combined into a high-precision strong learning classification algorithm. However, how to determine the threshold value.

In order to solve the problem of boosting adaptive, adaboosting algorithm is presented.

Weak classifier is implemented by decision tree, the basic weak classifier contains only one harr-like feature, and the decision tree has only one layer.

The strong classifier is based on the weak classifier, and then multiple T iterations are made, and then the T-optimal weak classifiers are combined.

In conclusion, the AdaBoost algorithm is actually a weak classifier from hatching to the process of the butterfly.

?

A strong classifier is obtained through the democratic vote of the weak classifier, and the strong classifier is cascaded to detect the higher correct rate cascade classifier, which is our final target Harr classifier.

2, the use of OPENCV above the face detection demo, write their own vehicle detection example, the test results as shown:

The test results are as follows: Each frame takes about 100ms of time.

The code is as follows:

  1. Static cvmemstorage* storage = 0; //Storage-related
  2. Static cvhaarclassifiercascade* cascade = 0; //Decision Tree
  3. void Detect_and_draw (iplimage* image);
  4. ?
  5. Const Char* cascade_name = "model.xml";
  6. Const Char* input_name = "Car.avi";
  7. int Main ()
  8. {
  9. ??? cvcapture* capture = NULL;
  10. ??? iplimage* frame = 0,*frame_copy = 0;
  11. ?
  12. ???? Cascade = (cvhaarclassifiercascade*) cvload (cascade_name,0,0,0);
  13. ??? if (!cascade)
  14. ??? {
  15. ?????? cout << "load fail" << Endl;
  16. ???}
  17. ??? Else
  18. ??? {
  19. ?????? Capture = Cvcreatefilecapture (Input_name);
  20. ???}
  21. ??? Storage = cvcreatememstorage (0); //Must be initialized
  22. ??? Cvnamedwindow ("result", 1);
  23. ??? int frame_num = Cvgetcaptureproperty (Capture,cv_cap_prop_frame_count);
  24. ?
  25. ??? while (Frame_num)
  26. ??? {
  27. ?????? DWORD tick = GetTickCount ();
  28. ?????? frame = Cvqueryframe (capture);
  29. ?
  30. ?????? Detect_and_draw (frame);
  31. ?
  32. ?????? cout << "Use time: " << GetTickCount ()-Tick << Endl;
  33. ?????? frame_num--;
  34. ?
  35. ???}
  36. ??? Cvreleasecapture (&capture);
  37. ??? Cvdestroywindow ("result");
  38. ??? return 0;
  39. }
  40. ?
  41. void Detect_and_draw (iplimage* image)
  42. {
  43. ??? int scale = 1.3;
  44. ??? Cvpoint Pt1,pt2;
  45. ??? Cvclearmemstorage (storage);
  46. ??? if (Cascade)
  47. ??? {
  48. ?????? cvseq* cars = cvhaardetectobjects (Image,cascade,storage,1.1,3,cv_haar_do_canny_pruning,cvsize (20,20));
  49. ?????? for (int i = 0; I < (cars cars->total:0); ++i)
  50. ?????? {
  51. ????????? cvrect* r = (cvrect*) Cvgetseqelem (cars,i);
  52. ????????? pt1.x = r->x*scale;
  53. ????????? PT1.Y = r->y*scale;
  54. ????????? pt2.x = (r->x + r->width) *scale;
  55. ????????? Pt2.y = (r->y + r->height) *scale;
  56. ????????? Cvrectangle (Image,pt1,pt2,cv_rgb (255,0,0), 3,8,0);
  57. ??????}
  58. ???}
  59. ??? Cvshowimage ("result", image);
  60. ??? Cvwaitkey (20);
  61. }

3, optimize the algorithm, improve the detection speed

If the memory space is large enough, it can theoretically improve the speed.

    1. From the point of view of increasing rate and accuracy, we find that the whole map detects the car, takes nearly 300ms, and how to improve the real-time of the algorithm.

      ?

      The radar monitoring obstacle coordinates, projected into the image, and its window is limited, window size 200*200, from the obstacle itself projection to the coordinates of the image, the use of vision around 60ms.

      Again, we can also increase the speed by changing the parameters inside the Haar function.

      (Note: Radar coordinates are not allowed for the reason, the condition tan, small, that is to say, pitch down more, this value on the ordinate effect is too large.) )

The detection function is as follows:

?

    1. The next thing to do:

      1) Whether we can limit its detection range by Lane line restrictions as long as the image within the lane line, others do not.

      2) If more than one obstacle is detected, we cannot determine the size of the rectangle because we do not know what the obstacle is. How to determine the length and width?

      3) Multiple obstacles are used haar words, efficiency is a problem, because the test time is too long, it is better to make the window larger, and then a one-time detection.

?

?

    1. Some minor errors:

      Libboost_thread-vc100-mt-1_47.lib (tss_pe.obj): Error LNK2038: "_iterator_debug_level" mismatch detected: value "0"

VS2010 detected a mismatch for "_iterator_debug_level" , this error is due to

When the release file is generated, it is linked to the debug file, and we need to add *d.lib to the attached property. Instead of using *.lib, this may cause a link error.

    1. Delphi ESR and Image fusion device algorithm ideas

      Image output pedestrian, vehicle, Lane line information (core chip with the Mobieye camera, can directly output lane line, pedestrian and vehicle information), and then the radar output obstacle information.

      The data is then fused within an ECU, which acts as a mutually verifiable function, and the height and width of each vehicle can be said to be certain. We can mark the width information by identifying the person and the car information.

      ?

about Delphi ESR and image fusion device algorithm thinking this piece, is our school at that time purchased a set of Delphi fusion equipment, according to the engineer described, this set of fusion equipment is Delphi and Mobieye co-development, Delphi with the Mobieye core chip, can provide lane line, pedestrian, vehicle information. At present, the Mobieye camera in our hands can only provide the following:

1, Lane line pressure alarm signal (55km/h above effective)

2, in the same lane, the vehicle alarm signal and time-distance signal (30km/h above effective)

3, in the same lane, pedestrian alarm signal (7km/h---50km/h between the effective)

Haar Adaboost Detection Vehicle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.