如何创建HaarCascade XML文件 [英] How to Create HaarCascade XML file

查看:177
本文介绍了如何创建HaarCascade XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要创建HarrCascade XML文件以将其与OpenCV一起使用来跟踪我的对象,并且我已经进行了研究,并且很喜欢创建HaarCascade的许多方法,但是在C ++中,所有这些都还不是很清楚,但是我是C#开发人员,我Emgu与OpenCV一起工作,但是我在C ++中不擅长

我需要函数可以创建HaarCascade,但不需要C ++代码


我需要的功能拍摄图像并解析该图像并进行一些计算,并创建具有此计算结果的XML文件

此函数是OpenCV函数之一,但我在C#(Emgu或OpenCVDotNet)中需要它


问候,

Hi All,

I need to create HarrCascade XML file to use it with OpenCV to tracking my object, and I have researched and I fond many way to create HaarCascade but it all of this is not clearly it all in C++ but I''m a C# developer and I work with OpenCV by Emgu however I''m not good in C++

I need function can create HaarCascade but I don''t need C++ code


the function I need It take images and parse this images and make some calculation and create XML file having the result of this calculation

this function is one of OpenCV functions but I need it in C# (Emgu or OpenCVDotNet)


Regards,

推荐答案

嗨艾哈迈德,

我本来想为您提供简明扼要的答案,但由于时间有限,所以我深表歉意.我已经使用EMGU几年了,并且已经广泛研究了Haar分类器.我打算在某个时候写一篇文章. Haar分类器上有很多东西,但是很好的来源是此处 [
opencv_createsamples.exe
opencv_haartraining.exe


现在,如果您跳了个脑袋并尝试运行这些程序之一,那么您不应该做所有将要发生的事情,因为控制台窗口将打开以显示一些文本,并且通常在您看到这些文本之前将其关闭.

要使用这些控制台应用程序,必须通过从开始菜单中选择RUN ..并通过命令行对其进行调用,然后键入CMD并按Enter,然后将出现一个控制台窗口.现在输入opencv_createsamples.exe的位置

例如C:\ EMGU \ bin \ opencv_createsamples.exe

它将仅显示命令行调用的所有可能输入
Hi Ahmed,

I was going to try and give you are concise answer but I''m limited for time so I apologise. I''ve been using EMGU for several years now and I''ve looked into Haar Classifiers extensively. I intend to write an article at some point. There is a lot out there on Haar classifiers but a very good source is Here[^].

Now the tutorial isn''t very clear but I did write c# program utilising EMGU to create the Haar classifier for you and I''ll try and dig it out. Now the most important thing I need to make sure you understand is the complexity of forming a Haar cascade and make sure you wish to go down this line, it''s not a quick process.

If your running Linux based OS then I can''t help you much other than the steps you need. As for timing issues to generate a good Haar classifier you will need several thousand sample images and powerful processor (single core as multiple cores are not supported yet) and about a week or more access.

From the papers I have read it can take between a day to over a week to form these classifiers and yes there is no way of knowing if the classifier will work.

The Steps Involved



Sample Images


Positive
The website I provided a link to uses positive 5000 sample images I would recommend this to be the minimum you utilise while you may think you don''t need as many all you will end up doing is wasting your time and producing a cascade that doesn''t work. I would recommend producing a quick c# application using EMGU that allows you to select a ROI (region of interest) and save that to a file using a standard naming convention i.e. 1.jpg-5000.jpg

Negative
The number of Negative sample image does not have to be as high as positive ones but there needs to be a large amount generally tailored to the background the object your looking for will regularly occur on.

So if it''s cars in a car park you need a few thousand images of the carpark without cars present and under different conditions snow, rain , night, day etc.

Creating Samples


This is done using a command line program now I would assume this is were you''ve found the C++ code but don''t worry this is compiled for you if you examine the "Installation Directory of EMGU\Bin" folder you will find the follwing compiled files

opencv_createsamples.exe
opencv_haartraining.exe


Now if you jumped a head and tried to run one of these programs then you shouldn''t have done all that will happen is the console window will open show some text and close usually before you will see the text.

To utilise these console applications they have to be called through command line from the start menu select RUN.. and type in CMD press enter and a console window will appear. Now type the location of opencv_createsamples.exe

e.g C:\EMGU\bin\opencv_createsamples.exe

It will simply display all the possible inputs for the command line call
Usage: ./createsamples
  [-info <description_file_name>]
  [-img <image_file_name>]
  [-vec <vec_file_name>]
  [-bg <background_file_name>]
  [-num <number_of_samples = 1000>]
  [-bgcolor <background_color = 0>]
  [-inv] [-randinv] [-bgthresh <background_color_threshold = 80>]
  [-maxidev <max_intensity_deviation = 40>]
  [-maxxangle <max_x_rotation_angle = 1.100000>]
  [-maxyangle <max_y_rotation_angle = 1.100000>]
  [-maxzangle <max_z_rotation_angle = 0.500000>]
  [-show [<scale = 4.000000>]]
  [-w <sample_width = 24>]
  [-h <sample_height = 24>]




现在,请查看网页
此处 [




Now please look at the web page Here[^] and about a 1/3rd of the way down you will see 2. Create training samples from some follow th steps involved you will have tor create the -info <description_file_of_samples> file yourself it''s just a simple text file holding relevant file information about your training sets.

The Cascade


I don''t wish to re-write the webpage I''ve provided a link for so you will have to work through the steps it shows from now on. Despite it being a bit hard to read through once the samples are created you should utilise opencv_haartraining.exe from now on to generate your Haar Cascade. Calling it in the same command line fashion as before. If all goes well you will have a classifier that works.

Please take note that the more stages you have to your cascade the more accurate it will be however the longer it will take to complete calculations and generate the required XML file.

Notes



I hope this helps you and please feel free to ask extra questions I''ll answer them as soon as I can when I have found the c# to generate the Haar classifiers I will write an article and upload it and of course post the link here

Cheers
Chris


首先,不要要求任何东西.我们都是志愿者,完全不必回答您.

如果您需要翻译某些C ++的帮助,则可以发布摘要并询问.
First, don''t ask for something ASAP. We are all volunteers here and don''t have to answer you at all.

If you need help translating some of the C++ perhaps you could post a snippet and ask.


感谢中继,

是的,它是一个XML文件,但不仅仅是一个字符串,我需要函数拍摄图像并给我一个XML文件,因为我需要使用该XML文件来检测图像中我们将其提供给对象的同一对象.函数(HaarCascade创建者)

问候
Thanks for relay,

Yes it''s a XML file but it''s not just a string, I need function take images and give me a XML file, because I need use that XML file to detecting the same object in the image which we gave it to the function (HaarCascade creator)

Regards,


这篇关于如何创建HaarCascade XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