Ask Your Question

How to Capture Camera frames with hidden/Dummy Surfaceview in Android

asked 2013-01-22 18:20:28 -0500

himanshu jain gravatar image

Is there way i can create own NativeCameraView in Android Background Service and add this view to WindowManager in order to capture camera frames in Background. In Android we can create dummy SurfaceView and then adding it to WindowManager can create surface which in turn start video capture or camera preview but onPreviewFrame never gets called therefore i am wondering can we do similar thing using OpenCV since it has callback onCameraFrame.??

Any suggestion Appreciated

edit retag flag offensive close merge delete


Could you solve the problem at last? I have the same problem. Could you help me? Thanks

CGN gravatar imageCGN ( 2013-07-12 10:58:31 -0500 )edit

Hi CGN, could you solve the problem? And can you help me? Thanks

telopena gravatar imagetelopena ( 2013-07-15 14:12:08 -0500 )edit

Hi telopena. I could solve the problem. I call directly to NativeCameraView.connectCamera, with screen dimensions as parameters (you have to change connectCamera and disconnectCamera privacy). I also have to modify the CameraBridgeViewBase.calculateCameraFrameSize class, to avoid it crash because size is 0. For that I write: maxAllowedWidth=surfaceWidth; maxAllowedHeight=surfaceHeight;

That's all, and it works for me.

CGN gravatar imageCGN ( 2013-07-18 02:51:25 -0500 )edit

Hi CGN, Could you please discuss about your changes made to NativeCameraView and how are you using those changes made in the application ? Thanks a lot

Rishi gravatar imageRishi ( 2013-09-12 05:32:59 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-23 00:15:43 -0500

NativeCameraView uses OpenCV VideoCapture class for camera access. You can use it without any visible surface. NativeCameraView class is designed for using in activities and handle different view events, i.e. construction, destruction, change, etc. You need to write your own code that initialize camera and grab frames. You can use NativeCameraView.connectCamera, NativeCameraView.disconnectCamera, NativeCameraView.initCamera and methods as reference.

edit flag offensive delete link more


Thanks that is what i read yesterday and looking now !

himanshu jain gravatar imagehimanshu jain ( 2013-01-23 13:39:49 -0500 )edit

I have the same problem and i not understand very well. Your idea consists in creating a new class that has the same methods that NativeCameraView? Does it have extend CameraBridgeViewBase too? Thanks

telopena gravatar imagetelopena ( 2013-07-15 13:51:19 -0500 )edit

Yes, you need to implement your own class with camera initialization. CameraBridgeViewBase is inherited from View, so it is not suitable parent.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-07-24 03:25:33 -0500 )edit

As i got lots of truble with CameraBridgeViewBase because of the low fps: Is your method with NativeCameraView faster then the CameraBridgeViewBase? How many fps do you get with what resolution? Is it possible to get your source code?

Earymgn gravatar imageEarymgn ( 2013-12-17 08:12:21 -0500 )edit

NativeCameraView is inherited from CameraBridgeViewBase and implemented most of the platform specific functions. Unfortunately, I do not have any examples without CameraBridgeViewBase class.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-12-18 01:18:56 -0500 )edit

Question Tools

1 follower


Asked: 2013-01-22 18:20:28 -0500

Seen: 4,017 times

Last updated: Jan 23 '13