Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

题目1:myCamera 相机封装类

跨平台(Windows / Ubuntu)的 C++ 相机封装,使用 OpenCV VideoCapture

目录结构

task1_myCamera/
├── CMakeLists.txt
├── include/
│   └── myCamera.hpp     # 类声明
├── src/
│   └── myCamera.cpp     # 类实现
└── io/
    └── example.cpp      # 示例程序

类设计

  • 公有成员仅三个:构造函数、析构函数、read 函数
  • 私有成员变量统一以 _ 结尾
  • 自适应:按平台自动选择相机后端(Windows: DSHOW/MSMF,Ubuntu: V4L2), 期望索引打不开时自动尝试其他索引

编译(Windows / Ubuntu 通用)

mkdir build && cd build
cmake ..          # Windows 需先设置 OpenCV_DIR,或 -DOpenCV_DIR=E:/OpenCV/opencv/build
cmake --build .
./example          # Windows 为 example.exe

示例运行

  • ESC 退出
  • s 保存当前帧为 myCamera_frame.jpg

About

题目1

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages