我已经为此工作了好几天了。我有一个基于OpenCV / JavaCameraView的项目我试图与我用来控制相机对光的敏感度的Android android.hardware.camera2.CaptureRequest
对象集成。
CameraBridgeViewBase.CvCameraViewListener2/JavaCameraView
项目有效(我可以在屏幕上看到图像),CaptureRequest
项目也可以工作(也见到这一点),但是将这两种技术结合在一个项目中证明了大问题。
有没有人让这两种技术一起工作?我的目标是让摄像头处于CaptureRequest(有限的SENSOR_SENSITIVITY + SENSOR_EXPOSURE_TIME)的控制之下,但是屏幕上显示的是通过OpenCV共享库过滤的流式图像。
要控制相机,我可以使用以下内容:
mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
// The camera is already closed
if (null == mCameraDevice) {
return;
}
long exposureTime = 66259688,frameDuration = 1000;
int sensitivity = 1512;
mCaptureSession = cameraCaptureSession;
try {
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
setAutoFlash(mPreviewRequestBuilder);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
mPreviewRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, Long.valueOf(exposureTime));
mPreviewRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(sensitivity));
mPreviewRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, Long.valueOf(frameDuration));
mPreviewRequest = mPreviewRequestBuilder.build();
mCaptureSession.setRepeatingRequest(mPreviewRequest,
mCaptureCallback, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
要过滤图像流,我可以使用以下内容:
public class MyCoolScanner extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2 {
...
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
OpenCVNative.myCoolLibrary(mRgba.getNativeObjAddr(),mGray.getNativeObjAddr());
return mGray;
}
提前致谢。
答案 0 :(得分:4)
请查看Android的开放式简历的实施情况,它可能对您有帮助。
Camera calibration With OpenCV
相机校准 - opencv 2.3.1 android
https://groups.google.com/forum/#!topic/android-opencv/xXtUvdA1E4M
https://fossies.org/dox/opencv-3.2.0/CameraCalibrationActivity_8java_source.html
答案 1 :(得分:0)
我相信OpenCV本身不支持与android.camera2一起使用
答案 2 :(得分:0)
答案是否定的,OpenCV不能与android.camera2一起工作,不是没有某种复杂的工作。