ChitraPathak / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Issue with javacv implementation of HOG descriptor #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  use the HoG descriptor class like samples/peopledetect.cpp
2.    hog.setSVMDetector(HOGDescriptor.getDefaultPeopleDetector());
3.  it will not be complied because javacv defines incompatible data type. 

I have tried to make conversion between FloatPointer and cvArr in the attached 
code. It could be complied , but when you make your running on it, it crashes 
on Hog.detectMultiScale().

I have use HOG to extract features only in JavaCV, after some hack, it works. 
but not for HOG +SVM.  Any clue? Is this because of incomplete implementation 
in JavaCV.

What is the expected output? What do you see instead?
return the detected  pedestrian rectangle

What version of the product are you using? On what operating system?
Newest JavaCV with newest stable OpenCV 2.1
jdk1.6,Ubuntu

Please provide any additional information below.

        HOGDescriptor hog=new HOGDescriptor(); 
        FloatPointer f=HOGDescriptor.getDefaultPeopleDetector();
        CvMat defaultSVM= CvMat.create(1,f.capacity(),CV_64F);

        for (int i=0;i<f.capacity();i++){
            f.position(i);
            defaultSVM.put(i, f.get());
        }

        hog.setSVMDetector(defaultSVM);

Original issue reported on code.google.com by lumin.zh...@gmail.com on 23 Nov 2011 at 8:31

GoogleCodeExporter commented 9 years ago
Strange, I wonder why they use different types in C++ if they are supposed to 
be the same type. I will be providing a setSVMDetector(FloatPointer) method in 
the next release, but for the moment I suppose something like this should work:

    HOGDescriptor hog = new HOGDescriptor(); 
    FloatPointer f = HOGDescriptor.getDefaultPeopleDetector();
    CvMat defaultSVM = CvMat.createHeader(f.capacity(), 1, CV_32FC1);
    defaultSVM.data_fl(f);
    hog.setSVMDetector(defaultSVM);

Let me know if this works! thanks

Original comment by samuel.a...@gmail.com on 26 Nov 2011 at 11:27

GoogleCodeExporter commented 9 years ago
Hi, Samuel,

I have tried your code.
it works somehow .

CvRect found = null;
hog.detectMultiScale(image, found, 0, cvSize(8, 8), cvSize(32, 32),1.05, 2);

But hog generally returns null found. sometimes it crashes if you increase the 
upper limit of the window size.

I have run the peopledetect application from cpp sample,even the same input 
images don't have the same results.

Original comment by lumin.zh...@gmail.com on 29 Nov 2011 at 5:13

GoogleCodeExporter commented 9 years ago
Well, this works just fine here:
    CvRect found = new CvRect(null);
    IplImage img = cvLoadImage("gaitsetA-gait2.jpg");
    hog.detectMultiScale(img, found, 0, cvSize(8,8), cvSize(32,32), 1.05, 2);
    System.out.println(found);

I get (67, 7; 71, 142) on this image 
http://www.cbsr.ia.ac.cn/images/gaitsetA-gait2.jpg which looks about right.

Original comment by samuel.a...@gmail.com on 12 Dec 2011 at 7:26

GoogleCodeExporter commented 9 years ago
Hi Samuel, 

Why is "found" in "hog.detectMultiScale" a single CvRect rather than a vector 
of CvRect's, as is specified in the following link? 
http://opencv.itseez.com/modules/gpu/doc/object_detection.html

Is there a way to get all CvRect's that are found by "hog.detectMultiScale" in 
javacv?

Original comment by zan...@gmail.com on 8 Jan 2012 at 6:36

GoogleCodeExporter commented 9 years ago
Fixed in latest release!

@zanetu, a CvRect object is a Pointer, which can be a native array. Just check 
Pointer.capacity() and use Pointer.position() functions as shown in the 
README.txt file, and please post your questions on the mailing list next time, 
thank you!

Original comment by samuel.a...@gmail.com on 8 Jan 2012 at 3:50

GoogleCodeExporter commented 9 years ago
Thanks a lot.
Sorry for the inconvenience that was caused. I'll post on the mailing
list next time.

Original comment by zan...@gmail.com on 8 Jan 2012 at 8:44

GoogleCodeExporter commented 9 years ago
Hi samule can you help me?

Original comment by elmarrhe...@gmail.com on 30 Apr 2013 at 5:20

GoogleCodeExporter commented 9 years ago
Hi samuel what is the code for this?.. Plese gave me the source code in java...

Original comment by elmarrhe...@gmail.com on 30 Apr 2013 at 5:26

Attachments:

GoogleCodeExporter commented 9 years ago
hi samuel ,
can you help me ? can u mail me the source code of human detection using hog in 
java ?
thankx.

Original comment by AKKI...@gmail.com on 13 Mar 2014 at 10:01

GoogleCodeExporter commented 9 years ago
@elmarrhex @AKKI There's some C++ sample here:
https://github.com/Itseez/opencv/blob/2.4/samples/cpp/peopledetect.cpp
Please post your questions on the mailing list if possible, thanks!

Original comment by samuel.a...@gmail.com on 16 Mar 2014 at 1:19