Comments (46)
It is a one line command, yes. But you posted it with multiple lines, like the way I did in the README of this repo. But: I put backslashes at the end of each line, so that the shell will interpret the multiple lines as one.
You can run it as a single line:
perl bin/createsamples.pl positives.txt negatives.txt samples 1700 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 24 -h 24"
I think I made an error while transcribing the command too: maxzangle 0.5
should probably be -maxzangle 0.5
from opencv-haar-classifier-training.
Did your forget the \
at the end of each line?
from opencv-haar-classifier-training.
@mrnugget
is this not a one line command ? I tried with \ as you suggested, this time no error and no sample is created
from opencv-haar-classifier-training.
@mrnugget I tried in many ways, with slash and without slash, there is no error but no sample are created in the sample folder. Can you tell me what will be there in the samples folder once the command is success and how long will it take to create samples ?
FYI - I have only 31 images each in positive_images and negative_images.
Step1 was not completely success, but i have downloaded opencv 2.4.9 framework
from opencv-haar-classifier-training.
So the command works now without an error?
Do you have the paths to your samples in positives.txt
and negatives.txt
?
from opencv-haar-classifier-training.
Yes command works without any error and i have both positives.txt and negatives.txt files and these two files are inside the root folder
from opencv-haar-classifier-training.
Okay, sounds good. But do those two files contain anything at all?
from opencv-haar-classifier-training.
Yes, it has the image paths, like, ./negative_images/imagename.jpeg
./positive_images/imagename.jpeg. I have just 31 images each for positive and negative, do you this is causing the issue ? as i said in my previous comments , step1 in your instruction is not completely success
Install OpenCV & get OpenCV source
brew tap homebrew/science
brew install --with-tbb opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9.zip
from opencv-haar-classifier-training.
Which of the four commands didn't succeed?
from opencv-haar-classifier-training.
This one - wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip. I'm trying to execute the step1, and it's going well i think, it's in ==>installing opencv
==>downloading https://github.com/Itseez/opencv/archive/2.4.9.tar.gz stage
Do you think this caused the issue ?
from opencv-haar-classifier-training.
What does "it's in ==>installing opencv ==>downloading https://github.com/Itseez/opencv/archive/2.4.9.tar.gz stage" mean? wget
should not output anything that has to do with "installing".
from opencv-haar-classifier-training.
I executed this command "brew install --without-tbb opencv" and it's installing everything, now the progress is in installing opencv
from opencv-haar-classifier-training.
Okay, that sounds like it works. Or is it stuck somewhere? Compiling opencv might take some time.
from opencv-haar-classifier-training.
It was stuck yesterday and the installing was failed. I'll complete the step 1, try to create sample again , and let you know the result. Thanks for your kind help, really appreciate it.
from opencv-haar-classifier-training.
Alright! I'll close this issue then, since the error you got from the command seems to be "fixed".
from opencv-haar-classifier-training.
@mrnugget when i compile this code
g++ pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/'
-I. -o mergevec mergevec.cpp
cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp
cvhaartraining.cpp
-lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
I get this error
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
clang: error: no such file or directory: 'mergevec'
clang: error: no such file or directory: ' -lopencv_core'
from opencv-haar-classifier-training.
What does this return?
brew info opencv
And what does this return?
pkg-config --libs --cflags opencv
from opencv-haar-classifier-training.
brew info opencv returned
opencv: stable 2.4.9, HEAD
http://opencv.org/
/usr/local/Cellar/opencv/2.4.9 (219 files, 38M) *
Built from source
From: https://github.com/homebrew/homebrew-science/blob/master/opencv.rb
==> Dependencies
Build: cmake ✔, pkg-config ✔
Required: jpeg ✔, libpng ✔, libtiff ✔
Recommended: eigen ✔, openexr ✔
Optional: gstreamer ✘, jasper ✘, libdc1394 ✘, openni ✘, qt ✘, tbb ✘, ffmpeg ✘
==> Options
--32-bit
Build 32-bit only
--c++11
Build using C++11 mode
--with-cuda
Build with CUDA support
--with-ffmpeg
Build with ffmpeg support
--with-gstreamer
Build with gstreamer support
--with-jasper
Build with jasper support
--with-java
Build with Java support
--with-libdc1394
Build with libdc1394 support
--with-openni
Build with openni support
--with-qt
Build the Qt4 backend to HighGUI
--with-quicktime
Use QuickTime for Video I/O insted of QTKit
--with-tbb
Enable parallel code in OpenCV using Intel TBB
--with-tests
Build with accuracy & performance tests
--without-eigen
Build without eigen support
--without-opencl
Disable GPU code in OpenCV using OpenCL
--without-openexr
Build without openexr support
--HEAD
install HEAD version
==> Caveats
If you need Python to find the installed site-packages:
mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
and pkg-config --libs --cflags opencv returned
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
from opencv-haar-classifier-training.
What does this return?
which pkg-config
And this?
brew ls opencv
from opencv-haar-classifier-training.
which pkg-config returned
/opt/local/bin/pkg-config
brew ls opencv returned
/usr/local/Cellar/opencv/2.4.9/bin/opencv_createsamples
/usr/local/Cellar/opencv/2.4.9/bin/opencv_haartraining
/usr/local/Cellar/opencv/2.4.9/bin/opencv_performance
/usr/local/Cellar/opencv/2.4.9/bin/opencv_traincascade
/usr/local/Cellar/opencv/2.4.9/include/opencv/ (11 files)
/usr/local/Cellar/opencv/2.4.9/include/opencv2/ (150 files)
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_calib3d.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_contrib.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_core.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_features2d.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_flann.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_gpu.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_highgui.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_imgproc.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_legacy.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_ml.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_nonfree.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_objdetect.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_ocl.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_photo.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_stitching.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_superres.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_video.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_videostab.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/pkgconfig/opencv.pc
/usr/local/Cellar/opencv/2.4.9/lib/python2.7/ (2 files)
/usr/local/Cellar/opencv/2.4.9/lib/ (37 other files)
/usr/local/Cellar/opencv/2.4.9/share/OpenCV/ (29 files)
from opencv-haar-classifier-training.
Seems like all the necessary files are there for pkg-config to work with opencv. But the path for pkg-config seems to be off.
Did you install homebrew to /opt/local? What does brew --prefix
return?
from opencv-haar-classifier-training.
I'm not sure where i installed :(
brew --prefix returned
/usr/local
from opencv-haar-classifier-training.
It seems like homebrew is installed to /usr/local but your $PATH contains /opt/local
before /usr/local/bin
. You need to change your $PATH variable, so it's the other way around and which pkg-config
returns /usr/local/bin/pkg-config
.
from opencv-haar-classifier-training.
ok, should i uninstall homebrew completely and install again or is there any way to change the $PATH to /usr/local/bin ?
from opencv-haar-classifier-training.
No, you don't need to reinstall homebrew. Setting $PATH is pretty common and you should easily find how to do it on your system. See this google search.
from opencv-haar-classifier-training.
After a complete mess, i finally set the $PATH. Now which pkg-config returns "/usr/local/bin/pkg-config"
But i have another issue, When i run the following command
perl bin/createsamples.pl positives.txt negatives.txt samples 1500
"opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1
-maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"
i get some syntax error
opencv_createsamples -bgcolor 0 -bgthresh 0 -maxangle 1.1 -maxyangle 1.1 -maxzangle 0.5 -maxidev 40 -w 40 -h 40 -img ./positive_images/images (7).jpeg -bg tmp -vec samples/images (7).jpeg.vec -num 1
sh: -c: line 0: syntax error near unexpected token `('
from opencv-haar-classifier-training.
ok, Now i fixed the above error by leaving space between each image file in the neg and pos images folder. below command is also success
cp src/mergevec.cpp ~/opencv-2.4.9/apps/haartraining
cd ~/opencv-2.4.9/apps/haartraining
g++ pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/'
-I. -o mergevec mergevec.cpp
cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp
cvhaartraining.cpp
-lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
after this, i switched to the root folder , that is , opencv-haar-classifier-training-master and i ran the below two commands
find ./samples -name '*.vec'>samples.txt -->This is success
./mergevec samples.txt samples.vec --> gives "-bash: ./mergevec: No such file or directory"
If i don't switch to root folder and run this command ;
find ./samples -name '*.vec'>samples.txt -->find: ./samples: No such file or directory
from opencv-haar-classifier-training.
Yep, you need to copy/move the mergevec
executable to the root folder.
from opencv-haar-classifier-training.
finally in training cascade stage, does it really take such a long time ? I have 30 positive images and 15 negative images and used below code
opencv-haar-classifier-training-master pradeepchandrasekaran$ opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 9 -numNeg 3 -w 30 -h 30 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024
first 13 stages are very fast, but next stage is taking too long, almost 3 hours , is it normal or am i doing s'thing wrong ? The reason why i used -numPos 9 -numNeg 3 eventhough i have 30 & 15 respectively , is that i have seen the calculation in some post. Could you please tell me how much images you had in each category and how long did it take for you to complete the training ?
from opencv-haar-classifier-training.
As I wrote in my original blogpost it took several days for my training process to finish (the number of samples is mentioned there as well)
from opencv-haar-classifier-training.
ok, Thank you so much for helping @mrnugget 👍 Really appreciate your quick response. All the best
from opencv-haar-classifier-training.
👍 👍 👍
from opencv-haar-classifier-training.
@mrnugget probably i need one more help from you. I had set 15 stages and it was completed. When i run the final command , i named the xml as smilingface.xml, i couldn't see this xml anywhere and i'm getting error
./facedetect --cascade="~/smilingface.xml"
This program demonstrates the cascade recognizer. Now you can use Haar or LBP features.
This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.
It's most known use is for faces.
Usage:
./facedetect [--cascade=<cascade_path> this is the primary trained classifier such as frontal face]
[--nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]
[--scale=<image scale greater or equal to 1, try 1.3 for example>]
[--try-flip]
[filename|camera_index]
see facedetect.cmd for one call:
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3
During execution:
Hit any key to quit.
Using OpenCV version 2.4.9
Processing 1 --cascade=~/smilingface.xml
from which we have cascadeName= ~/smilingface.xml
ERROR: Could not load classifier cascade
from opencv-haar-classifier-training.
It didn't produce a file? Weird.
If it has, try running it without putting the filename in quotes or without
using "~/" (use absolute path instead)
On Monday, November 17, 2014, pradeepktg [email protected] wrote:
@mrnugget https://github.com/mrnugget probably i need one more help
from you. I had set 15 stages and it was completed. When i run the final
command , i named the xml as smilingface.xml, i couldn't see this xml
anywhere and i'm getting error./facedetect --cascade="~/smilingface.xml"
This program demonstrates the cascade recognizer. Now you can use Haar or
LBP features.
This classifier can recognize many kinds of rigid objects, once the
appropriate classifier is trained.
It's most known use is for faces.
Usage:
./facedetect [--cascade= this is the primary trained classifier such as
frontal face]
[--nested-cascade[=nested_cascade_path this an optional secondary
classifier such as eyes]]
[--scale=]
[--try-flip]
[filename|camera_index]see facedetect.cmd for one call:
./facedetect
--cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml"
--nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3During execution:
Hit any key to quit.
Using OpenCV version 2.4.9Processing 1 --cascade=~/smilingface.xml
from which we have cascadeName= ~/smilingface.xml
ERROR: Could not load classifier cascade—
Reply to this email directly or view it on GitHub
#4 (comment)
.
from opencv-haar-classifier-training.
nope, no success, i tried without quotes and without ~/. Below is the error
./facedetect --cascade= ~/smilingface.xml
This program demonstrates the cascade recognizer. Now you can use Haar or LBP features.
This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.
It's most known use is for faces.
Usage:
./facedetect [--cascade=<cascade_path> this is the primary trained classifier such as frontal face]
[--nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]
[--scale=<image scale greater or equal to 1, try 1.3 for example>]
[--try-flip]
[filename|camera_index]
see facedetect.cmd for one call:
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3
During execution:
Hit any key to quit.
Using OpenCV version 2.4.9
Processing 1 --cascade=
from which we have cascadeName=
Processing 2 /Users/pradeepchandrasekaran/smilingface.xml
OpenCV Error: Null pointer (NULL or empty buffer) in cvOpenFileStorage, file /tmp/opencv-4KWvU5/opencv-2.4.9/modules/core/src/persistence.cpp, line 2697
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-4KWvU5/opencv-2.4.9/modules/core/src/persistence.cpp:2697: error: (-27) NULL or empty buffer in function cvOpenFileStorage
Abort trap: 6
from opencv-haar-classifier-training.
But the file exists?
On Tuesday, November 18, 2014, pradeepktg [email protected] wrote:
nope, no success, i tried without quotes and without ~/. Below is the error
./facedetect --cascade= ~/smilingface.xml
This program demonstrates the cascade recognizer. Now you can use Haar or
LBP features.
This classifier can recognize many kinds of rigid objects, once the
appropriate classifier is trained.
It's most known use is for faces.
Usage:
./facedetect [--cascade= this is the primary trained classifier such as
frontal face]
[--nested-cascade[=nested_cascade_path this an optional secondary
classifier such as eyes]]
[--scale=]
[--try-flip]
[filename|camera_index]see facedetect.cmd for one call:
./facedetect
--cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml"
--nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3During execution:
Hit any key to quit.
Using OpenCV version 2.4.9Processing 1 --cascade=
from which we have cascadeName=
Processing 2 /Users/pradeepchandrasekaran/smilingface.xml
OpenCV Error: Null pointer (NULL or empty buffer) in cvOpenFileStorage,
file /tmp/opencv-4KWvU5/opencv-2.4.9/modules/core/src/persistence.cpp, line
2697
libc++abi.dylib: terminating with uncaught exception of type
cv::Exception:
/tmp/opencv-4KWvU5/opencv-2.4.9/modules/core/src/persistence.cpp:2697:
error: (-27) NULL or empty buffer in function cvOpenFileStorageAbort trap: 6
—
Reply to this email directly or view it on GitHub
#4 (comment)
.
from opencv-haar-classifier-training.
Nope.the file is not there in the "classifier" folder
from opencv-haar-classifier-training.
So there is nothing in your "classifier" directory? That would mean that the training didn't work. And I have no idea why that would be, sorry.
from opencv-haar-classifier-training.
I mean 14 stages xml files are there , but not the final xml (smilingface.xml), which is suppose to be generated after this ./facedetect --cascade= ~/smilingface.xml command
from opencv-haar-classifier-training.
The XML file is not supposed to be generated by the facedetect
command, no. It's supposed to be the result of the opencv_traincascade
command. And there you specified -data cascade
, which would not result in a smilingface.xml
file.
Sorry, don't know more about that.
from opencv-haar-classifier-training.
ok, if i'm not wrong, cascade.xml in the "classifier" folder is the output/generated xml file ? if yes, then i think my training was successful and can i use cascade.xml file in my ios application without last command ?
cd /opencv-2.4.9/samples/c/finished_classifier.xml"
chmod +x build_all.sh
./build_all.sh
./facedetect --cascade="
from opencv-haar-classifier-training.
Yes, exactly right: the "cascade.xml" file in the "classifier" folder is the final classifier file.
The last command is just there to try it out :) It uses the facedetect
program that ships with OpenCV to try out the classifier.
from opencv-haar-classifier-training.
OMG. I have deleted all the xml files and restarted the training with 20 stages. Anyways, happy to read the cascade.xml is the final output :) Thank you again so much 👍 👍 After this it's my headache to detect the objects i'm intended to
Danke
from opencv-haar-classifier-training.
Oh! Sorry to hear! Well, good luck then with the new process! 👍
from opencv-haar-classifier-training.
Danke
from opencv-haar-classifier-training.
please help me to solve my error....... I have run the createsamples command but my info folder is empty.
from opencv-haar-classifier-training.
Related Issues (20)
- hi, i'm getting like this while creating my own harr-cascade classifier, please let me correct if anything wrong, and please tell the reason for why classifier cant be trained? and thanks in advance HOT 3
- Illegal division by zero at bin/createsamples.pl line 45. HOT 3
- OpenCV error : Bad Arguement - Can not get new Positive Sample
- no vec files
- Can not see finished_classifier.xml file HOT 15
- unable to create .vec files with create samples file HOT 1
- how createsamples.pl will works? HOT 1
- Error when create samples HOT 1
- Cannot create sample.vec HOT 14
- opencv_createsamples not creating anything inside the 'samples' folder HOT 1
- not able to create final classifier HOT 1
- File not found - '*.jpg' HOT 1
- Please Help
- std::logic_error
- opencv error assertion failed
- sh: 1: Syntax error: Unterminated quoted string HOT 1
- opencv_traincascade assertion error HOT 2
- vec files can't be created HOT 1
- mergevec.py error
- 'opencv_createsamples' is not recognized as an internal or external command, HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv-haar-classifier-training.