cdut007 / javacv

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

Problem on converting BufferedImage to IplImage #97

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
for (int i = 0; i < total; i++) {
                    CvRect r = new CvRect(cvGetSeqElem(faces, i));  // putting of rectangular markers to the detected faces
                    int x = r.x(), y = r.y(), w = r.width(), h = r.height();
                    cvRectangle(grabbedImage, cvPoint(x, y), cvPoint(x+w, y+h), CvScalar.RED, 1, CV_AA, 0);   
                    System.out.println("x = " + x + " y = " + y );
                    BufferedImage image = grabbedImage.getBufferedImage();
                    BufferedImage image2 = image.getSubimage(x, y, w, h);
                    faceExtract[i] = image2;                                                   
                    // this is the line where I got an error
                    IplImage imageGray = IplImage.createFrom(image2);
                    cvCvtColor(imageGray,imageGray,CV_BGR2GRAY);
                    BufferedImage image3 = null;
                    imageGray.copyTo(image3);
                    clipImage(image3,w,h);
                }     

What is the expected output? What do you see instead?
I should see an grayscaled image of the extracted faces, but rather I got this 
error message:

Exception in thread "main" java.lang.IndexOutOfBoundsException
    at java.nio.ByteBuffer.wrap(ByteBuffer.java:352)
    at com.googlecode.javacv.cpp.opencv_core$IplImage.copyFrom(opencv_core.java:856)
    at com.googlecode.javacv.cpp.opencv_core$IplImage.createFrom(opencv_core.java:475)
    at ojt.FaceTracking.<init>(FaceTracking.java:109)
    at ojt.FaceTracking.main(FaceTracking.java:157)

What version of the product are you using? On what operating system?
I am using Netbeans IDE 7.0, and OpenCv 2.2 and OS is Windows 7

Please provide any additional information below.
what seems to be the problem?
how do I solve this error?

Original issue reported on code.google.com by petervil...@gmail.com on 3 Aug 2011 at 1:48

GoogleCodeExporter commented 9 years ago
Thanks for reporting! It will be fixed in the next release soon...

Original comment by samuel.a...@gmail.com on 20 Aug 2011 at 5:06

GoogleCodeExporter commented 9 years ago
Fixed in latest release

Original comment by samuel.a...@gmail.com on 20 Aug 2011 at 1:34

GoogleCodeExporter commented 9 years ago
Hi, which release has solved this ? 
I am facing the same issue. Using OpenCV 2.2 along with JavaCV 0.3.

Original comment by viralrse...@gmail.com on 6 Jan 2013 at 5:01

GoogleCodeExporter commented 9 years ago
Didn't use version number back then, but yeah JavaCV 0.3 and OpenCV *2.4.3* 
should work.

Original comment by samuel.a...@gmail.com on 6 Jan 2013 at 5:25

GoogleCodeExporter commented 9 years ago
Hi, I am not able to use OpenCV 2.4.3 with JavaCV 0.3.
Reason for that is because
below mentioned code-annotations are written in the JavaClasses such as 
opencv_objdetect

@Properties(value = {
    @Platform(include = {"<opencv2/objdetect/objdetect.hpp>"}, includepath = {"/opt/local/include/"}, linkpath = {"/opt/local/lib/:/opt/local/lib64/:/usr/local/lib/:/usr/local/lib64/"}, link = {"opencv_objdetect"}),
    @Platform(value = {"windows"}, includepath = {"C:/OpenCV2.2/include/"}, linkpath = {"C:/OpenCV2.2/lib/"}, preloadpath = {"C:/OpenCV2.2/bin/Release/;C:/OpenCV2.2/bin/"}, link = {"opencv_objdetect220"}),
    @Platform(value = {"android"}, includepath = {"../include/"}, linkpath = {"../lib/"})})

The above mentioned hard coded values would not make me able to use Open CV 
other than 2.2
Moreover, 
When i install Open CV 2.4.3 I can not see any lib or bin folder as well. which 
are used in the code as mentioned above

Please instruct. 

Original comment by viralrse...@gmail.com on 6 Jan 2013 at 6:27

GoogleCodeExporter commented 9 years ago
JavaCV 0.3 doesn't have those lines

Original comment by samuel.a...@gmail.com on 6 Jan 2013 at 7:04

GoogleCodeExporter commented 9 years ago
Thanks a lot for the hint. probably I imported wrong lib. 

Original comment by viralrse...@gmail.com on 6 Jan 2013 at 7:42