Ask Your Question

opencv mergevec haartraining issues

asked 2015-02-22 21:33:39 -0500

austin gravatar image

I'm running windows 7, and i'm trying to get some haar training done to make a haar classifier. I've got to the point were i need to merge a folder full of .vec files. I've been working on this for the better part of a day. I've tried following coding robin's tutorial but i get an error of:

g++.exe": pkg-config: No such file or directory
g++.exe": opencv -I.: No such file or directory
g++.exe": installation problem, cannot exec `cpp': No such file or directory is this "installation problem" a problem with my g++ install? I'm still not sure.

those files (or directories) aren't in my opencv folder so i'm not really sure what to do about that. I vaguely remember reading that those were for if you were installing it with linux or something so i tried a different method.

I couldn't get Naotoshi Seo's to work because i can't download the mergevec.exe file anywhere. I always get a "your computer or network may be sending automated queries. To protect our users, we can't process your request right now." I've done virus scans i've tried downloading from different computers and networks nothing works. since the previous method of compiling the mergevec.cpp file didn't work for me either, I then looked for yet another method where i found this tutorial for using python. So I installed python 2.7.9 and ran this in command prompt

"C:\Users\Austin\Desktop\Recog_Project>python -v samples -o weed_samples.vec"

and i got this as a result

Traceback (most recent call last):
File "", line 170, in <module>
merge_vec_files(vec_directory, output_filename)
File "", line 133, in merge_vec_files
val = struct.unpack('<iihh', content[:12])="" <br=""> struct.error: unpack requires a string argument of length 12" I don't know what to do anymore to try and get this to work.

I've tried installing Ubuntu on a virtual machine, but i can't even figure out how to change the resolution from 640:480. Ran these commands in terminal and restarted and got nothing.

sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

I also did something with some drivers but I can't remember what it was. basically this is my last hope. I'm out of ideas. I'll of course keep looking and for answers and will post any progress i make. Any help at all would be greatly appreciated as my job is on the line. I could skype screen share if it would be helpful too. Thanks in advance.

edit retag flag offensive close merge delete


For those who are still looking for an answer to get rid of this error: You need to run it with python2, not python3 This solved it for me

Lukas gravatar imageLukas ( 2017-01-03 21:04:27 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-02-23 06:20:30 -0500

Let me answer to this

  • You do not need to merge vec files for object classifier training using the cascade of weak classifiers approach. I keep wonder why the hell people merge vec files, and always the answer is because they want to create artificial data vectors. Avoid this at all costs if you want you models to do something with sense.
  • Skip the complete haar training interface and move on to the traincascade interface, which is better supported, more bugfree and better supported.
  • Start with the traincascade and createsamples information in the documentation.
edit flag offensive delete link more



Thanks for the response I'll definitely use this method instead. I'll post my results. The main reason i was doing it the other way is because I've barely understand any of this, and I'm just following tutorials. Hopefully i can finish before my dead line. If you use stack overflow i posted this question there too. So i'll upvote and stuff if you post this answer there too.

austin gravatar imageaustin ( 2015-02-24 11:24:58 -0500 )edit

@austin, I am not active on SO, simply keeping my work to this Q&A :)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-25 02:27:18 -0500 )edit

@StevenPuttemans Thanks for the answer - would you mind elaborating on why artificial data is a poor approach and what the better approach is? (I realize the tutorials give an extended answer, but it would be great to have a concise one as well) Thanks

slice_and_dice gravatar imageslice_and_dice ( 2015-05-20 22:30:55 -0500 )edit

Artificial data has data representations that will not be available in your application. For example if you take a plain logo and then transform it on the different backgrounds with the createsamples tool, then you will have positive image which are that transformed that they are not possible in reality. It is better to collect a large set of true positive instances, grabbed from your actual setup where you will use this detector, rather than using 1 and transforming it to 1000 samples.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-05-27 08:14:17 -0500 )edit

Just to make sure I understand: are you advising against data augmentation? I'm working on detecting roofs as seen on aerial images and there is quite a bit of variation. I don't have a lot of annotated data (around 300 examples). I was planning to augment the data by: flipping it, rotating it and changing the contrast. Do you think this is a bad idea? I expect to see this sort of variation in the testing data. Also, if this is advisable, is there a good way to merge .vec files?

angela gravatar imageangela ( 2015-06-23 13:39:07 -0500 )edit

Yes I am. Saying * I expect to see this sort of variation in the testing data* means as much as it is possible but it is also not. If you apply transformations manually than you can somewhat control the behaviour but the inbuilt variation does things which are plain and artificial. You want your training data to represent your case as much as possible. I therefore suggest that it is better to use 300 real examples than to use 15000 artificial examples. Me myself I never merged vec files before, so I am not aware of functions that do this.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-06-24 03:42:07 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-02-22 21:33:39 -0500

Seen: 3,840 times

Last updated: Feb 23 '15