billmccord / OpenCV-Android

A project for porting and optimizing OpenCV for Google's Android OS
http://billmccord.github.com/OpenCV-Android/
444 stars 159 forks source link

How to manage an image with the library? #4

Open jabrena opened 14 years ago

jabrena commented 14 years ago

Hi,

I tested all examples but they use a remote camera. I would like to process an image stored in the phone or in the application and I would like to use the internal camera to process the frames. How to do it?

Cheers

pflammertsma commented 14 years ago

I don't quite understand what you mean with "using the internal camera to process the frames", but here is a snippet to modify SocketCamera.java:69-79 to use a image file as a stream instead of reading from a socket:

InputStream in = new BufferedInputStream(new FileInputStream(
        "/data/data/org.siprop.opencv/files/example.jpg"));
bitmap = BitmapFactory.decodeStream(in);

I would encourage you to simply read the stream once as opposed to constantly having the thread read the file over and over, but this is only to give you an idea of how it could be done.

Of course you will have to push example.jpg to the correct path onto the device in order for this to work.