开发者

How to create Haar Cascade (.xml file) to use in OpenCV? [closed]

开发者 https://www.devze.com 2022-12-15 15:31 出处:网络
Closed. This question needs to be more focused. It is no开发者_如何学Got currently accepting answers.
Closed. This question needs to be more focused. It is no开发者_如何学Got currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 17 days ago.

The community reviewed whether to reopen this question 17 days ago and left it closed:

Original close reason(s) were not resolved

Improve this question

If you are familiar with OpenCV library, you know what Haar Cascade image object detection is. By image object detection I mean, like human face detection or something else. I have some Haar Cascade XMLs for face detection, but I don't know how to create my own. I want to create Haar Cascade XMLs to detect simple bright circle light sources (i.e. flashing infrared light from TV remote control).

So, how do I create a Haar Cascade (.xml file) to use in OpenCV?


If you are interested to detect simple IR light blob through haar cascade, it will be very odd to do. Because simple IR blob does not have enough features to be trained through opencv like other objects (face, eyes,nose etc). Because IR is just a simple light having only one feature of brightness in my point of view. But if you want to learn how to train a classifier following link will help you alot.

http://note.sonots.com/SciSoftware/haartraining.html

And if you just want to detect IR blob, then you have two more possibilities, one is you go for DIP algorithms to detect bright region and the other one which I recommend you is you can use an IR cam which just pass the IR blob and you can detect easily the IR blob by using opencv blob functiuons. If you think an IR cam is expansive, you can make simple webcam to an IR cam by removing IR blocker (if any) and add visible light blocker i.e negative film, floppy material or any other. You can check the following link to convert simple webcam to IR cam.

http://www.metacafe.com/watch/385098/transform_your_webcam_into_an_infrared_cam/


How to create CascadeClassifier :

  1. Open this link : https://github.com/opencv/opencv/tree/master/data/haarcascades
  2. Right click on where you find "haarcascade_frontalface_default.xml"
  3. Click on "Save link as"
  4. Save it into the same folder in which your file is.
  5. Include this line in your file face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
0

精彩评论

暂无评论...
验证码 换一张
取 消