Samples not working on Motorola Droid

1,834 views
Skip to first unread message

Matt

unread,
Jan 5, 2012, 5:52:07 PM1/5/12
to android...@googlegroups.com
I cannot get samples with the camera to work on my Motorola Droid (the screen is just black).  I have found this ticket:


which gives a description of what seems to be the cause of the problem:

Initialization of camera is incomplete in native camera implementation and samples.

1) missed call to setPreviewDisplay
2) error handling is incomplete

I have tried to do mCamera.setPreviewDisplay(this) but the native VideoCapture object does not seem to have a setPreviewDisplay method.  I also tried to cast the VideoCapture object 'mCamera' to the type 'android.hardware.Camera' to no avail.

Anyone know what I'm missing?  Am I going about this the wrong way?  Any help would be appreciated.. I'm pretty noobish with this...

Shervin Emami

unread,
Jan 7, 2012, 6:44:51 PM1/7/12
to android-opencv
What version of Android do you have? And are you using the Android
Binary package, or did you build OpenCV yourself using the latest
source code on SVN trunk? Because the native camera is only on some
specific versions of Android on some specific devices. Unfortunately,
maybe you will need to upgrade or degrade your version of Android for
OpenCV to support camera.

Cheers,
Shervin Emami.

Andrey Kamaev

unread,
Jan 8, 2012, 5:20:14 AM1/8/12
to android...@googlegroups.com
It is a known problem, that OpenCV native camera does not work on Motorola devices. The problem is vendor-specific and can not be fixed with system upgrade/downgrade. For now, Java camera is the only option for Motorla.
Probably this camera issue will be fixed in the upcoming OpenCV release.

/Andrey
Message has been deleted

Matt

unread,
Jan 17, 2012, 4:04:58 PM1/17/12
to android...@googlegroups.com
Android 2.2.2 Froyo - Motorola Droid.  I am using the pre-build binaries.. just going through the tutorials.

Matt

unread,
Jan 17, 2012, 4:11:03 PM1/17/12
to android...@googlegroups.com
Do you know if there is a way to use "java camera" and still use the OpenCV functions?  I have been able to get pixel arrays from onPreviewFrame(), but I'm looking for a way to connect the dots.  Unfortunately, my only test device is my own phone (Motorola Droid);  If I can at least connect the dots for now as a work-around (to work out the OpenCV code) it would be awesome!

android-facedetection

unread,
Mar 27, 2012, 10:26:06 PM3/27/12
to android...@googlegroups.com
i somehow have the same problem with yours.
it did work on nexus one and emulator, but not on Droid nor Nexus s, with different error messages.
Did you figure out how to deal with it?

Geomod

unread,
Mar 29, 2012, 2:41:17 PM3/29/12
to android...@googlegroups.com

Guy Lifchitz

unread,
May 29, 2012, 12:38:39 AM5/29/12
to android...@googlegroups.com
Tutorial 1 - Basic 1 does this exactly. it uses the Java camera and OpenCV native code to process the images.


בתאריך יום שלישי, 17 בינואר 2012 23:11:03 UTC+2, מאת Matt:

Guy Lifchitz

unread,
May 29, 2012, 12:43:27 AM5/29/12
to android...@googlegroups.com
I develop on HTC One S with Android 4.0.4 platform. The initialization of the native camera crashes with memory corruption exception. I use the prebuilt binaries.
Building the binaries from source should fix this problem of is there a problem in the implementation itself.
Can someone explain how to build the binaries from source for the given device? I assume the ndk build-tool is required?

Thanks,
 Guy.

בתאריך יום שלישי, 29 במאי 2012 07:38:39 UTC+3, מאת Guy Lifchitz:

Artem Storozhuk

unread,
May 29, 2012, 7:17:39 AM5/29/12
to android...@googlegroups.com
Hi Guy Lifchitz,

