Files
mzxwww 19ac43da6f Add pose_test tool and harden solvePose; expose camera controls
- pose_test: verify the geometry chain (4 corners -> distance/yaw/pitch)
  before any detector exists; modes: camera + mouse clicks, --image,
  --corners (headless), --selftest (synthetic round-trip, no camera needed)
- solvePose: undistort corners first, then solvePnPGeneric(IPPE) and pick
  the best candidate; reject solutions behind the camera (z<=0) or with
  reprojection error > 8px
  - fixes IPPE + distortion + in-plane rotation returning garbage
  - 4 coplanar points: cyclic/mirrored orderings give the same quad and
    the same pose (harmless); crossing orderings blow up reprojection
    and are rejected
- camera_set: implement setAeState/setExposureTime/setAnalogGain(+-Times)/
  setWbMode/setFrameSpeed; configs/camera_runtime.yaml drives them
- selftest passes all 6 synthetic cases; verified on 6 real photos
  (chessboard outer rect 180x120mm): distance 0.44-0.69m, reproj <2.5px
2026-09-16 21:08:03 +08:00

38 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef CAMERA_SET_HPP
#define CAMERA_SET_HPP
#include "CameraDefine.h" // 类型定义
#include <opencv2/opencv.hpp>
class CameraGrabber
{
public:
CameraGrabber(); // 构造函数声明
~CameraGrabber(); // 析构函数声明
bool initializeCamera(); // 初始化相机
bool startCamera(); // 启动相机
bool stopCamera(); // 停止相机
// ---- 参数设置:在 initializeCamera 之后、startCamera 之前调用 ----
bool setAeState(bool aeOn); // 曝光模式:true=自动, false=手动(比赛必须手动)
bool setExposureTime(double exposureUs); // 曝光时间(微秒 us)
bool setAnalogGainRaw(int gainRaw); // 模拟增益(SDK 原始整数,范围见 capability.sExposeDesc)
bool setAnalogGainTimes(double gainTimes); // 模拟增益(倍率,内部按 fAnalogGainStep 换算成原始值)
bool setWbMode(bool autoWb); // 白平衡:true=自动, false=手动
bool setFrameSpeed(int speed); // 帧率档位:0=低速 1=正常 2=高速
bool getFrame(cv::Mat &frame); // 获取一帧图像
private:
CameraHandle hCamera = -1; // 相机句柄
tSdkCameraCapbility capability; // 相机能力描述
unsigned char *pRgbBuffer = nullptr; // 图像处理缓冲区
int channel = 3; // 通道数:1 灰度,3 彩色
bool isInitialized = false; // 是否已初始化
bool isPlaying = false; // 是否已启动取流
};
#endif