【发布时间】:2018-05-28 07:20:41
【问题描述】:
我在 android 4.4、5.1 上将这个示例与 ioctl 一起使用 https://github.com/theicfire/simplewebcam/blob/master/jni/ImageProc.c
我正在使用此界面手动控制对比度、增益、曝光、白电平等参数。 当我尝试将应用程序移至 android 7 时,fd 文件无法打开。
fd = open (dev_name, O_RDWR | O_NONBLOCK, 0);
有没有办法解决这个问题?
我已经检查过了,camera2.api 不允许控制我需要从相机获得的参数,并且本机代码因为这个错误而失败。
编辑: 更准确地说,我使用的是连接到平板电脑的 USB 摄像头,即使我使用 chmod 666 或 777 来设置权限,android 7 也不会让我得到设备 FD。有什么方法可以解决它或其他方法来控制曝光、对比度、增益、白色 lvl?
这是我在java部分添加的代码,canRead()部分代码失败
private void InitCameraDevice() throws Exception {
//set permissions to all /dev/video devices before checking them
General.RunAsRoot("chmod 666 /dev/video*");
NativeUtils.setLogName(General.getLogFileName());
File dir = new File("/dev");
File[] videoDevFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith("video");
}
});
boolean cameraFound = false;
for (File deviceFile : videoDevFiles) {
// Process file
if(deviceFile.canRead()) {
cameraFound = (NativeUtils.prepareCamera(deviceFile.getAbsolutePath(), frameWidth, frameHeight) != -1);
if (cameraFound)
break;
}
else
General.logd(STREAM_THREAD_TAG, "Insufficient permissions on [" +
deviceFile.getAbsolutePath() +"].");
}
if(!cameraFound)
throw new Exception("UVC Camera not found!");
}
感谢您的帮助
【问题讨论】:
-
更准确地说,我使用的是连接到平板电脑的 USB 摄像头,即使我使用 chmod 666 或 777 设置权限,android 7 也无法获取设备 FD。跨度>
标签: android camera java-native-interface native ioctl