cdut007 / javacv

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

Could not find class 'java.awt.image.BufferedImage' when tried to use ROI #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Edit facepreview sample and add setImageROI for grayimage:
CvRect face = (CvRect)cvGetSeqElem(faces, 0);

        cvSetImageROI(
            grayImage,                   
            cvRect(
                face.x(),            
                face.y() + face.height(), 
                face.width(),       
                face.height()    
            )
        );
Without setting ROI code runs fine.

What is the expected output? What do you see instead?
sets ROI in greyimage to face rectable

What version of the product are you using? On what operating system?
Android 2.3.4 + armeabiv7 + latest javacv 

Please provide any additional information below.

Logcat:
08-17 23:24:44.578: DEBUG/dalvikvm(13984): VFY: replacing opcode 0x1f at 0x01fe
08-17 23:24:44.578: ERROR/dalvikvm(13984): Could not find class 
'java.awt.image.BufferedImage', referenced from method 
com.googlecode.javacv.cpp.opencv_core$IplImage.getBufferedImage
08-17 23:24:44.578: WARN/dalvikvm(13984): VFY: unable to resolve new-instance 
831 (Ljava/awt/image/BufferedImage;) in 
Lcom/googlecode/javacv/cpp/opencv_core$IplImage;
08-17 23:24:44.578: DEBUG/dalvikvm(13984): VFY: replacing opcode 0x22 at 0x007f
08-17 23:24:44.578: DEBUG/dalvikvm(13984): VFY: dead code 0x0011-0025 in 
Lcom/googlecode/javacv/cpp/opencv_core$IplImage;.getBufferedImage 
(DLjava/awt/color/ColorSpace;)Ljava/awt/image/BufferedImage;
08-17 23:24:44.578: DEBUG/dalvikvm(13984): VFY: dead code 0x003e-003e in 
Lcom/googlecode/javacv/cpp/opencv_core$IplImage;.getBufferedImage 
(DLjava/awt/color/ColorSpace;)Ljava/awt/image/BufferedImage;

Thanks
Roman

Original issue reported on code.google.com by rho...@quadbase.com on 17 Aug 2011 at 9:38

GoogleCodeExporter commented 9 years ago
I tried workaround this, but Image.copyFrom(grayImage, 1.0, arg2) have arg2 
awt.Rectable.
The type java.awt.Rectangle cannot be resolved. It is indirectly referenced 
from required .class files. 

Is there any way to use ROI on android? 

Thanks

Original comment by rho...@quadbase.com on 19 Aug 2011 at 5:23

GoogleCodeExporter commented 9 years ago
Android comes with no classes from the java.awt package, so it is perfectly 
normal that you get an "ERROR" about those. You will get this "ERROR" whether 
you use cvSetImageROI() or not. In fact, it is a problem if you do not get this 
ERROR. Can you confirm that you see this ERROR when you do not use 
cvSetImageROI()? If you do not get the ERROR, please report it.

In any case, your problem is elsewhere, e.g.: You probably want to write 
cvSetImageROI(grayImage, face).

Original comment by samuel.a...@gmail.com on 20 Aug 2011 at 12:48

GoogleCodeExporter commented 9 years ago
Thanks for reply.

When I use cvSetImageROI there is no warning in Eclipse, only error in logcat 
as above.
When using Image.copyFrom, there is warning in Eclipse.
The type java.awt.Rectangle cannot be resolved. It is indirectly referenced 
from required .class files. 

Ok I will try to write cvSetImageROI for CvRect, or use this 
http://code.google.com/p/awt-android-compat/

Original comment by rho...@quadbase.com on 20 Aug 2011 at 10:04

GoogleCodeExporter commented 9 years ago
Hi guys, did you solve this?
I cannot use any command working with CvRect on Android due this :/

Dupla

Original comment by du...@centrum.cz on 28 Aug 2011 at 3:25

GoogleCodeExporter commented 9 years ago
First things first, what exactly is the problem? I see nothing abnormal from 
any of the above...

Original comment by samuel.a...@gmail.com on 29 Aug 2011 at 1:53

GoogleCodeExporter commented 9 years ago
Samuel,problem is how use ROI on Android, because any function (which I tried) 
working with CvRect ends with: 
08-29 19:41:17.574: ERROR/dalvikvm(1880): Could not find class 
'java.awt.Rectangle', referenced from method 
com.googlecode.javacv.cpp.opencv_core$IplImage.copyTo

If you could provide small sample code would be great!  

Original comment by du...@centrum.cz on 29 Aug 2011 at 5:53

GoogleCodeExporter commented 9 years ago
What is the relation between CvRect or cvSetImageROI() and IplImage.copyTo()?

Original comment by samuel.a...@gmail.com on 30 Aug 2011 at 1:01

GoogleCodeExporter commented 9 years ago
Yes, propably not related "error", but did you tried 
cvSetImageROI(IplImage,CvRect) on Android? Sorry if Im disturbing you, I 
apologize.

Jan Dupla

Original comment by du...@centrum.cz on 31 Aug 2011 at 3:11

GoogleCodeExporter commented 9 years ago
I have just tried these three lines in Android:
{{{
    IplImage frame = IplImage.create(640, 480, IPL_DEPTH_8U, 3);
    cvSetImageROI(frame, cvRect(0, 0, 100, 100));
    cvResetImageROI(frame);
}}}
And they produce nothing abnormal...

Original comment by samuel.a...@gmail.com on 4 Sep 2011 at 2:49

GoogleCodeExporter commented 9 years ago
I have the same issue and my proccesor is armv6. I created a new project and i 
follow the instructions that exist at comments etc. The applicattion runs (I 
see the red string "FacePreview-This side up") and the camera is working 
properly but in the debugger with Eclipse i see the ClassNotFoundException, 
detailMessage: java.awt.image.BufferedImage na d classnotFound 
java.awt.color.ColorSpace. I haven't change any part of the code from 
FacePreview. But as i said the app works and it throws these exceptions before 
any face recognition takes place, afterwards everything runs smoothly. I just 
wanted to mention  because it is very weird at least for me. Keep up with your 
excellent job.

Original comment by stergios...@gmail.com on 26 Sep 2011 at 3:04

GoogleCodeExporter commented 9 years ago
Also your APK crashes without any message

Original comment by stergios...@gmail.com on 26 Sep 2011 at 3:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The "classes not found" messages are only warnings, not errors.. They are 
"normal" since Android does not come with any AWT classes.

The sample APK binary contains only binaries for ARMv7, so it will crash with 
ARMv5 or your ARMv6, that's normal.

BTW, is there still anything unresolved, or can I mark this issue as "Done"?

Original comment by samuel.a...@gmail.com on 30 Sep 2011 at 1:40

GoogleCodeExporter commented 9 years ago
I think its resolved and can be closed.
Thanks for your help Samuel!

Original comment by rho...@quadbase.com on 2 Oct 2011 at 9:03

GoogleCodeExporter commented 9 years ago
Great!

Original comment by samuel.a...@gmail.com on 6 Oct 2011 at 12:40

GoogleCodeExporter commented 9 years ago
However irrelevant these "class not found" warnings are, I find them 
irritating, especially when looking through the log while looking for real 
errors. So please create a jar for android on your maven repository which does 
not include methods whose signature references BufferedImage and other AWT 
classes.

Original comment by nabil.st...@gmail.com on 13 Mar 2013 at 9:20

GoogleCodeExporter commented 9 years ago
@nabil AFAIK, passing the project through ProGuard would also take care of 
those 

Original comment by samuel.a...@gmail.com on 13 Mar 2013 at 9:23