If you want to build advanced (not basic) OpenCV project then, yes, you have to add NDK builder to your project settings.
In project settings (Eclipse) you can set android API level. But I don't know if it's possible to build it for HTC.

Вівторок, 29 травня 2012 р. 07:43:27 UTC+3 користувач Guy Lifchitz написав:

Guy Lifchitz

unread,
May 29, 2012, 7:48:04 AM5/29/12
to android...@googlegroups.com
OK,
 I downloaded and compiled the OpenCV from source following the wiki manuscript. All seemed to work...
Then I tried to import the projects into eclipse.

The samples under OpenCV/samples/android/... has no project.properties files and no Build.xml files so I couldn't import them into eclipse.
The project OpenCV/modules/java/android is missing all configuration files...

I also didn't find and .jar file which I understand should be the library created by the OpenCV-2.4.0 java project and referenced by the other projects.

Any suggestions?
Thanks,
 Guy.


בתאריך יום שלישי, 29 במאי 2012 14:17:39 UTC+3, מאת Artem Storozhuk:

Andrey Pavlenko

unread,
May 29, 2012, 8:27:17 AM5/29/12
to android...@googlegroups.com
Preparing the package from the build folder require additional steps ('make install/strip', copying samples, 'android update project ...', etc).
But I see no reason why you're doing this: the native camera libs are prebuilt even in OpenCV sources (opencv/3rdparty/lib/armeabi-v7a/...), they are updated manually since this is tricky procedure.
Can you share a logcat describing the crash you mentioned above?

Guy Lifchitz

unread,
May 29, 2012, 8:36:37 AM5/29/12
to android...@googlegroups.com
The log file is attached.

I understand the inefficiency of building the code/projects from source, but to satisfy curiousity and to learn more, is there any cook-book of the procedure required?

בתאריך יום שלישי, 29 במאי 2012 15:27:17 UTC+3, מאת Andrey Pavlenko:
log.txt

Andrey Pavlenko

unread,
May 29, 2012, 10:08:31 AM5/29/12
to android...@googlegroups.com
We'll look if we need to fix native camera for android 4.0.4. (BTW, you can try your luck building the camera wrapper yourself with the instruction).
Also we'll consider the possibility to publish packaging steps on wiki.

Guy Lifchitz

unread,
May 29, 2012, 10:35:23 AM5/29/12
to android...@googlegroups.com
Sure, thanks.
I'll try to follow the instructions and if by some accident I'll be usefull, I'll be happy to share the knowledge. :)

בתאריך יום שלישי, 29 במאי 2012 17:08:31 UTC+3, מאת Andrey Pavlenko:

Alexander Smorkalov

unread,
May 30, 2012, 3:22:16 AM5/30/12
to android...@googlegroups.com
Hello, Guy!

We cannot reproduce problem on our device (Samsung Nexus S) with Android 4.0.4. All works fine. The problem may be cased by vendor specific code. We'll try to reproduce problem if appropriate device will be available.

Guy Lifchitz

unread,
May 30, 2012, 4:48:17 AM5/30/12
to android...@googlegroups.com
OK, Thanks.

I'm working on HTC One S.

In the meanwhile I'm working with the Java camera, but eventually I'd like to build the sources with optimizations and use the native camera.

Following the instruction of how to build the sources on windows, does not include exaplanation on how to install and build the java part of the code (the wrappers of the whole opencv lib, not only the camera).

I can't run make install since I'm not on UNIX/Linux.

I also saw that in the file "build.cmd" which is used by the cmake, the is a line "IF EXIST .\jni\nul (SET BUILD_JAVA_PART=1) ELSE (SET BUILD_JAVA_PART=0)"
which seems to later execute java part compilation, but the folder .\jni\nul does not exists. Could it be that the trunk from SVN repository http://code.opencv.org/svn/opencv/trunk is not updated? or maybe the script should have create that folder but for some reason it doesn't?

Thanks,
 Guy.
Reply all
Reply to author
Forward
0 new messages