树莓派上运行OpenCV程序的嵌入式计算机视觉实践
1. 树莓派上的相机捕获代码
在树莓派上进行相机捕获,我们可以使用以下代码来启动捕获过程:
if (mmal_port_parameter_set_boolean(camera_video_port, MMAL_PARAMETER_CAPTURE, 1) != MMAL_SUCCESS) {
printf("%s: Failed to start capture\n", __func__);
}
cout << "Capture started" << endl;
此代码尝试启动相机捕获,如果启动失败,会输出相应的错误信息。
1.1 CMakeLists.txt配置
为了编译包含相机捕获功能的程序,我们需要配置 CMakeLists.txt
文件,以下是具体的配置内容:
cmake_minimum_required(VERSION 2.8)
project(PiCapture)
SET(COMPILE_DEFINITIONS -Werror)
find_package( OpenCV REQUIRED )
include_directories(/opt/vc/include)
include_directories(/opt/vc/include/interface/vcos/pthreads)
include_directories(/opt/vc/inclu