问题描述
我只需要知道如何开始这个实际上我需要打开Android本机相机使用opencv。
I just need to know about how can I start with this actually I need to open the Android native camera using opencv.
在哪里可以找到相关的文档或任何帮助材料?
我已经设置我的eclipse使用opencv示例项目!
Where can I find the related docs or any helping material?I have setup my eclipse working with the opencv sample projects!
推荐答案
看看发货opencv示例opencv / samples / android /,你应该能够找到几个好的例子。这里还有一个指向文档的链接,其中显示。
Have a look at the shipped opencv samples in opencv/samples/android/, there you should be able to find a few good examples. Here is also a link to the docs that shows how to open the camera. Don't forget to request the permissions to access the camera.
简短版本,请参阅完整详细信息的链接:
添加布局:
Short version, see the link for full details:Add a layout:
<org.opencv.android.JavaCameraView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:id="@+id/HelloOpenCvView"
opencv:show_fps="true"
opencv:camera_id="any" />
初始程序:
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
@Override
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
实现CVFrameListener2接口:
Implement CVFrameListener2 interface:
private CameraBridgeViewBase mOpenCvCameraView;
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.HelloOpenCvLayout);
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.HelloOpenCvView);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
}
@Override
public void onPause()
{
super.onPause();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
public void onDestroy() {
super.onDestroy();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
public void onCameraViewStarted(int width, int height) {
}
public void onCameraViewStopped() {
}
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
return inputFrame.rgba();
}
这篇关于使用OpenCV打开Android本机Camera的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!