简体   繁体   中英

How to use OpenCV methods in Android Camera Preview

I want to do some image processing by using Imgproc functions of OpenCV from an image captured by a camera preview.

The problem is that I already use a Camera.PreviewCallback to get images from the Android camera preview. But I saw that in OpenCV we need to use a different preview called CvCameraViewListener2.

So do I have to redo all my stuff from my custom preview to the OpenCV one? Could I just use OpenCV functions without CvCameraViewListener2? Or do CvCameraViewListener2 and Camera.PreviewCallback work the same and It's simple to switch from one to another?

What I already use:

public class MyClass implements Camera.PreviewCallback

In OpenCV:

public class MyClass implements CvCameraViewListener2 {

After some more research, thanks to this post: Unable to use both cameras of Evo 4G using OpenCV4Android I can say that the answer is yes. We can use OpenCV methods without having to use CvCameraViewListener2.

I just initialized the OpenCV lib where I want to use my image processing (explained here step 10: http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html ). Then I can use OpenCV methods.

And I can get the matrix to use with OpenCV for example with:

img = new Mat(height, width, CvType.CV_8UC1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM