Ask Your Question
0

How to fix the issue about cvCreateCameraCapture

asked 2018-12-10 19:20:36 -0600

JohnnyWang gravatar image

updated 2018-12-26 20:25:21 -0600

I have built opencv(with ffmpeg) for android arm64-v8a successfully, however, cvCreateCameraCapture return null. cvCreateFileCapture work well. I found we need to set the following item for support camera. -DWITH_V4L=1 -DHAVE_CAMV4L2=ON

Now, v4l have been built in opencv, however, the following interface in cap_libv4l.cpp can not open device successfully.

static void icvInitCapture_V4L() {
...
deviceHandle = open(deviceName, O_RDONLY);
...
}

That open function failed because of permission denied.

I think my android app don't have related permission. However, i add the following setting in AndroidManifest.xml.

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>

And opencv functions are called in a thread in my app. My app is a service for android.

How to fix the permission issue for my app?

Any idea?

Change my app to system app?

Update 2018/12/27.

I found that deviceName is /dev/video*. So I checked the permission of those video in path /dev as below,

1|gts4lltechn:/dev $ ls -l | grep video ls: ./event-log-tags: Permission denied

crw-rw---- 1 system camera 81, 0 2017-04-01 08:37 video0

crw-rw---- 1 system camera 81, 1 2017-04-01 08:37 video1

crw-rw---- 1 system camera 81, 2 2017-04-01 08:37 video2

crw-rw---- 1 system camera 81, 3 2017-04-01 08:37 video3

crw-rw---- 1 system camera 81, 32 2017-04-01 08:37 video32

crw-rw---- 1 system camera 81, 33 2017-04-01 08:37 video33

crw-rw---- 1 system camera 81, 4 2017-04-01 08:37 video4

crw-rw---- 1 system camera 81, 5 2017-04-01 08:37 video5

crw-rw---- 1 system camera 81, 6 2018-12-20 21:28 video6

And my app's permission is as below,

u0_a191 20375 995 4406488 82904 0 0 S xxx.xxx.xxx+

I don't have su permission, how to fix the issue?

edit retag flag offensive close merge delete

Comments

those c-api functions are no more supported / maintained. please try again using cv::VideoCapture for both

berak gravatar imageberak ( 2018-12-19 01:20:18 -0600 )edit

cv::VideoCapture is implented by those c-api functions, so those c-api functions still work. I do not want to modify source code for processing image, so i would like to use those c-api functions.

Thanks for your reply.

JohnnyWang gravatar imageJohnnyWang ( 2018-12-19 01:58:27 -0600 )edit
1

I would like to add all necessary dependency to my project. So what dependency is lost?so that videoio.h is not found.

JohnnyWang gravatar imageJohnnyWang ( 2018-12-19 02:15:38 -0600 )edit
1

Update latest status

JohnnyWang gravatar imageJohnnyWang ( 2018-12-19 04:44:38 -0600 )edit

btw:

cv::VideoCapture is implented by those c-api functions

not true.

berak gravatar imageberak ( 2018-12-26 02:53:00 -0600 )edit

Ohh, if i use cv::VideoCapture, the same issue may occur.

JohnnyWang gravatar imageJohnnyWang ( 2018-12-26 20:20:15 -0600 )edit

target platform have no su, and no root.

JohnnyWang gravatar imageJohnnyWang ( 2018-12-26 20:52:31 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-01-23 05:05:02 -0600

JohnnyWang gravatar image

I fix the issue by chmod 666 /dev/videoX

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-10 19:20:36 -0600

Seen: 1,083 times

Last updated: Jan 23 '19