I'm trying to move a very simple OpenCV application to android. The code tries to access the camera from a C++ .so library that is linked with the main app which is using C# and Xamarin which I doubt has anything to do with my issue. My C++ code simply tries to access the camera using cv::VideoCapture like so:
cv::VideoCapture cap(0); //default camera
if(!cap.isOpened())
{
LOGE("No camera detected on this system\n");
}
This however always fails despite me specifying permission in AndroidManifest.xml like so:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.XamarinARapp">
<uses-sdk android:minSdkVersion="15" />
<application android:label="XamarinARapp.Android">
</application>
<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"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
</manifest>
Has anyone been successful accessing the android camera with cv::VideoCapture in C++? Does Xamarin have anything to do with it?
but the app is being built for android 4.4
Your manifest SDK versions should look like this:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
Otherwise without the targetSdkVersion
set and running on a API 23+ device you will need to request runtime camera permissions.
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.