diff --git a/README.md b/README.md index c8467d39e45fa74b13b87cc42442542293316598..981a14d620f246ad40eebcae050d89e4fb2579d0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,14 @@ sudo cp $(pwd)/hnurm_camera/lib/linux/* /usr/lib/ #下载nomachine到/usr目录并解压安装 wget -P ~/Downloads/ https://download.nomachine.com/download/8.11/Linux/nomachine_8.11.3_4_amd64.deb sudo dpkg --install ~/Downloads/nomachine*amd64.deb + +#其他依赖项 +sudo apt -y install ros-humble-sophus +sudo apt -y install ros-humble-libg2o +sudo apt -y install ros-humble-camera-info-manager +sudo apt -y install ros-camera-calibration +sudo apt -y install ros-humble-camera-calibration +rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y ``` 4. 安装ROS2 humble @@ -84,7 +92,7 @@ echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc 关于组局域网连接nomachine的方法原理的进一步阐释,可以参考[这里](https://blog.csdn.net/qq_50791664/article/details/135578810)。 -6. 创建路径`/home/rm/hnuvision/src`,将本项目目录下文件复制或剪切到这个路径,然后使用`colcon build`编译,如果出现依赖问题,再补充安装即可。 +6. 创建路径`/home/rm/hnuvision/src`,将本项目目录下所有文件(包括隐藏文件)复制或剪切到这个路径,然后使用`colcon build`编译,编译失败多半是依赖没装好,回到之前再补充安装即可。 7. 设置自启动 在启动应用程序中添加 @@ -104,35 +112,37 @@ sudo usermod -aG dialout rm # 概览 ## 功能包 -本框架基于ROS平台设计了5个功能包,如下: +本框架基于ROS平台设计了6个功能包,如下: 1. hnurm_uart:负责与下位机的通讯 -2. hnurm_camera:调用相机,感知外界信息 +2. hnurm_camera:调用相机 3. hnurm_detect:检测装甲 4. hnurm_armor:预测装甲的运动并进行补偿 -5. hnurm_bringup:启动其他全部节点并适配双云台,对于单云台,默认相机为`right` +5. hnurm_bringup:启动其他全部节点并适配双云台 +6. hnurm_interfaces:存储所有消息类型 ## 自瞄流程 -1. 从相机获取图像,图像接受线程获取图像。 -2. 图像处理线程开始进行识别和预测。识别过程不需要接受串口数据,预测需要。识别过程首先计算目标的像素坐标系下的坐标,然后通过PnP算法计算出目标与的相对位置坐标,然后通过预测算法预测出目标对于相机的相对坐标位置、空间位姿、移动速度、半径。 -3. 将预测的俯仰角和偏航角发送到串口 +1. 启动`hnurm_uart`节点,可以自动识别串口名字并尝试读写数据。 +2. 启动`hnurm_camera`节点,可以根据参数文件中的相机id打开相机获取图像。 +3. 启动`hnurm_detect`节点,可以对相机图像进行装甲板的提取。 +4. 启动`hnurm_armor`节点,可以装甲板进行预测和弹道的计算,并将计算结果发送给`hnurm_uart`。 +5. 启动`hnurm_bringup`功能包中的`compose_node`节点,可以一次性启动如上所有节点。对于哨兵这样的双云台机器人来说,需要 # 标定脚本执行方法 -1. 准备好标定板,根据标定板的方格数量、方格面积、方格类型修改`hnurm_camera/CameraCalibration/default.xml`文件。 -```xml - -7 -7 - -20 -"CIRCLES_GRID" +1. 准备好标定板,根据标定板的方格数量、方格面积、方格类型修改`hnurm_camera/launch/calib.launch.py`文件。 +```python + # execute `ros2 run camera_calibration cameracalibrator --size --square + camera_calibration_node = ExecuteProcess( + + cmd=['ros2', 'run', 'camera_calibration', 'cameracalibrator', '--size', '11x8', '--square', '0.03', + '--no-service-check' + ], + output='screen' + ) ``` -2. 编译项目`CameraCalibration`并执行,clion中需要指定`Program arguments`为`../default.xml`。在程序执行过程中,按下`G`键开始标定,手持标定板,在图像四个角周围移动标定板。 -3. 完成拍摄后,程序会打印出loss(误差值)并自动保存文件,一般认为loss低于0.2是可以接受的。 -4. 最后检查一下图像的四周是否存在肉眼可见的畸变,然后就可以退出程序了。 +2. 运行此文件,移动标定板进行标定。标定距离不要超过2m;标定时,标定板俯仰角上下15°左右,偏航角不限;图像边缘也要照顾到。 +3. 标定文件存储在`/tmp`下,解压缩并打开文件,把相机内参矩阵手动复制到`hnurm_aromor/data`下任意一个标定文件下,并顺便依据相机id修改标定文件名字。 -# 路径问题 -在运行程序前,修改相机id(位于`vision.right.launch.py`)和神经网络模型(位于`hnurm_detect/params/default.xml`)的路径。 # 串口问题 ## 解包顺序 @@ -145,8 +155,8 @@ y对应roll,z对应yaw,x对应pitch; # 装甲板识别问题 ## 灯条识别正常,但是没有构成装甲板 -查看config.yaml中ignore_classes参数,可能因为是识别成`negative`被筛除了 -```shell +- 查看`hnurm_detect/params/default.yaml`中ignore_classes参数,可能因为是识别成`negative`被筛除了 +```yaml ignore_classes: - "2" # - negative @@ -154,18 +164,11 @@ y对应roll,z对应yaw,x对应pitch; # - base ``` -**注意,yaml的格式相当严格,如下格式的yaml无法运行:** -```shell - ignore_classes: -# - negative -# - outpost -# - base - - "2" -``` +- `hnurm_detect/src/detector.cpp`中的`isArmor`函数把它筛去了,调整参数试试。 ## 解决数字识别网络的误识别问题: 1. 在适当的距离重新对焦并标定 -2. 调整光圈到最大,调整CameraParam.yaml的曝光时间和增益 +2. 调整光圈,调整CameraParam.yaml的曝光时间和增益 3. 调整二值化阈值 @@ -183,7 +186,7 @@ static constexpr float LARGE_ARMOR_WIDTH = 225; static constexpr float LARGE_ARMOR_HEIGHT = 55; ``` -2. 检查相机成像是否清晰(即焦距是否合适),光圈是否调整到最大。**每次调整完焦距或者光圈后都需要重新标定**。 +2. 检查相机成像是否清晰(即焦距是否合适),光圈是否调整合适。**每次调整完焦距或者光圈后都需要重新标定**。 3. 检查`hnurm_armor/params/default.yaml`中的相机偏移参数是否正确。应该设置为相机光心在惯性传感器坐标系下的坐标:相机镜头方向为y轴正方向,天空为z轴正方向。 ```yaml @@ -207,7 +210,7 @@ static constexpr float LARGE_ARMOR_HEIGHT = 55; # 预测问题 ## 查看channel_delay是否设置正确 -channel_delay这个时间定义为电控受到开火指令后转动拨盘的延迟,这个参数会严重的影响预测的准度。对于步兵而言,比赛时几乎都是连发,可以设置为0.01;对于英雄而言,就需要去询问电控组的同学。此外,调整方式如下: +channel_delay这个时间定义为电控受到开火指令后转动拨盘的延迟,这个参数会严重的影响预测的准度。对于步兵而言,比赛时几乎都是连发,可以设置为0.05;对于英雄而言,就需要去询问电控组的同学。此外,调整方式如下: 1. 当弹道晚于目标,那么channel_delay过小,程序认为子弹几乎可以立即发射,但现实是子弹发射延迟更大,所以弹道慢了。应该增大channel_delay 2. 弹道早于目标,应该减小channel_delay @@ -215,7 +218,7 @@ channel_delay这个时间定义为电控受到开火指令后转动拨盘的延 预测的角速度是能否击中目标的关键,这通常与曝光时间和增益有所关联。曝光时间增加可以获得更多颜色信息,但会降低帧率。 # 完整调试流程 -1. 光圈最大,对焦并标定(四个角不要有畸变),对应地方修改相机id +1. 调整光圈、焦距,标定(四个角不要有畸变),对应地方修改相机id和参数(宽高、像素格式) 2. 根据比赛场地调整曝光和增益,主要是曝光 3. 调整装甲板识别参数、相机光心与惯性传感器的相对位置、摩擦轮中心与惯性传感器的相对位置 4. 静止击打装甲板确保可以正中,主要调整bias_yaw。bias_pitch默认就是0,几乎不用调整,如果pitch不准,优先去调整摩擦系数,实在不行的话再去调bias_pitch @@ -232,3 +235,5 @@ sudo apt install ros-$ROS_DISTRO-foxglove-bridge $ ros2 launch foxglove_bridge foxglove_bridge_launch.xml ``` 3. 打开应用即可 + + diff --git a/bringup.sh b/bringup.sh index 0b56eba19afafd6b0e146e3d342483c9baee1d4e..341bb492d2756d664cea7f7f51c6bf322a39d43c 100644 --- a/bringup.sh +++ b/bringup.sh @@ -1,9 +1,16 @@ #!/bin/bash +#while [ true ]; do +# if ls /dev/ttyACM* 1> /dev/null 2>&1 || ls /dev/ttyUSB* 1> /dev/null 2>&1 ;then +# break +# else +# echo "waiting for the uart..." +# fi +#done + cmds=( - "ros2 launch hnurm_bringup hnurm_bringup.launch.py" - "ros2 launch hnurm_bringup vision.right.launch.py" + "ros2 launch hnurm_bringup compose.launch.py" ) for cmd in "${cmds[@]}" do diff --git a/hnurm_armor/CMakeLists.txt b/hnurm_armor/CMakeLists.txt index a7bf102113692dbb5d2fc7d8353cf932cf4fe8ef..b759e122fa79f2461b9249397ac33511a99c2e3c 100644 --- a/hnurm_armor/CMakeLists.txt +++ b/hnurm_armor/CMakeLists.txt @@ -3,84 +3,23 @@ project(hnurm_armor) set(CMAKE_CXX_STANDARD 17) -find_package(rosidl_default_generators REQUIRED) -find_package(ament_cmake REQUIRED) -find_package(rclcpp REQUIRED) -find_package(cv_bridge REQUIRED) -find_package(sensor_msgs REQUIRED) -find_package(angles REQUIRED) +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() -find_package(tf2 REQUIRED) -find_package(tf2_ros REQUIRED) -find_package(tf2_eigen REQUIRED) -find_package(tf2_geometry_msgs REQUIRED) - -find_package(visualization_msgs REQUIRED) - -find_package(Eigen3 REQUIRED) -find_package(OpenCV REQUIRED) -find_package(Sophus REQUIRED) -find_package(g2o REQUIRED) - -find_package(hnurm_uart REQUIRED) -find_package(hnurm_detect REQUIRED) - -set(dependencies - rclcpp - Eigen3 - OpenCV - cv_bridge - sensor_msgs - angles - hnurm_uart - hnurm_detect - visualization_msgs - tf2 - tf2_ros - tf2_eigen - tf2_geometry_msgs -) - -rosidl_generate_interfaces(${PROJECT_NAME} - msg/Target.msg - msg/TrackerInfo.msg - DEPENDENCIES std_msgs geometry_msgs sensor_msgs -) -rosidl_get_typesupport_target(cpp_typesupport_target - ${PROJECT_NAME} rosidl_typesupport_cpp) - -add_library(${PROJECT_NAME}_lib SHARED - src/extended_kalman_filter.cpp src/Processor.cpp src/tracker.cpp +ament_auto_add_library(hnurm_armor + src/armor_node.cpp src/Compensator.cpp -) -target_include_directories(${PROJECT_NAME}_lib PUBLIC - $ - $ -) -ament_target_dependencies(${PROJECT_NAME}_lib ${dependencies}) -target_link_libraries(${PROJECT_NAME}_lib - Eigen3::Eigen - Sophus::Sophus - g2o::core - ${cpp_typesupport_target} + src/extended_kalman_filter.cpp + src/Processor.cpp + src/tracker.cpp ) -add_executable(${PROJECT_NAME}_node src/armor_node.cpp src/main.cpp src/solvePnPBA.cpp) -target_include_directories(${PROJECT_NAME}_node PUBLIC - $ - $) -ament_target_dependencies(${PROJECT_NAME}_node ${dependencies}) -target_link_libraries(${PROJECT_NAME}_node ${PROJECT_NAME}_lib ${cpp_typesupport_target}) +ament_auto_add_executable(hnurm_armor_node src/main.cpp) +target_link_libraries(hnurm_armor_node hnurm_armor) -install(TARGETS ${PROJECT_NAME}_lib - DESTINATION lib -) -install(TARGETS ${PROJECT_NAME}_node - DESTINATION lib/${PROJECT_NAME} +ament_auto_package( + INSTALL_TO_SHARE + launch + params + data ) -install(DIRECTORY launch params data - DESTINATION share/${PROJECT_NAME} -) - - -ament_package() diff --git a/hnurm_armor/data/2BDF67015843.yaml b/hnurm_armor/data/2BDF67015843.yaml old mode 100644 new mode 100755 index a05533e79a83736d2c60d8783c3cd8b6fcd60086..6cd1dc1330338f65dda9a3dbff97bc841d6cba54 --- a/hnurm_armor/data/2BDF67015843.yaml +++ b/hnurm_armor/data/2BDF67015843.yaml @@ -1,6 +1,6 @@ %YAML:1.0 --- -calibration_time: "Tue 26 Mar 2024 10:15:41 PM CST" +calibration_time: "2024年04月10日 星期三 05时33分29秒" # flags: +fix_aspectRatio +fix_principal_point +zero_tangent_dist +fix_k4 +fix_k5 flags: 6158 fisheye_model: 0 @@ -8,11 +8,11 @@ camera_matrix: !!opencv-matrix rows: 3 cols: 3 dt: d - data: [ 8.6285852023350242e+02, 0., 6.3950000000000000e+02, 0., - 8.6285852023350242e+02, 3.5950000000000000e+02, 0., 0., 1. ] + data: [ 8.6204018260781015e+02, 0., 6.3950000000000000e+02, 0., + 8.6204018260781015e+02, 3.5950000000000000e+02, 0., 0., 1. ] distortion_coefficients: !!opencv-matrix rows: 5 cols: 1 dt: d - data: [ -9.9345144087277501e-02, 1.2013852036217572e-01, 0., 0., - -4.4704145076911242e-02 ] + data: [ -9.7539644997920810e-02, 1.0768468716235712e-01, 0., 0., + -2.7325839492794737e-02 ] diff --git a/hnurm_armor/include/hnurm_armor/Compensator.h b/hnurm_armor/include/hnurm_armor/Compensator.h index 5b0d5ca271507ff5dacfa97ce4456d6d0dd0aec8..8304cd463943fb7d08b0c07b16c18eb2ae99ace9 100755 --- a/hnurm_armor/include/hnurm_armor/Compensator.h +++ b/hnurm_armor/include/hnurm_armor/Compensator.h @@ -2,8 +2,10 @@ #define COMPENSATOR_H #include "hnurm_armor/DataType.hpp" -#include -#include + +#include +#include + #include #include #include @@ -11,38 +13,63 @@ namespace hnurm { -class Compensator -{ -private: - // 默认参数 - float gravity_ = 9.8; - float friction_coeff_ = 0.02; - float bullet_speed_bias_ = -0.5; - float imutofrt_y = 0.0; - float imutofrt_z = 0.0; - TargetInfo t_info; - float fx, fy, fz,fx_center,fy_center; - float pout, yout; - float tmp_fly_time; - float bullet_speed_; - float channel_delay_; - void PredictPose(ArmorsNum &armors_num); - - void CompensatePitch(); - [[nodiscard]] double diff_eq(double v) const; - double integrate_euler(double v0, double t); -public: - explicit Compensator(rclcpp::Node::SharedPtr node); - - float CalcFinalAngle( - TargetInfo &target_msg, hnurm_uart::msg::VisionRecvData &recv_data, hnurm_uart::msg::VisionSendData &send_data, ArmorsNum &num - ); - static bool cmp(const cv::Point3f &a, const cv::Point3f &b); - float yaw_bias_ = 0.0; - float pitch_bias_ = 0.0; -private: - rclcpp::Node::SharedPtr node_; -}; + class Compensator + { + private: + // 默认参数 + float gravity_ = 9.8; + float friction_coeff_ = 0.02; + float bullet_speed_bias_ = -0.5; + float imutofrt_y = 0.0; + float imutofrt_z = 0.0; + TargetInfo t_info; + float fx, fy, fz, fx_center, fy_center, fv, yaw_difference; + float pout, yout; + float tmp_fly_time; + float bullet_speed_; + float channel_delay_; + std::vector px; + std::vector py; + std::vector pz; + std::vector pv; + + void PredictPose(ArmorsNum &armors_num); + + void PredictPosition(); + + void CompensatePitch(); + + float calculateAverage(const std::vector &vec); + + void Averagedistance(std::vector &p, float value); + + [[nodiscard]] double diff_eq(double v) const; + + double integrate_euler(double v0, double t); + + public: + explicit Compensator(rclcpp::Node::SharedPtr node); + + float CalcFinalAngle( + TargetInfo &target_msg, + hnurm_interfaces::msg::VisionRecvData &recv_data, + hnurm_interfaces::msg::VisionSendData &send_data, + ArmorsNum &num + ); + + struct predict_armor + { + cv::Point3f position; + float yaw; + }; + + static bool cmp(const predict_armor &a, const predict_armor &b); + + float yaw_bias_ = 0.0; + float pitch_bias_ = 0.0; + private: + rclcpp::Node::SharedPtr node_; + }; } // namespace hnurm #endif // COMPENSATOR_H \ No newline at end of file diff --git a/hnurm_armor/include/hnurm_armor/DataBuffer.hpp b/hnurm_armor/include/hnurm_armor/DataBuffer.hpp deleted file mode 100755 index 1869e042ebf87a7f054503a846f63874959e82cf..0000000000000000000000000000000000000000 --- a/hnurm_armor/include/hnurm_armor/DataBuffer.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* kiko@idiospace.com 2020.01.20 */ - -#ifndef DataBuffer_HPP -#define DataBuffer_HPP - -#include -#include -#include -#include -#include -#include - -// #include "easylogging++.h" - -using namespace std::chrono_literals; - -namespace hnurm -{ -template -class DataBuffer -{ -public: - DataBuffer() = default; - - ~DataBuffer() = default; - - bool Get(DataType &data); - - bool Update(const DataType &data); - -private: - DataType data_buf; - std::timed_mutex mtx; - bool updated_flag = false; -}; // class DataBuffer - -template -bool DataBuffer::Get(DataType &data) -{ - if(mtx.try_lock_for(2ms)) - { - if(!updated_flag) - { - mtx.unlock(); - return false; - } - // LOG(WARNING) << "Success to lock in GET, UPDATED"; - data = data_buf; - updated_flag = false; - mtx.unlock(); - return true; - } - // LOG(WARNING) << "Failed to lock in GET"; - return false; -} - -template -bool DataBuffer::Update(const DataType &data) -{ - if(mtx.try_lock_for(2ms)) - { - // LOG(WARNING) << "Success to lock in UPDATE"; - data_buf = data; - updated_flag = true; - mtx.unlock(); - return true; - } - // LOG(WARNING) << "Failed to lock in UPDATE"; - return false; -} -} // namespace hnurm - -#endif // DataBuffer_HPP diff --git a/hnurm_armor/include/hnurm_armor/DataType.hpp b/hnurm_armor/include/hnurm_armor/DataType.hpp old mode 100755 new mode 100644 index d7cd3643baba8a3e04306bba3443649403885ced..35a24da35fa66b078114f9caddd0b3ce6cb3a210 --- a/hnurm_armor/include/hnurm_armor/DataType.hpp +++ b/hnurm_armor/include/hnurm_armor/DataType.hpp @@ -157,7 +157,8 @@ enum class ArmorsNum { NORMAL_4 = 4, BALANCE_2 = 2, - OUTPOST_3 = 3 + OUTPOST_3 = 3, + BASE_1 = 1 }; } // namespace hnurm diff --git a/hnurm_armor/include/hnurm_armor/Processor.h b/hnurm_armor/include/hnurm_armor/Processor.h index 47c217d238692f7383169d5a17031a5fd88a2bbe..32f9681ef523b9357465c58e908f7805302183bd 100755 --- a/hnurm_armor/include/hnurm_armor/Processor.h +++ b/hnurm_armor/include/hnurm_armor/Processor.h @@ -5,8 +5,9 @@ #include "hnurm_armor/TSolver.hpp" #include "hnurm_armor/armor.hpp" #include "hnurm_armor/tracker.hpp" +#include + #include -#include #include #include @@ -39,7 +40,7 @@ public: */ // void ProcessArmor(std::vector &armors_msg, VisionRecvData &recv_data, TargetInfo &target_msg); void - ProcessArmor(std::vector &armors_msg, hnurm_uart::msg::VisionRecvData &recv_data, TargetInfo &target_msg); + ProcessArmor(std::vector &armors_msg, hnurm_interfaces::msg::VisionRecvData &recv_data, TargetInfo &target_msg); std::unique_ptr tracker; std::unique_ptr tsolver; diff --git a/hnurm_armor/include/hnurm_armor/TSolver.hpp b/hnurm_armor/include/hnurm_armor/TSolver.hpp index 0a857c13500f6f687812dfbbd43bbafb711c866a..09a5150d27851377f426b22e47c049ebbcce146f 100755 --- a/hnurm_armor/include/hnurm_armor/TSolver.hpp +++ b/hnurm_armor/include/hnurm_armor/TSolver.hpp @@ -9,11 +9,9 @@ #include "hnurm_armor/armor.hpp" #include "hnurm_armor/tracker.hpp" -#include "solvePnPBA/solvePnPBA.h" - #include #include - +#include #include #include @@ -28,504 +26,279 @@ namespace hnurm { -class TSolver -{ -public: - explicit TSolver(const rclcpp::Node::SharedPtr &node) + class TSolver { - small_armor_points_ = { - cv::Point3f(-SMALL_ARMOR_WIDTH / 2, 0, SMALL_ARMOR_HEIGHT / 2), - cv::Point3f(-SMALL_ARMOR_WIDTH / 2, 0, -SMALL_ARMOR_HEIGHT / 2), - cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, -SMALL_ARMOR_HEIGHT / 2), - cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, SMALL_ARMOR_HEIGHT / 2), - - cv::Point3f(0 , 0 , SMALL_ARMOR_HEIGHT / 2), - cv::Point3f(-SMALL_ARMOR_WIDTH / 2 , 0 , 0), - cv::Point3f(0 , 0 , -SMALL_ARMOR_HEIGHT / 2), - cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, 0), - - cv::Point3f(0, 0, 0), - - }; - - - large_armor_points_ = { - cv::Point3f(-LARGE_ARMOR_WIDTH / 2, 0, LARGE_ARMOR_HEIGHT / 2), - cv::Point3f(-LARGE_ARMOR_WIDTH / 2, 0, -LARGE_ARMOR_HEIGHT / 2), - cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, -LARGE_ARMOR_HEIGHT / 2), - cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, LARGE_ARMOR_HEIGHT / 2), - - cv::Point3f(0 , 0 , LARGE_ARMOR_WIDTH / 2), - cv::Point3f(-LARGE_ARMOR_WIDTH / 2 , 0 , 0), - cv::Point3f(0 , 0 , -LARGE_ARMOR_WIDTH / 2), - cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, 0), - - cv::Point3f(0, 0, 0), - - }; - - float cam_bias_z, cam_bias_y; - cam_bias_z = node->declare_parameter("processor.solver.camera_bias_z", 0); - cam_bias_y = node->declare_parameter("processor.solver.camera_bias_y", 0); - _cam_bias << cam_bias_z, cam_bias_y, 0; - std::string calib_info_path; - // cfg_node["calib_info_path"] >> calib_info_path; - calib_info_path = node->declare_parameter("processor.solver.calib_info_path", "src/hnurm_armor/data/"); - std::string camera_id; - camera_id = node->declare_parameter("processor.solver.camera_id", "0"); - calib_info_path = calib_info_path + camera_id + ".yaml"; - cv::FileStorage calib_info(calib_info_path, cv::FileStorage::READ); - if(!calib_info.isOpened()) + public: + explicit TSolver(const rclcpp::Node::SharedPtr &node) { - RCLCPP_WARN_STREAM(node->get_logger(), "Failed to load calib info in " << calib_info_path); + small_armor_points_ = { + cv::Point3f(0, 0, SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(-SMALL_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, -SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, 0), + }; + small_armor_9points_ = { + cv::Point3f(-SMALL_ARMOR_WIDTH / 2, 0, SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(-SMALL_ARMOR_WIDTH / 2, 0, -SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, -SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(0, 0, SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(-SMALL_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, -SMALL_ARMOR_HEIGHT / 2), + cv::Point3f(SMALL_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, 0), + }; + large_armor_points_ = { + cv::Point3f(0, 0, LARGE_ARMOR_WIDTH / 2), + cv::Point3f(-LARGE_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, -LARGE_ARMOR_WIDTH / 2), + cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, 0), + }; + large_armor_9points_ = { + cv::Point3f(-LARGE_ARMOR_WIDTH / 2, 0, LARGE_ARMOR_HEIGHT / 2), + cv::Point3f(-LARGE_ARMOR_WIDTH / 2, 0, -LARGE_ARMOR_HEIGHT / 2), + cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, -LARGE_ARMOR_HEIGHT / 2), + cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, LARGE_ARMOR_HEIGHT / 2), + cv::Point3f(0, 0, LARGE_ARMOR_WIDTH / 2), + cv::Point3f(-LARGE_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, -LARGE_ARMOR_WIDTH / 2), + cv::Point3f(LARGE_ARMOR_WIDTH / 2, 0, 0), + cv::Point3f(0, 0, 0), + }; + float cam_bias_z, cam_bias_y; + cam_bias_z = node->declare_parameter("processor.solver.camera_bias_z", 0); + cam_bias_y = node->declare_parameter("processor.solver.camera_bias_y", 0); + _cam_bias << cam_bias_z, cam_bias_y, 0; + std::string calib_info_path; + // cfg_node["calib_info_path"] >> calib_info_path; + calib_info_path = node->declare_parameter("processor.solver.calib_info_path", "src/hnurm_armor/data/"); + std::string camera_id; + camera_id = node->declare_parameter("processor.solver.camera_id", "0"); + calib_info_path = calib_info_path + camera_id + ".yaml"; + cv::FileStorage calib_info(calib_info_path, cv::FileStorage::READ); + if (!calib_info.isOpened()) + { + RCLCPP_WARN_STREAM(node->get_logger(), "Failed to load calib info in " << calib_info_path); + } + calib_info["camera_matrix"] >> camera_matrix_; + calib_info["distortion_coefficients"] >> dist_coeffs_; } - calib_info["camera_matrix"] >> camera_matrix_; - calib_info["distortion_coefficients"] >> dist_coeffs_; - } - - // Get 3d position from 2d points - bool GetTransformation(Armor &armor, float g_pitch, float g_yaw, const geometry_msgs::msg::TransformStamped&imu_to_gimbal_trans - ) - { - // 求解PnP问题 - // g_pitch = 0; - // g_yaw=0; - cv::Mat rvec, tvec; - if(armor.armor_type == ArmorType::SMALL) + float distance(const cv::Point2f &p1, const cv::Point2f &p2) { - cv::solvePnP( - small_armor_points_, armor.points2d, camera_matrix_, dist_coeffs_, rvec, tvec, false, cv::SOLVEPNP_IPPE - ); -// solvePnPBA(small_armor_points_, armor.points2d, camera_matrix_, dist_coeffs_, rvec, tvec, true); + float dx = p1.x - p2.x; + float dy = p1.y - p2.y; + return sqrt(dx * dx + dy * dy); } - else if(armor.armor_type == ArmorType::LARGE) - cv::solvePnP( - large_armor_points_, armor.points2d, camera_matrix_, dist_coeffs_, rvec, tvec, false, cv::SOLVEPNP_IPPE - ); - - // 构造变换矩阵 - armor._translation << tvec.at(0, 0), tvec.at(1, 0), tvec.at(2, 0); - Eigen::AngleAxisd rot_angle( - cv::norm(rvec), Eigen::Vector3d(rvec.at(0, 0), rvec.at(1, 0), rvec.at(2, 0)) - ); - armor._rmat = rot_angle.matrix(); - float sp = std::sin(g_pitch), cp = std::cos(g_pitch), sy = std::sin(g_yaw), cy = std::cos(g_yaw); - armor._r1 << 1, 0, 0, - 0, 0, 1, - 0, -1, 0; - armor._r2 << 1, 0, 0, - 0, cp, -sp, - 0, sp, cp; - armor._r3 << cy, -sy, 0, - sy, cy, 0, - 0, 0, 1; - // 计算装甲板中心点在世界坐标系下的坐标,以及装甲板的旋转矩阵 - - Eigen::Quaterniond cam_to_imu(1,0,0,0); - Eigen::Quaterniond imu_to_gimbal; - tf2::fromMsg(imu_to_gimbal_trans.transform.rotation, imu_to_gimbal); - - auto rot = imu_to_gimbal * cam_to_imu * armor._rmat; - auto pos = (imu_to_gimbal * cam_to_imu * armor._translation) / 1'000; - RCLCPP_INFO_STREAM(rclcpp::get_logger("TSolver"), "pos: " << pos.transpose()); - RCLCPP_INFO_STREAM(rclcpp::get_logger("TSolver"), "rot: " << rot.matrix().transpose()); - - armor.rotation = armor._r3 * armor._r2 * armor._r1 * armor._rmat; - armor.position = armor._r3 * armor._r2 * (armor._r1 * armor._translation) / 1'000; - - RCLCPP_INFO_STREAM(rclcpp::get_logger("TSolver"), "pos: " << armor.position.transpose()); - RCLCPP_INFO_STREAM(rclcpp::get_logger("TSolver"), "rot: " << armor.rotation.transpose()); - return true; - } - - /** - * @brief 实现可视化 - * @param curr_tracker - * @param radius_1 读取到的装甲板和其相对的装甲板的距离 - * @param radius_2 - * @return - */ - void ArmorVisualization(const Tracker &curr_tracker, const TargetInfo &target) - { - cv::Mat visualization(1'000, 1'000, CV_8UC3, cv::Scalar(0, 0, 0)); // 可视化界面 - cv::putText( - visualization, - "radius_1:" + std::to_string(target.radius_1), - cv::Point(100, 100), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示距离 - cv::putText( - visualization, - "radius_2:" + std::to_string(target.radius_2), - cv::Point(100, 150), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示距离 - cv::putText( - visualization, - "yaw" + std::to_string(angles::to_degrees(target.yaw)), - cv::Point(100, 200), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - cv::putText( - visualization, - "vx: " + std::to_string(target.vx), - cv::Point(100, 400), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - cv::putText( - visualization, - "x: " + std::to_string(target.x), - cv::Point(100, 350), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - cv::putText( - visualization, - "vy: " + std::to_string(target.vy), - cv::Point(100, 500), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - cv::putText( - visualization, - "y: " + std::to_string(target.y), - cv::Point(100, 450), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - cv::putText( - visualization, - "vz: " + std::to_string(target.vz), - cv::Point(100, 600), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - cv::putText( - visualization, - "z: " + std::to_string(target.z), - cv::Point(100, 550), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - cv::putText( - visualization, - "w_yaw: " + std::to_string(target.w_yaw), - cv::Point(100, 250), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); // 显示w_yaw - - // write the tracker state - std::string tracker_state; - switch(curr_tracker.tracker_state) + float totalDistance(const std::vector &points1, const std::vector &points2) + { + float total_dist = 0.0f; + for (size_t i = 0; i < points1.size(); ++i) + { + total_dist += distance(points1[i], points2[i]); + } + return total_dist; + } + static void rotationMatrixToEulerAngles(const Eigen::Matrix3d &R, Eigen::Vector3d &eulerAngles) { - case Tracker::TRACKING: - tracker_state = "TRACKING"; - break; - case Tracker::LOST: - tracker_state = "LOST"; - break; - case Tracker::DETECTING: - tracker_state = "DETECTING"; - break; - case Tracker::TEMP_LOST: - tracker_state = "TEMP_LOST"; - break; + double sy = sqrt(R(0, 0) * R(0, 0) + R(1, 0) * R(1, 0)); + bool singular = sy < 1e-6; // If + if (!singular) + { + eulerAngles[0] = atan2(R(2, 1), R(2, 2)); // pitch + eulerAngles[1] = atan2(-R(2, 0), sy); // roll + eulerAngles[2] = atan2(R(1, 0), R(0, 0)); // yaw + } + else + { + eulerAngles[0] = atan2(-R(1, 2), R(1, 1)); + eulerAngles[1] = atan2(-R(2, 0), sy); + eulerAngles[2] = 0; + } } - cv::putText( - visualization, - "tracker state:" + tracker_state, - cv::Point(100, 300), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - cv::putText( - visualization, - "tracker_armor_sum" + std::to_string((int)curr_tracker.tracked_armors_num), - cv::Point(100, 325), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - float bili = 0.1; - float radius_1 = 2 * target.radius_1 * 1'000 * bili; - float radius_2 = 2 * target.radius_2 * 1'000 * bili; - float t_x = target.x * 1'000 * bili; - float t_y = target.y * 1'000 * bili; - cv::arrowedLine( - visualization, cv::Point(0, 500), cv::Point(1'000, 500), cv::Scalar(255, 0, 0), 1, 8, 0, 0.01 - ); // 世界坐标系x轴 蓝色 - cv::arrowedLine( - visualization, cv::Point(500, 1'000), cv::Point(500, 0), cv::Scalar(0, 255, 255), 1, 8, 0, 0.01 - ); // 世界坐标系y轴 黄色 - Eigen::Vector3d x_c(50 / bili, 0, 0); - Eigen::Vector3d y_c(0, 50 / bili, 0); - const auto armor = curr_tracker.tracked_armor; - cv::putText( - visualization, - "xa: " + std::to_string(armor.position(0)), - cv::Point(100, 700), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - cv::putText( - visualization, - "ya: " + std::to_string(armor.position(1)), - cv::Point(100, 750), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - cv::putText( - visualization, - "za: " + std::to_string(armor.position(2)), - cv::Point(100, 800), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - double dis_armor_to_origin = armor.position.norm(); - double dis_center_to_origin = sqrt(pow(target.x, 2) + pow(target.y, 2) + pow(target.z, 2)); - cv::putText( - visualization, - "armor_dis: " + std::to_string(dis_armor_to_origin), - cv::Point(800, 50), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - cv::putText( - visualization, - "center_dis: " + std::to_string(dis_center_to_origin), - cv::Point(800, 100), - cv::FONT_HERSHEY_SIMPLEX, - 0.5, - cv::Scalar(255, 255, 255), - 1, - 8, - false - ); - Eigen::Vector3d x_w - = armor._r3 * armor._r2 * (armor._r1 * (armor._rmat * x_c + armor._translation) + _cam_bias); - Eigen::Vector3d z_w - = armor._r3 * armor._r2 * (armor._r1 * (armor._rmat * y_c + armor._translation) + _cam_bias); - Eigen::Vector3d center_w = armor._r3 * armor._r2 * (armor._r1 * armor._translation + _cam_bias); - // std::cout<<"z_w-center_w"< armors; - armors.push_back(armor1); - armors.push_back(armor2); - armors.push_back(armor3); - armors.push_back(armor4); - sort(armors.begin(), armors.end(), Compensator::cmp); - double rad0 = atan2(armors[0].y, armors[0].x); - double rad1 = atan2(armors[1].y, armors[1].x); - double rad = atan2(target.y, target.x); - if(abs(angles::shortest_angular_distance(rad0, rad)) < abs(angles::shortest_angular_distance(rad1, rad))) + float get_distance(const float &yaw_reg, Armor &armor, cv::Mat &tvec) { - fx = armors[0].x; - fy = armors[0].y; - fz = armors[0].z; + double pitch_deg; + if (armor.number == "outpost") + { + pitch_deg = 15.0; + } + else if (armor.number == "base") + { + pitch_deg = -62.5; + } + else + { + pitch_deg = -15.0; + } + double pitch_rad = pitch_deg * CV_PI / 180.0; + double yaw_rad = yaw_reg * CV_PI / 180.0; + Eigen::Matrix3d rotation_matrix_pitch_roll; + rotation_matrix_pitch_roll << 1, 0, 0, + 0, cos(pitch_rad), -sin(pitch_rad), + 0, sin(pitch_rad), cos(pitch_rad); + Eigen::Matrix3d rotation_matrix_yaw; + rotation_matrix_yaw << cos(yaw_rad), -sin(yaw_rad), 0, + sin(yaw_rad), cos(yaw_rad), 0, + 0, 0, 1; + Eigen::Matrix3d final_rotation_matrix = rotation_matrix_yaw * rotation_matrix_pitch_roll; + std::vector image_points; + cv::Matx33d final_rotation_matrix_opencv( + final_rotation_matrix(0, 0), final_rotation_matrix(0, 1), final_rotation_matrix(0, 2), + final_rotation_matrix(1, 0), final_rotation_matrix(1, 1), final_rotation_matrix(1, 2), + final_rotation_matrix(2, 0), final_rotation_matrix(2, 1), final_rotation_matrix(2, 2) + ); + cv::Matx33d r; + cv::eigen2cv(armor._R, r); + if (armor.armor_type == ArmorType::SMALL) + { + projectPoints(small_armor_9points_, + r * final_rotation_matrix_opencv, + tvec, + camera_matrix_, + dist_coeffs_, + image_points); + } + else + { + projectPoints(large_armor_9points_, + r * final_rotation_matrix_opencv, + tvec, + camera_matrix_, + dist_coeffs_, + image_points); + } +// std::vector last_five_points(armor.points2d.end() - 5, armor.points2d.end()); + float distance_9 = totalDistance(armor.points2d, image_points); + return distance_9; } - else + // Get 3d position from 2d points + bool GetTransformation(Armor &armor, float g_pitch, float g_yaw) { - fx = armors[1].x; - fy = armors[1].y; - fz = armors[1].z; + // 求解PnP问题 + // g_pitch = 0; + // g_yaw=0; + cv::Mat rvec, tvec; + if (armor.armor_type == ArmorType::SMALL) + { + cv::solvePnP( + small_armor_9points_, + armor.points2d, + camera_matrix_, + dist_coeffs_, + rvec, + tvec, + false, + cv::SOLVEPNP_IPPE + ); +// solvePnPBA(small_armor_points_, armor.points2d, camera_matrix_, dist_coeffs_, rvec, tvec, true); + } + else if (armor.armor_type == ArmorType::LARGE) + cv::solvePnP( + large_armor_9points_, + armor.points2d, + camera_matrix_, + dist_coeffs_, + rvec, + tvec, + false, + cv::SOLVEPNP_IPPE + ); + + // 构造变换矩阵 + armor._translation << tvec.at(0, 0), tvec.at(1, 0), tvec.at(2, 0); + Eigen::AngleAxisd rot_angle( + cv::norm(rvec), Eigen::Vector3d(rvec.at(0, 0), rvec.at(1, 0), rvec.at(2, 0)) + ); + armor._rmat = rot_angle.matrix(); + float sp = std::sin(g_pitch), cp = std::cos(g_pitch), sy = std::sin(g_yaw), cy = std::cos(g_yaw); + armor._r1 << 1, 0, 0, + 0, 0, 1, + 0, -1, 0; + armor._r2 << 1, 0, 0, + 0, cp, -sp, + 0, sp, cp; + armor._r3 << cy, -sy, 0, + sy, cy, 0, + 0, 0, 1; + armor._R = (armor._r3 * armor._r2 * armor._r1).inverse(); + armor.rotation = armor._r3 * armor._r2 * armor._r1 * armor._rmat; + armor.position = armor._r3 * armor._r2 * (armor._r1 * armor._translation) / 1'000; + Eigen::Vector3d eulerAngles; + rotationMatrixToEulerAngles(armor.rotation, eulerAngles); + float a = eulerAngles[2] * 180 / CV_PI - 35; // 搜索区间起点 + float b = eulerAngles[2] * 180 / CV_PI + 35; // 搜索区间终点 + float tolerance = 0.1; // 精度阈值 + const float phi = (1 + std::sqrt(5)) / 2; // 黄金分割比 + float c = b - (b - a) / phi; + float d = a + (b - a) / phi; + while (std::fabs(b - a) > tolerance) + { + float s1 = get_distance(c, armor, tvec); + float s2 = get_distance(d, armor, tvec); + if (s1 < s2) + { + b = d; + } + else + { + a = c; + } + c = b - (b - a) / phi; + d = a + (b - a) / phi; + } + float right_yaw = (a + b) / 2 * CV_PI / 180; + Eigen::Matrix3d rotation_matrix_pitch_roll; + double pitch_deg; + if (armor.number == "outpost") + { + pitch_deg = 15.0; + } + else if (armor.number == "base") + { + pitch_deg = -62.5; + } + else + { + pitch_deg = -15.0; + } + rotation_matrix_pitch_roll << 1, 0, 0, + 0, cos(pitch_deg * CV_PI / 180.0), -sin(pitch_deg * CV_PI / 180.0), + 0, sin(pitch_deg * CV_PI / 180.0), cos(pitch_deg * CV_PI / 180.0); + Eigen::Matrix3d rotation_matrix_yaw; + rotation_matrix_yaw << cos(right_yaw), -sin(right_yaw), 0, + sin(right_yaw), cos(right_yaw), 0, + 0, 0, 1; + armor.rotation = rotation_matrix_yaw * rotation_matrix_pitch_roll; + return true; } - circle( - visualization, - cv::Point((int)(500 + fx * 1'000 * bili), (int)(500 - fy * 1'000 * bili)), - 3, - cv::Scalar(255, 255, 255), - -1 - ); - /// 111 - line( - visualization, - cv::Point( - (int)(500 + t_x - radius_1 * cos(target.yaw) / 2), (int)(500 - t_y + radius_1 * sin(target.yaw) / 2) - ), - cv::Point( - (int)(500 + t_x + radius_1 * cos(target.yaw) / 2), (int)(500 - t_y - radius_1 * sin(target.yaw) / 2) - ), - cv::Scalar(0, 0, 255), - 2 - ); // 根据半径画出车 - line( - visualization, - cv::Point( - (int)(500 + t_x - radius_2 * sin(target.yaw) / 2), (int)(500 - t_y - radius_2 * cos(target.yaw) / 2) - ), - cv::Point( - (int)(500 + t_x + radius_2 * sin(target.yaw) / 2), (int)(500 - t_y + radius_2 * cos(target.yaw) / 2) - ), - cv::Scalar(0, 0, 255), - 2 - ); // 根据半径画出车 - circle(visualization, cv::Point((int)(500 + t_x), (int)(500 - t_y)), 3, cv::Scalar(0, 0, 255), -1); // 车的中心 - cv::namedWindow("visualization", cv::WINDOW_AUTOSIZE); - cv::imshow("visualization", visualization); - cv::waitKey(1); - } - -private: - cv::Mat camera_matrix_; - cv::Mat dist_coeffs_; - // Unit: mm - static constexpr float SMALL_ARMOR_WIDTH = 135; - static constexpr float SMALL_ARMOR_HEIGHT = 55; - static constexpr float LARGE_ARMOR_WIDTH = 225; - static constexpr float LARGE_ARMOR_HEIGHT = 55; - // Four vertices of armor in 3d - std::vector small_armor_points_; - std::vector large_armor_points_; - Eigen::Vector3d _cam_bias; - double angle = 0.2 * CV_PI; - float lastr = 0.14; - float radius = 0.24; - cv::Point2f ccc = cv::Point2f(3, 3); - std::vector armorss; - std::vector armorss1; -}; + private: + cv::Mat camera_matrix_; + cv::Mat dist_coeffs_; + + static constexpr float SMALL_ARMOR_WIDTH = 131.25; + static constexpr float SMALL_ARMOR_HEIGHT = 55.5; + static constexpr float LARGE_ARMOR_WIDTH = 226.25; + static constexpr float LARGE_ARMOR_HEIGHT = 55.5; + + // Four vertices of armor in 3d + std::vector small_armor_points_; + std::vector small_armor_9points_; + std::vector large_armor_points_; + std::vector large_armor_9points_; + Eigen::Vector3d _cam_bias; + double angle = 0.2 * CV_PI; + float lastr = 0.14; + float radius = 0.24; + cv::Point2f ccc = cv::Point2f(3, 3); + std::vector armorss; + std::vector armorss1; + }; } // namespace hnurm diff --git a/hnurm_armor/include/hnurm_armor/armor.hpp b/hnurm_armor/include/hnurm_armor/armor.hpp index cfa01e5afc142f5069172f70bef464eccc4864de..bb35ed3991052e6e0a5e53b0eaf0e06181c16490 100755 --- a/hnurm_armor/include/hnurm_armor/armor.hpp +++ b/hnurm_armor/include/hnurm_armor/armor.hpp @@ -29,7 +29,7 @@ struct Light : public cv::RotatedRect explicit Light(const cv::RotatedRect &box) : cv::RotatedRect(box) { - cv::Point2f p[4]; + box.points(p); std::sort(p, p + 4, [](const cv::Point2f &a, const cv::Point2f &b) { return a.y < b.y; }); top = (p[0] + p[1]) / 2; @@ -47,6 +47,7 @@ struct Light : public cv::RotatedRect double length; double width; float tilt_angle; + cv::Point2f p[4]; }; struct Armor @@ -112,6 +113,7 @@ struct Armor Eigen::Matrix3d _r1; // 相机坐标系到云台坐标系 Eigen::Matrix3d _r2; // 先对pitch进行旋转 Eigen::Matrix3d _r3; // 再对yaw的旋转,变为世界坐标系(pitch、yaw为0) + Eigen::Matrix3d _R; //本体系到相机系 Eigen::Matrix3d _rmat; Eigen::Vector3d _translation; }; diff --git a/hnurm_armor/include/hnurm_armor/armor_node.hpp b/hnurm_armor/include/hnurm_armor/armor_node.hpp index 218922174365923a86b57caad6fcfa93877de74a..9a55a27fdc1717f7e7bfe4d2dc9aacdb89e6315e 100644 --- a/hnurm_armor/include/hnurm_armor/armor_node.hpp +++ b/hnurm_armor/include/hnurm_armor/armor_node.hpp @@ -2,30 +2,39 @@ #include "hnurm_armor/Compensator.h" #include "hnurm_armor/Processor.h" -#include "hnurm_armor/msg/target.hpp" -#include "hnurm_armor/msg/tracker_info.hpp" -#include "hnurm_detect/msg/armor_array.hpp" +#include "hnurm_interfaces/msg/armor_array.hpp" +#include "hnurm_interfaces/msg/target.hpp" +#include "hnurm_interfaces/msg/tracker_info.hpp" #include +#include "hnurm_armor/armor.hpp" +#include +#include +#include + namespace hnurm { - -std::vector fromROSMsg(const hnurm_detect::msg::ArmorArray &armors); +std::vector fromROSMsg(const hnurm_interfaces::msg::ArmorArray &armors); class ArmorNode : public rclcpp::Node { public: explicit ArmorNode(const rclcpp::NodeOptions &options); - ~ArmorNode() {RCLCPP_INFO(get_logger(), "ArmorNode destroyed");} + ~ArmorNode() + { + RCLCPP_INFO(get_logger(), "ArmorNode destroyed"); + } void init_markers(); - void send_target(TargetInfo &target, hnurm_uart::msg::VisionRecvData &uart_msg); + void send_target(TargetInfo &target, hnurm_interfaces::msg::VisionRecvData &uart_msg); + + void publish_markers(hnurm_interfaces::msg::Target &target_msg); - void publish_markers(hnurm_armor::msg::Target &target_msg); + void timer_callback(); ArmorNode(const ArmorNode &) = delete; ArmorNode &operator=(const ArmorNode &) = delete; @@ -39,15 +48,17 @@ protected: } private: - void armor_array_callback(hnurm_detect::msg::ArmorArray::SharedPtr msg); + void armor_array_callback(hnurm_interfaces::msg::ArmorArray::SharedPtr msg); private: - rclcpp::Publisher::SharedPtr send_data_pub_; - rclcpp::Subscription::SharedPtr armor_array_sub_; + rclcpp::Publisher::SharedPtr send_data_pub_; + rclcpp::Subscription::SharedPtr armor_array_sub_; rclcpp::Publisher::SharedPtr marker_pub_; - rclcpp::Publisher::SharedPtr target_pub_; - rclcpp::Publisher::SharedPtr tracker_info_pub_; + rclcpp::Publisher::SharedPtr target_pub_; + rclcpp::Publisher::SharedPtr tracker_info_pub_; + + rclcpp::TimerBase::SharedPtr timer_; // markers visualization_msgs::msg::Marker position_marker_; @@ -57,5 +68,14 @@ private: std::unique_ptr processor_; std::unique_ptr compensator_; + std::vector armors; + std::mutex mtx; + + hnurm_interfaces::msg::ArmorArray last_recv_array_; + std::vector pv; + + float calculateAverage(const std::vector &vec); + + void Averagedistance(std::vector &p, float value); }; } \ No newline at end of file diff --git a/hnurm_armor/include/hnurm_armor/tracker.hpp b/hnurm_armor/include/hnurm_armor/tracker.hpp index 55cb18e6e65691a88319c1e52d6225e801a54802..629bdca00ec66ef9c128b1b42738235771997bb2 100755 --- a/hnurm_armor/include/hnurm_armor/tracker.hpp +++ b/hnurm_armor/include/hnurm_armor/tracker.hpp @@ -32,6 +32,7 @@ public: DETECTING, TRACKING, TEMP_LOST, + JUMP, } tracker_state; ExtendedKalmanFilter ekf; @@ -49,7 +50,8 @@ public: // To store another pair of armors message double dz {}, another_r {}; static int i_jump; - + double armor_pitch{}; + double armor_yaw{}; // todo double orientationToYaw(const Eigen::Matrix3d &R); @@ -72,7 +74,7 @@ private: int lost_count_ {}; double last_yaw_ {}; - double armor_pitch {}; + }; } // namespace hnurm diff --git a/hnurm_armor/include/solvePnPBA/solvePnPBA.h b/hnurm_armor/include/solvePnPBA/solvePnPBA.h deleted file mode 100644 index 62ecb985b5e5824199e353b0aef7d907546d5a2e..0000000000000000000000000000000000000000 --- a/hnurm_armor/include/solvePnPBA/solvePnPBA.h +++ /dev/null @@ -1,149 +0,0 @@ -// -// Created by Kai Wang on 24-3-15. -// - -#ifndef SCRIPTS_SOLVEPNP_BA_H -#define SCRIPTS_SOLVEPNP_BA_H - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#define TIMEIT(code) \ - do \ - { \ - std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now(); \ - code; \ - std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now(); \ - std::chrono::duration time_used = std::chrono::duration_cast>(t2 - t1); \ - std::cout << "Time cost: " << time_used.count() << " seconds." << std::endl; \ - } \ - while(0) - -using VecVector3d = std::vector>; -using VecVector2d = std::vector>; - -class VertexPose : public g2o::BaseVertex<6, Sophus::SE3d> -{ -public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW; - - void setToOriginImpl() override - { - _estimate = Sophus::SE3d(); - } - - /// left multiplication on SE3 - void oplusImpl(const double *update) override - { - Eigen::Matrix update_eigen; - update_eigen << update[0], update[1], update[2], update[3], update[4], update[5]; - _estimate = Sophus::SE3d::exp(update_eigen) * _estimate; - } - - bool read(std::istream &in) override - { - return true; - } - - bool write(std::ostream &out) const override - { - return true; - } -}; - -class EdgeProjection : public g2o::BaseUnaryEdge<2, Eigen::Vector2d, VertexPose> -{ -public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW; - - EdgeProjection(Eigen::Vector3d pos, Eigen::Matrix3d K) : pose_3d_(std::move(pos)), K_(std::move(K)) - { - } - - void computeError() override - { - const VertexPose *v = dynamic_cast(_vertices[0]); - Sophus::SE3d T = v->estimate(); - Eigen::Vector3d pos_pixel = K_ * (T * pose_3d_); - pos_pixel /= pos_pixel[2]; - _error = _measurement - pos_pixel.head<2>(); - } - - void linearizeOplus() override - { - const VertexPose *v = dynamic_cast(_vertices[0]); - Sophus::SE3d T = v->estimate(); - Eigen::Vector3d pos_cam = T * pose_3d_; - double fx = K_(0, 0); - double fy = K_(1, 1); - double cx = K_(0, 2); - double cy = K_(1, 2); - double X = pos_cam[0]; - double Y = pos_cam[1]; - double Z = pos_cam[2]; - double Z2 = Z * Z; - _jacobianOplusXi << -fx / Z, 0, fx * X / Z2, fx * X * Y / Z2, -fx - fx * X * X / Z2, fx * Y / Z, 0, -fy / Z, - fy * Y / (Z * Z), fy + fy * Y * Y / Z2, -fy * X * Y / Z2, -fy * X / Z; - } - - bool read(std::istream &in) override - { - return true; - } - - bool write(std::ostream &out) const override - { - return true; - } - -private: - Eigen::Vector3d pose_3d_; - Eigen::Matrix3d K_; -}; - -/** - * @brief do bundle adjustment with g2o - * @param points_3d vector of 3d points, i.e. object points in world coordinate - * @param points_2d vector of 2d points, i.e. image points in pixel coordinate - * @param K camera intrinsic matrix - * @param pose pose of camera, initial value is used as input, and refined pose is output - */ -void bundleAdjustmentG2O( - const VecVector3d &points_3d, const VecVector2d &points_2d, const cv::Mat &K, Sophus::SE3d &pose -); - -/** - * @brief solve PnP problem with bundle adjustment - * @param object_points the 3d points in world coordinate - * @param image_points the 2d points in pixel coordinate - * @param cameraMatrix camera intrinsic matrix - * @param distCoeffs distortion coefficients [not used] - * @param rvec rotation vector - * @param tvec translation vector - * @param useExtrinsicGuess whether to use the initial value from rvec and tvec - * @return - */ -bool solvePnPBA( - cv::InputArray object_points, - cv::InputArray image_points, - cv::InputArray cameraMatrix, - cv::InputArray distCoeffs, - cv::OutputArray rvec, - cv::OutputArray tvec, - bool useExtrinsicGuess -); - -#endif // SCRIPTS_SOLVEPNP_BA_H diff --git a/hnurm_armor/include/solvePnPBA/test.cpp b/hnurm_armor/include/solvePnPBA/test.cpp deleted file mode 100644 index ea8e061390ded77977dac404512a2255edd92734..0000000000000000000000000000000000000000 --- a/hnurm_armor/include/solvePnPBA/test.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -// Created by Kai Wang on 24-3-15. -// - -#include "solvePnPBA.h" - -void data_generation( - const Eigen::Isometry3d &transform, const Eigen::Matrix3d &K, VecVector3d &obj_points, VecVector2d &img_points -) -{ - obj_points.clear(); - img_points.clear(); - double z = 1; - obj_points.emplace_back(-2, 1, z); - obj_points.emplace_back(2, 1, z); - obj_points.emplace_back(-2, -1, z); - obj_points.emplace_back(2, -1, z); - - for(const auto &obj_point : obj_points) - { - Eigen::Vector3d cam_point = transform * obj_point; - Eigen::Vector3d pixel = K * cam_point; - pixel /= pixel[2]; - // add noise - std::random_device rd; - std::default_random_engine generator(rd()); - std::normal_distribution noise(0, 20); - pixel[0] += noise(generator); - pixel[1] += noise(generator); - img_points.emplace_back(pixel[0], pixel[1]); - } -} - -int main() -{ - // 相机内参 - Eigen::Matrix3d K; - K << 520.9, 0, 325.1, 0, 521.0, 249.7, 0, 0, 1; - - // 相机位姿 - Eigen::Isometry3d T = Eigen::Isometry3d::Identity(); - T.rotate(Eigen::AngleAxisd(M_PI / 4, Eigen::Vector3d(0, 0, 1))); - T.rotate(Eigen::AngleAxisd(M_PI / 8, Eigen::Vector3d(0, 1, 0))); - T.rotate(Eigen::AngleAxisd(M_PI / 10, Eigen::Vector3d(1, 0, 0))); - T.pretranslate(Eigen::Vector3d(0.7, 0.8, 2.0)); - - // 生成3D-2D观测数据 - VecVector3d obj_points; - VecVector2d img_points; - data_generation(T, K, obj_points, img_points); - - cv::Mat obj_mat(obj_points.size(), 3, CV_64F); - cv::Mat img_mat(img_points.size(), 2, CV_64F); - for(int i = 0; i < obj_points.size(); i++) - { - obj_mat.at(i, 0) = obj_points[i][0]; - obj_mat.at(i, 1) = obj_points[i][1]; - obj_mat.at(i, 2) = obj_points[i][2]; - img_mat.at(i, 0) = img_points[i][0]; - img_mat.at(i, 1) = img_points[i][1]; - } - - cv::Mat K_mat(3, 3, CV_64F); - cv::eigen2cv(K, K_mat); - - // 调用g2o进行优化 - Sophus::SE3d pose_g2o; - cv::Mat r, t; - - cv::Mat rvec, tvec; - // opencv 的PNP求解 - TIMEIT(cv::solvePnP(obj_mat, img_mat, K_mat, cv::Mat(), rvec, tvec, false, cv::SOLVEPNP_IPPE);); - - cv::Mat R; - cv::Rodrigues(rvec, R); - std::cout << "opencv estimated rvec =\n" << R << std::endl; - std::cout << "opencv estimated tvec =\n" << tvec << std::endl; - - TIMEIT(solvePnPBA(obj_mat, img_mat, K_mat, cv::noArray(), r, t, false);); - - cv::Rodrigues(r, R); - std::cout << "ba estimated rvec =\n" << R << std::endl; - std::cout << "ba estimated tvec =\n" << t << std::endl; - - // gt - std::cout << "gt r =\n" << T.matrix() << std::endl; - - return 0; -} diff --git a/hnurm_armor/package.xml b/hnurm_armor/package.xml index f399a00911cf3a699186f172011f225cff096a01..c4d1c0fea0de3e4e456e20dbc7711cb704e739a3 100644 --- a/hnurm_armor/package.xml +++ b/hnurm_armor/package.xml @@ -18,13 +18,15 @@ angles visualization_msgs + tf2 + tf2_ros + tf2_eigen + tf2_geometry_msgs + Eigen3 OpenCV - Sophus - g2o - hnurm_uart - hnurm_detect + hnurm_interfaces rosidl_interface_packages diff --git a/hnurm_armor/params/default.yaml b/hnurm_armor/params/default.yaml index cdae9e169fae148dd1f81f00b3f7499643b35e95..0562d49aa6e6937038b924c5c781386907b29695 100644 --- a/hnurm_armor/params/default.yaml +++ b/hnurm_armor/params/default.yaml @@ -2,10 +2,12 @@ ros__parameters: # topics - vision_send_topic: "vision_send_res" + vision_send_topic: "vision_send_data" tracker_info_topic: "tracker_info" target_topic: "target" + using_timer: false + ##################################### # configs for compensator module # @@ -13,22 +15,22 @@ compensator: gravity: 9.8 friction_coeff: 0.02 - bullet_speed_bias: -0.5 - channel_delay: 0.01 # s + bullet_speed_bias: 0.0 + channel_delay: 0.05 # s yaw_bias: 0.0 pitch_bias: 0.0 # dirty param - imutofrt_y: 0 #单位:米 - imutofrt_z: 0 + imutofrt_y: 0.08418 #单位:米 + imutofrt_z: 0.005 ##################################### # configs for processor module # ##################################### processor: tracker: - max_match_distance: 0.5 # meter + max_match_distance: 1.0 # meter max_match_yaw_diff: 0.5 # rads tracking_threshold: 0.0 # frames - lost_threshold: 15.0 # seconds + lost_threshold: 100.0 # seconds # 过程噪声 s2_q_xyz: 0.05 @@ -37,11 +39,11 @@ # 测量噪声 r_xyz_factor: 4e-4 - r_yaw: 5e-3 + r_yaw: 7e-3 solver: - calib_info_path: "src/hnurm_armor/data/" + calib_info_path: "/home/rm/hnuvision/src/hnurm_armor/data/" # bias to imu - camera_bias_z: 0 # 单位:毫米 - camera_bias_y: 0 - camera_id: 2BDF89504499 + camera_bias_z: 74 # 单位:毫米 + camera_bias_y: 200 + camera_id: 2BDFA2819639 diff --git a/hnurm_armor/src/Compensator.cpp b/hnurm_armor/src/Compensator.cpp index fbb86216bbee08459ab15ce9ba19207c2dc3759d..f4895e9ee8423d272db53d2f91dce5f4c4cfac04 100755 --- a/hnurm_armor/src/Compensator.cpp +++ b/hnurm_armor/src/Compensator.cpp @@ -7,30 +7,55 @@ namespace hnurm { -Compensator::Compensator(rclcpp::Node::SharedPtr node) : node_(std::move(node)) -{ - gravity_ = static_cast(node_->declare_parameter("compensator.gravity", 9.8)); - friction_coeff_ = static_cast(node_->declare_parameter("compensator.friction_coeff", 0.02)); - bullet_speed_bias_ = static_cast(node_->declare_parameter("compensator.bullet_speed_bias", -0.5)); - channel_delay_ = static_cast(node_->declare_parameter("compensator.channel_delay", 0.01)); - yaw_bias_ = static_cast(node_->declare_parameter("compensator.yaw_bias", 0.0)); - pitch_bias_ = static_cast(node_->declare_parameter("compensator.pitch_bias", 0.0)); - imutofrt_y = static_cast(node_->declare_parameter("compensator.imutofrt_y", 0.0)); - imutofrt_z = static_cast(node_->declare_parameter("compensator.imutofrt_z", 0.0)); + Compensator::Compensator(rclcpp::Node::SharedPtr node) + : node_(std::move(node)) + { + gravity_ = static_cast(node_->declare_parameter("compensator.gravity", 9.8)); + friction_coeff_ = static_cast(node_->declare_parameter("compensator.friction_coeff", 0.006)); + bullet_speed_bias_ = static_cast(node_->declare_parameter("compensator.bullet_speed_bias", -0.5)); + channel_delay_ = static_cast(node_->declare_parameter("compensator.channel_delay", 1.2)); + yaw_bias_ = static_cast(node_->declare_parameter("compensator.yaw_bias", 0.0)); + pitch_bias_ = static_cast(node_->declare_parameter("compensator.pitch_bias", 0.0)); + imutofrt_y = static_cast(node_->declare_parameter("compensator.imutofrt_y", 0.0)); + imutofrt_z = static_cast(node_->declare_parameter("compensator.imutofrt_z", 0.0)); - RCLCPP_INFO(node_->get_logger(), "Compensator initialized, yaw_bias: %f, pitch_bias: %f", yaw_bias_, pitch_bias_); + RCLCPP_INFO(node_->get_logger(), + "Compensator initialized, yaw_bias: %f, pitch_bias: %f", + yaw_bias_, + pitch_bias_); - fx = fy = fz = 0; - pout = yout = 0; - tmp_fly_time = channel_delay_; - bullet_speed_ = 0; -} + fx = fy = fz = fv = yaw_difference = 0; + pout = yout = 0; + tmp_fly_time = channel_delay_; + bullet_speed_ = 0; + px = py = pz = pv = {}; + } -bool Compensator::cmp(const cv::Point3f &a, const cv::Point3f &b) -{ - return pow(a.x, 2) + pow(a.y, 2) < pow(b.x, 2) + pow(b.y, 2); -} + float Compensator::calculateAverage(const std::vector &vec) + { + int n = vec.size(); + if (n == 0) return 0.1f; // 如果向量为空,返回0 + + float sum = 0.0f; + for (float value: vec) + { + sum += value; + } + return sum / n; + } + void Compensator::Averagedistance(std::vector &p, float value) + { + if (p.size() >= 50) + { + p.erase(p.begin()); + } + p.push_back(value); + } + bool Compensator::cmp(const predict_armor &a, const predict_armor &b) + { + return a.yaw < b.yaw; + } double Compensator::diff_eq(double v) const { return -gravity_ - (friction_coeff_ * abs(v) * v); @@ -40,126 +65,197 @@ bool Compensator::cmp(const cv::Point3f &a, const cv::Point3f &b) double v = v0; double y = 0.0; double dt = 0.001; - for (double time = 0; time <= t; time += dt) { + for (double time = 0; time <= t; time += dt) + { double dv = diff_eq(v); v += dv * dt; y += v * dt; } return y; } -float Compensator::CalcFinalAngle( - TargetInfo &target_msg, hnurm_uart::msg::VisionRecvData &recv_data, hnurm_uart::msg::VisionSendData &send_data,ArmorsNum &armors_num -) -{ - tmp_fly_time = channel_delay_; - // todo: fix this - auto bullet_speed = recv_data.bullet_speed.data; - auto g_yaw = recv_data.yaw; - t_info = target_msg; - bullet_speed_ = static_cast(bullet_speed) + bullet_speed_bias_; - // 迭代三次 - for(int i = 0; i < 5; i++) + float Compensator::CalcFinalAngle( + TargetInfo &target_msg, + hnurm_interfaces::msg::VisionRecvData &recv_data, + hnurm_interfaces::msg::VisionSendData &send_data, + ArmorsNum &armors_num + ) { - PredictPose(armors_num); - CompensatePitch(); - } - yout = (float) (g_yaw + angles::shortest_angular_distance(g_yaw * CV_PI / 180, -atan2(fx_center, fy_center)) * 180 / CV_PI); - auto armor_yaw = (float) (g_yaw + angles::shortest_angular_distance(g_yaw * CV_PI / 180, -atan2(fx, fy)) * 180 / CV_PI); - send_data.pitch = pout; - send_data.yaw = yout; - return armor_yaw; -} - -// 根据飞行时间预测目标位置 todo -void Compensator::PredictPose(ArmorsNum &armors_num) -{ - if (abs(t_info.w_yaw) > 1 || (abs(t_info.vx) + abs(t_info.vy) + abs(t_info.vz)) > 1) { - fx = t_info.x + tmp_fly_time * t_info.vx;// 根据飞行时间和速度计算预测的x坐标 - fy = t_info.y + tmp_fly_time * t_info.vy;// 根据飞行时间和速度计算预测的y坐标 - fz = t_info.z + tmp_fly_time * t_info.vz;// 根据飞行时间和速度计算预测的z坐标 - fx_center = fx; - fy_center = fy; - float yaw = t_info.yaw + tmp_fly_time * t_info.w_yaw;// 计算预测的偏航角 - cv::Point3f armor1, armor2, armor3, armor4; - std::vector armor; - if (armors_num == ArmorsNum::OUTPOST_3) { - armor1.x = fx - t_info.radius_1 * cos(yaw); // 计算预测的护甲点1的x坐标 - armor1.y = fy - t_info.radius_1 * sin(yaw); // 计算预测的护甲点1的y坐标 - armor1.z = fz; // 设置预测的护甲点1的z坐标为当前的z坐标 - armor2.x = fx - t_info.radius_1 * cos(float(yaw + 2 * CV_PI / 3));// 计算预测的护甲点2的x坐标 - armor2.y = fy - t_info.radius_1 * sin(float(yaw + 2 * CV_PI / 3));// 计算预测的护甲点2的y坐标 - armor2.z = fz; // 设置预测的护甲点2的z坐标为当前的z坐标 - armor3.x = fx - t_info.radius_1 * sin(float(yaw + 4 * CV_PI / 3));// 计算预测的护甲点3的x坐标 - armor3.y = fy - t_info.radius_1 * cos(float(yaw + 4 * CV_PI / 3));// 计算预测的护甲点3的y坐标 - armor3.z = fz; - armor.push_back(armor1);// 将预测的护甲点1加入vector - armor.push_back(armor2);// 将预测的护甲点2加入vector - armor.push_back(armor3);// 将预测的护甲点3加入vector - } else if (armors_num == ArmorsNum::NORMAL_4) { - armor1.x = fx - t_info.radius_1 * cos(yaw);// 计算预测的护甲点1的x坐标 - armor1.y = fy - t_info.radius_1 * sin(yaw);// 计算预测的护甲点1的y坐标 - armor1.z = fz; // 设置预测的护甲点1的z坐标为当前的z坐标 - armor2.x = fx + t_info.radius_1 * cos(yaw);// 计算预测的护甲点2的x坐标 - armor2.y = fy + t_info.radius_1 * sin(yaw);// 计算预测的护甲点2的y坐标 - armor2.z = fz; // 设置预测的护甲点2的z坐标为当前的z坐标 - armor3.x = fx - t_info.radius_2 * sin(yaw);// 计算预测的护甲点3的x坐标 - armor3.y = fy + t_info.radius_2 * cos(yaw);// 计算预测的护甲点3的y坐标 - armor3.z = fz + t_info.dz; // 设置预测的护甲点3的z坐标为当前的z坐标加上护甲的深度 - armor4.x = fx + t_info.radius_2 * sin(yaw);// 计算预测的护甲点4的x坐标 - armor4.y = fy - t_info.radius_2 * cos(yaw);// 计算预测的护甲点4的y坐标 - armor4.z = fz + t_info.dz; // 设置预测的护甲点4的z坐标为当前的z坐标加上护甲的深度 - armor.push_back(armor1); // 将预测的护甲点1加入vector - armor.push_back(armor2); // 将预测的护甲点2加入vector - armor.push_back(armor3); // 将预测的护甲点3加入vector - armor.push_back(armor4); // 将预测的护甲点4加入vector - } else if (armors_num == ArmorsNum::BALANCE_2) { - armor1.x = fx - t_info.radius_1 * cos(yaw);// 计算预测的护甲点1的x坐标 - armor1.y = fy - t_info.radius_1 * sin(yaw);// 计算预测的护甲点1的y坐标 - armor1.z = fz; // 设置预测的护甲点1的z坐标为当前的z坐标 - armor2.x = fx + t_info.radius_1 * cos(yaw);// 计算预测的护甲点2的x坐标 - armor2.y = fy + t_info.radius_1 * sin(yaw);// 计算预测的护甲点2的y坐标 - armor2.z = fz; // 设置预测的护甲点2的z坐标为当前的z坐标 - armor.push_back(armor1); // 将预测的护甲点1加入vector - armor.push_back(armor2); // 将预测的护甲点2加入vector + tmp_fly_time = channel_delay_; + // todo: fix this + auto bullet_speed = recv_data.bullet_speed.data; + auto g_yaw = recv_data.yaw; + t_info = target_msg; + bullet_speed_ = static_cast(bullet_speed) + bullet_speed_bias_; + if (armors_num == ArmorsNum::OUTPOST_3 || armors_num == ArmorsNum::BASE_1) + { + Averagedistance(px, t_info.x); + Averagedistance(py, t_info.y); + Averagedistance(pz, t_info.z); + Averagedistance(pv, t_info.w_yaw); } - - sort(armor.begin(), armor.end(), cmp); // 根据护甲点的x,y坐标排序 - double rad0 = atan2(armor[0].y, armor[0].x);// 计算排序后的第一个护甲点的航向角 - double rad1 = atan2(armor[1].y, armor[1].x); - double rad = atan2(fy_center, fx_center);// 计算预测的航向角 - if (abs(angles::shortest_angular_distance(rad0, rad)) < abs(angles::shortest_angular_distance(rad1, rad))) + if (armors_num != ArmorsNum::OUTPOST_3 && armors_num != ArmorsNum::BASE_1 + && sqrt(pow(t_info.vx, 2) + pow(t_info.vy, 2) + pow(t_info.vz, 2)) > 0.3) + { + for (int i = 0; i < 2; i++) + { + PredictPosition(); + CompensatePitch(); + } + } + for (int i = 0; i < 4; i++) { - fx = armor[0].x;// 设置预测的x坐标为第一个护甲点的x坐标 - fy = armor[0].y;// 设置预测的y坐标为第一个护甲点的y坐标 - fz = armor[0].z;// 设置预测的z坐标为第一个护甲点的z坐标 - } else + PredictPose(armors_num); + CompensatePitch(); + } + yout = (float) (g_yaw + + angles::shortest_angular_distance(g_yaw * CV_PI / 180, -atan2(fx_center, fy_center)) * 180 / CV_PI); + auto armor_yaw = + (float) (g_yaw + angles::shortest_angular_distance(g_yaw * CV_PI / 180, -atan2(fx, fy)) * 180 / CV_PI); + if (abs(armor_yaw - yout) > 2) { - fx = armor[1].x;// 设置预测的x坐标为第二个护甲点的x坐标 - fy = armor[1].y;// 设置预测的y坐标为第二个护甲点的y坐标 - fz = armor[1].z;// 设置预测的z坐标为第二个护甲点的z坐标 + yaw_difference = DBL_MAX; } + auto difference = yaw_difference; + send_data.pitch = pout; + send_data.yaw = yout; + return difference; } - else { - fx = t_info.x - t_info.radius_1 * cos(t_info.yaw); - fy = t_info.y - t_info.radius_1 * sin(t_info.yaw); - fz = t_info.z; - fx_center = fx; - fy_center = fy; + void Compensator::PredictPosition() + { + fx = t_info.x + tmp_fly_time * t_info.vx - t_info.radius_1 * cos(t_info.yaw); + fy = t_info.y + tmp_fly_time * t_info.vy - t_info.radius_1 * sin(t_info.yaw); + fz = t_info.z + tmp_fly_time * t_info.vz; + } + void Compensator::PredictPose(ArmorsNum &armors_num) + { + if (abs(t_info.w_yaw) < 0.5) + { + if (armors_num == ArmorsNum::OUTPOST_3 || armors_num == ArmorsNum::BASE_1) + { + fx = calculateAverage(px) - t_info.radius_1 * cos(t_info.yaw); + fy = calculateAverage(py) - t_info.radius_1 * sin(t_info.yaw); + fz = calculateAverage(pz); + } + else + { + fx = t_info.x + tmp_fly_time * t_info.vx - t_info.radius_1 * cos(t_info.yaw); + fy = t_info.y + tmp_fly_time * t_info.vy - t_info.radius_1 * sin(t_info.yaw); + fz = t_info.z + tmp_fly_time * t_info.vz; + } + fx_center = fx; + fy_center = fy; + yaw_difference = 0; + } + else + { + float yaw; + if (armors_num == ArmorsNum::OUTPOST_3 || armors_num == ArmorsNum::BASE_1) + { + fx = calculateAverage(px); + fy = calculateAverage(py); + fz = calculateAverage(pz); + fv = calculateAverage(pv); + yaw = t_info.yaw + tmp_fly_time * fv; + } + else + { + fx = t_info.x + tmp_fly_time * t_info.vx; + fy = t_info.y + tmp_fly_time * t_info.vy; + fz = t_info.z + tmp_fly_time * t_info.vz; + yaw = t_info.yaw + tmp_fly_time * t_info.w_yaw; + } + fx_center = fx; + fy_center = fy; + float yaw_center = -atan2(fx_center, fy_center) + CV_PI / 2; + predict_armor armor1, armor2, armor3, armor4; + std::vector armors = {}; + if (armors_num == ArmorsNum::OUTPOST_3) + { + armor1.position.x = fx - t_info.radius_1 * cos(yaw); + armor1.position.y = fy - t_info.radius_1 * sin(yaw); + armor1.position.z = fz; + armor1.yaw = abs(angles::shortest_angular_distance(yaw, yaw_center)); + armor2.position.x = fx - t_info.radius_1 * cos(float(yaw + 2 * CV_PI / 3)); + armor2.position.y = fy - t_info.radius_1 * sin(float(yaw + 2 * CV_PI / 3)); + armor2.position.z = fz; + armor2.yaw = abs(angles::shortest_angular_distance(yaw + 2 * CV_PI / 3, yaw_center)); + armor3.position.x = fx - t_info.radius_1 * sin(float(yaw + 4 * CV_PI / 3)); + armor3.position.y = fy - t_info.radius_1 * cos(float(yaw + 4 * CV_PI / 3)); + armor3.position.z = fz; + armor3.yaw = abs(angles::shortest_angular_distance(yaw + 4 * CV_PI / 3, yaw_center)); + armors.push_back(armor1); + armors.push_back(armor2); + armors.push_back(armor3); + } + else if (armors_num == ArmorsNum::NORMAL_4) + { + armor1.position.x = fx - t_info.radius_1 * cos(yaw); + armor1.position.y = fy - t_info.radius_1 * sin(yaw); + armor1.position.z = fz; + armor1.yaw = abs(angles::shortest_angular_distance(yaw, yaw_center)); + armor2.position.x = fx + t_info.radius_1 * cos(yaw); + armor2.position.y = fy + t_info.radius_1 * sin(yaw); + armor2.position.z = fz; + armor2.yaw = abs(angles::shortest_angular_distance(yaw + CV_PI, yaw_center)); + armor3.position.x = fx - t_info.radius_2 * sin(yaw); + armor3.position.y = fy + t_info.radius_2 * cos(yaw); + armor3.position.z = fz + t_info.dz; + armor3.yaw = abs(angles::shortest_angular_distance(yaw + 3 * CV_PI / 2, yaw_center)); + armor4.position.x = fx + t_info.radius_2 * sin(yaw); + armor4.position.y = fy - t_info.radius_2 * cos(yaw); + armor4.position.z = fz + t_info.dz; + armor4.yaw = abs(angles::shortest_angular_distance(yaw + CV_PI / 2, yaw_center)); + armors.push_back(armor1); + armors.push_back(armor2); + armors.push_back(armor3); + armors.push_back(armor4); + } + else if (armors_num == ArmorsNum::BALANCE_2) + { + armor1.position.x = fx - t_info.radius_1 * cos(yaw); + armor1.position.y = fy - t_info.radius_1 * sin(yaw); + armor1.position.z = fz; + armor1.yaw = abs(angles::shortest_angular_distance(yaw, yaw_center)); + armor2.position.x = fx + t_info.radius_1 * cos(yaw); + armor2.position.y = fy + t_info.radius_1 * sin(yaw); + armor2.position.z = fz; + armor2.yaw = abs(angles::shortest_angular_distance(yaw + CV_PI, yaw_center)); + armors.push_back(armor1); + armors.push_back(armor2); + } + else if (armors_num == ArmorsNum::BASE_1) + { + armor1.position.x = fx - t_info.radius_1 * cos(yaw); + armor1.position.y = fy - t_info.radius_1 * sin(yaw); + armor1.position.z = fz; + armors.push_back(armor1); + } + sort(armors.begin(), armors.end(), cmp); + fx = armors[0].position.x; + fy = armors[0].position.y; + fz = armors[0].position.z; + yaw_difference = armors[0].yaw; + if (armors_num != ArmorsNum::BASE_1 && armors_num != ArmorsNum::OUTPOST_3 && abs(t_info.w_yaw) < 6) + { + fx_center = fx; + fy_center = fy; + yaw_difference = 0; + } + } } -} -// 根据目标位置计算补偿角度和新的飞行时间 void Compensator::CompensatePitch() { - double dist_horizon = sqrt(pow(fx, 2) + pow(fy - imutofrt_y, 2));// 和目标在水平方向上的距离 - double target_height = fz-imutofrt_z; + double dist_horizon = sqrt(pow(fx, 2) + pow(fy - imutofrt_y, 2)); + double target_height = fz - imutofrt_z; // 迭代参数 double vx, vy, fly_time, tmp_height = target_height, delta_height = target_height, tmp_pitch, real_height; int iteration_num = 0; - while ((iteration_num <= 50 && abs(delta_height) >= 0.005) || iteration_num <= 5) { + while ((iteration_num <= 30 && abs(delta_height) >= 0.005) || iteration_num <= 5) + { tmp_pitch = atan((tmp_height) / dist_horizon); - dist_horizon = sqrt(pow(fx, 2) + pow(fy - imutofrt_y * cos(tmp_pitch)+imutofrt_z* sin(tmp_pitch), 2)); - target_height = fz -imutofrt_z * cos(tmp_pitch)-imutofrt_y* sin(tmp_pitch); + dist_horizon = sqrt(pow(fx, 2) + pow(fy - imutofrt_y * cos(tmp_pitch) + imutofrt_z * sin(tmp_pitch), 2)); + target_height = fz - imutofrt_z * cos(tmp_pitch) - imutofrt_y * sin(tmp_pitch); vx = bullet_speed_ * cos(tmp_pitch); vy = bullet_speed_ * sin(tmp_pitch); diff --git a/hnurm_armor/src/Processor.cpp b/hnurm_armor/src/Processor.cpp index 0a289181a7fac937d51427db4012027409a1e66e..cb3556a8aefa294de56f31a9409db26f1c45689c 100755 --- a/hnurm_armor/src/Processor.cpp +++ b/hnurm_armor/src/Processor.cpp @@ -6,163 +6,189 @@ namespace hnurm { -void Processor::ProcessArmor( - std::vector &armors_msg, hnurm_uart::msg::VisionRecvData &recv_data, TargetInfo &target_msg -) -{ - // Transform armor position from image frame to world coordinate - auto now = recv_data.header.stamp; - auto imu_to_gimbal = tf_buffer_->lookupTransform("gimbal_link", "imu_link", now, tf2::durationFromSec(0.1)); - for(auto &armor : armors_msg) + void Processor::ProcessArmor( + std::vector &armors_msg, hnurm_interfaces::msg::VisionRecvData &recv_data, TargetInfo &target_msg + ) { - tsolver->GetTransformation( - armor, - (float)angles::from_degrees(recv_data.pitch), - (float)angles::from_degrees(recv_data.yaw), - imu_to_gimbal - ); + // Transform armor position from image frame to world coordinate + for (auto &armor: armors_msg) + { + tsolver->GetTransformation( + armor, (float) angles::from_degrees(recv_data.pitch), (float) angles::from_degrees(recv_data.yaw) + ); + } + + auto time = std::chrono::steady_clock::now(); + + if (tracker->tracker_state == Tracker::LOST) + { + tracker->init(armors_msg); + } + else + { + dt_ = (double) std::chrono::duration_cast(time - time_elapsed_).count() / 1e6; + tracker->update(armors_msg); + } + time_elapsed_ = time; + const auto state = tracker->target_state; + // clang-format off + target_msg.x = (float) state(0); + target_msg.vx = (float) state(1); + target_msg.y = (float) state(2); + target_msg.vy = (float) state(3); + target_msg.z = (float) state(4); + target_msg.vz = (float) state(5); + target_msg.yaw = (float) state(6); + target_msg.w_yaw = (float) state(7); + target_msg.radius_1 = (float) state(8); + target_msg.radius_2 = (float) tracker->another_r; + target_msg.dz = (float) tracker->dz; + // clang-format on + if (!armors_msg.empty()) + { + if (target_msg.w_yaw < 1) + { + auto gimbal_yaw = recv_data.yaw; + std::sort(armors_msg.begin(), armors_msg.end(), [&](const Armor &armor1, const Armor &armor2) + { + Eigen::Vector3d euler1, euler2; + this->tsolver->rotationMatrixToEulerAngles(armor1.rotation, euler1); + this->tsolver->rotationMatrixToEulerAngles(armor2.rotation, euler2); + return abs(euler1(1) - gimbal_yaw) < abs(euler2(1) - gimbal_yaw); + }); + + target_msg.x = armors_msg[0].position.x(); + target_msg.y = armors_msg[0].position.y(); + target_msg.z = armors_msg[0].position.z(); + } + if (Eigen::Vector3f(target_msg.vx, target_msg.vy, target_msg.vz).norm() < 0.5) + { + target_msg.vx = 0; + target_msg.vy = 0; + target_msg.vz = 0; + } + } } - auto time = std::chrono::steady_clock::now(); - - if(tracker->tracker_state == Tracker::LOST) + Processor::Processor(rclcpp::Node::SharedPtr node) + : node_(node) { - tracker->init(armors_msg); - } - else - { - dt_ = (double)std::chrono::duration_cast(time - time_elapsed_).count() / 1e6; - tracker->update(armors_msg); - } - time_elapsed_ = time; - const auto state = tracker->target_state; - // clang-format off - target_msg.x = (float )state(0); - target_msg.vx = (float )state(1); - target_msg.y = (float )state(2); - target_msg.vy = (float )state(3); - target_msg.z = (float )state(4); - target_msg.vz = (float )state(5); - target_msg.yaw = (float )state(6); - target_msg.w_yaw = (float )state(7); - target_msg.radius_1 = (float )state(8); - target_msg.radius_2 = (float )tracker->another_r; - target_msg.dz = (float )tracker->dz; - // clang-format on -} - -Processor::Processor(rclcpp::Node::SharedPtr node) : node_(node) -{ - dt_ = 0.01; - - tracker = std::make_unique(node_); - tsolver = std::make_unique(node_); - - // EKF - // xa = x_armor, xc = x_robot_center - // state: xc, v_xc, yc, v_yc, za, v_za, yaw, v_yaw, r - // measurement: xa, ya, za, yaw - // f - Process function - auto f = [this](const Eigen::VectorXd &x) { - Eigen::VectorXd x_new = x; - x_new(0) += x(1) * dt_; - x_new(2) += x(3) * dt_; - x_new(4) += x(5) * dt_; - x_new(6) += x(7) * dt_; - return x_new; - }; - - // J_f - Jacobian of process function - auto j_f = [this](const Eigen::VectorXd &) { - Eigen::MatrixXd f(9, 9); - // clang-format off - f << 1, dt_, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, dt_, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, dt_, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, dt_, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1; - // clang-format on - return f; - }; - - // h - Observation function - auto h = [](const Eigen::VectorXd &x) { - Eigen::VectorXd z(4); - double xc = x(0), yc = x(2), yaw = x(6), r = x(8); - z(0) = xc - r * cos(yaw); // xa - z(1) = yc - r * sin(yaw); // ya - z(2) = x(4); // za - z(3) = x(6); // yaw - return z; - }; - // J_h - Jacobian of observation function - auto j_h = [](const Eigen::VectorXd &x) { - Eigen::MatrixXd h(4, 9); - double yaw = x(6), r = x(8); - // clang-format off + dt_ = 0.01; + + tracker = std::make_unique(node_); + tsolver = std::make_unique(node_); + + // EKF + // xa = x_armor, xc = x_robot_center + // state: xc, v_xc, yc, v_yc, za, v_za, yaw, v_yaw, r + // measurement: xa, ya, za, yaw + // f - Process function + auto f = [this](const Eigen::VectorXd &x) + { + Eigen::VectorXd x_new = x; + x_new(0) += x(1) * dt_; + x_new(2) += x(3) * dt_; + x_new(4) += x(5) * dt_; + x_new(6) += x(7) * dt_; + return x_new; + }; + + // J_f - Jacobian of process function + auto j_f = [this](const Eigen::VectorXd &) + { + Eigen::MatrixXd f(9, 9); + // clang-format off + f << 1, dt_, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, dt_, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, dt_, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, dt_, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1; + // clang-format on + return f; + }; + + // h - Observation function + auto h = [](const Eigen::VectorXd &x) + { + Eigen::VectorXd z(4); + double xc = x(0), yc = x(2), yaw = x(6), r = x(8); + z(0) = xc - r * cos(yaw); // xa + z(1) = yc - r * sin(yaw); // ya + z(2) = x(4); // za + z(3) = x(6); // yaw + return z; + }; + // J_h - Jacobian of observation function + auto j_h = [](const Eigen::VectorXd &x) + { + Eigen::MatrixXd h(4, 9); + double yaw = x(6), r = x(8); + // clang-format off // xc v_xc yc v_yc za v_za yaw v_yaw r - h << 1, 0, 0, 0, 0, 0, r*sin(yaw), 0, -cos(yaw), - 0, 0, 1, 0, 0, 0, -r*cos(yaw),0, -sin(yaw), - 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0; - // clang-format on - return h; - }; - - // tracker_config_node["s2_q_xyz"] >> s2qxyz_; - // tracker_config_node["s2_q_yaw"] >> s2qyaw_; - // tracker_config_node["s2_q_r"] >> s2qr_; - s2qxyz_ = node->declare_parameter("processor.tracker.s2_q_xyz", 0.05); - s2qyaw_ = node->declare_parameter("processor.tracker.s2_q_yaw", 5.0); - s2qr_ = node->declare_parameter("processor.tracker.s2_q_r", 80.0); - - // update_Q - process noise covariance matrix - auto u_q = [this]() { - Eigen::MatrixXd q(9, 9); - double t = dt_, x = s2qxyz_, y = s2qyaw_, r = s2qr_; - double q_x_x = pow(t, 4) / 4 * x, q_x_vx = pow(t, 3) / 2 * x, q_vx_vx = pow(t, 2) * x; - double q_y_y = pow(t, 4) / 4 * y, q_y_vy = pow(t, 3) / 2 * x, q_vy_vy = pow(t, 2) * y; - double q_r = pow(t, 4) / 4 * r; - // clang-format off + h << 1, 0, 0, 0, 0, 0, r * sin(yaw), 0, -cos(yaw), + 0, 0, 1, 0, 0, 0, -r * cos(yaw), 0, -sin(yaw), + 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0; + // clang-format on + return h; + }; + + // tracker_config_node["s2_q_xyz"] >> s2qxyz_; + // tracker_config_node["s2_q_yaw"] >> s2qyaw_; + // tracker_config_node["s2_q_r"] >> s2qr_; + s2qxyz_ = node->declare_parameter("processor.tracker.s2_q_xyz", 0.05); + s2qyaw_ = node->declare_parameter("processor.tracker.s2_q_yaw", 5.0); + s2qr_ = node->declare_parameter("processor.tracker.s2_q_r", 80.0); + + // update_Q - process noise covariance matrix + auto u_q = [this]() + { + Eigen::MatrixXd q(9, 9); + double t = dt_, x = s2qxyz_, y = s2qyaw_, r = s2qr_; + double q_x_x = pow(t, 4) / 4 * x, q_x_vx = pow(t, 3) / 2 * x, q_vx_vx = pow(t, 2) * x; + double q_y_y = pow(t, 4) / 4 * y, q_y_vy = pow(t, 3) / 2 * x, q_vy_vy = pow(t, 2) * y; + double q_r = pow(t, 4) / 4 * r; + // clang-format off // xc v_xc yc v_yc za v_za yaw v_yaw r - q << q_x_x, q_x_vx, 0, 0, 0, 0, 0, 0, 0, - q_x_vx, q_vx_vx,0, 0, 0, 0, 0, 0, 0, - 0, 0, q_x_x, q_x_vx, 0, 0, 0, 0, 0, - 0, 0, q_x_vx, q_vx_vx,0, 0, 0, 0, 0, - 0, 0, 0, 0, q_x_x, q_x_vx, 0, 0, 0, - 0, 0, 0, 0, q_x_vx, q_vx_vx,0, 0, 0, - 0, 0, 0, 0, 0, 0, q_y_y, q_y_vy, 0, - 0, 0, 0, 0, 0, 0, q_y_vy, q_vy_vy,0, - 0, 0, 0, 0, 0, 0, 0, 0, q_r; - // clang-format on - return q; - }; - - r_xyz_factor = node->declare_parameter("processor.tracker.r_xyz_factor", 4e-4); - r_yaw = node->declare_parameter("processor.tracker.r_yaw", 5e-3); - - // update_R - measurement noise covariance matrix - auto u_r = [this](const Eigen::VectorXd &z) { - Eigen::DiagonalMatrix r; - double x = r_xyz_factor; - r.diagonal() << abs(x * z[0]), abs(x * z[1]), abs(x * z[2]), r_yaw; - return r; - }; - - // P - error estimate covariance matrix - Eigen::DiagonalMatrix p0; - p0.setIdentity(); - - // init ekf - tracker->ekf = ExtendedKalmanFilter {f, h, j_f, j_h, u_q, u_r, p0}; - - tf_buffer_ = std::make_shared(node_->get_clock()); - tf_listener_ = std::make_shared(*tf_buffer_); -} + q << q_x_x, q_x_vx, 0, 0, 0, 0, 0, 0, 0, + q_x_vx, q_vx_vx, 0, 0, 0, 0, 0, 0, 0, + 0, 0, q_x_x, q_x_vx, 0, 0, 0, 0, 0, + 0, 0, q_x_vx, q_vx_vx, 0, 0, 0, 0, 0, + 0, 0, 0, 0, q_x_x, q_x_vx, 0, 0, 0, + 0, 0, 0, 0, q_x_vx, q_vx_vx, 0, 0, 0, + 0, 0, 0, 0, 0, 0, q_y_y, q_y_vy, 0, + 0, 0, 0, 0, 0, 0, q_y_vy, q_vy_vy, 0, + 0, 0, 0, 0, 0, 0, 0, 0, q_r; + // clang-format on + return q; + }; + + r_xyz_factor = node->declare_parameter("processor.tracker.r_xyz_factor", 4e-4); + r_yaw = node->declare_parameter("processor.tracker.r_yaw", 5e-3); + + // update_R - measurement noise covariance matrix + auto u_r = [this](const Eigen::VectorXd &z) + { + Eigen::DiagonalMatrix r; + double x = r_xyz_factor; + r.diagonal() << abs(x * z[0]), abs(x * z[1]), abs(x * z[2]), r_yaw; + return r; + }; + + // P - error estimate covariance matrix + Eigen::DiagonalMatrix p0; + p0.setIdentity(); + + // init ekf + tracker->ekf = ExtendedKalmanFilter{f, h, j_f, j_h, u_q, u_r, p0}; + + tf_buffer_ = std::make_shared(node_->get_clock()); + tf_listener_ = std::make_shared(*tf_buffer_); + } } // namespace hnurm \ No newline at end of file diff --git a/hnurm_armor/src/armor_node.cpp b/hnurm_armor/src/armor_node.cpp index f2c742be8902438fe947b2060ab1df28faa543af..39ec4f6b82de21777dd9a934492cbb4a342c401b 100644 --- a/hnurm_armor/src/armor_node.cpp +++ b/hnurm_armor/src/armor_node.cpp @@ -5,304 +5,337 @@ #include #include +using namespace std::chrono_literals; + namespace hnurm { -ArmorNode::ArmorNode(const rclcpp::NodeOptions &options) : Node("armor_node", options) -{ - std::string tracker_info_topic = this->declare_parameter("tracker_info_topic", "tracker_info"); - std::string target_topic = this->declare_parameter("target_topic", "target"); - std::string vision_send_topic = this->declare_parameter("vision_send_topic", "vision_send_data"); + ArmorNode::ArmorNode(const rclcpp::NodeOptions &options) + : Node("armor_node", options) + { + std::string tracker_info_topic = this->declare_parameter("tracker_info_topic", "tracker_info"); + std::string target_topic = this->declare_parameter("target_topic", "target"); + std::string vision_send_topic = this->declare_parameter("vision_send_topic", "vision_send_data"); - RCLCPP_INFO(get_logger(), "ArmorNode is running"); - processor_ = std::make_unique(shared_from_this()); - RCLCPP_INFO(get_logger(), "Processor created"); - compensator_ = std::make_unique(shared_from_this()); - RCLCPP_INFO(get_logger(), "Compensator created"); + RCLCPP_INFO(get_logger(), "ArmorNode is running"); + processor_ = std::make_unique(shared_from_this()); + RCLCPP_INFO(get_logger(), "Processor created"); + compensator_ = std::make_unique(shared_from_this()); + RCLCPP_INFO(get_logger(), "Compensator created"); - send_data_pub_ = this->create_publisher(vision_send_topic, rclcpp::ServicesQoS()); + send_data_pub_ + = this->create_publisher(vision_send_topic, rclcpp::ServicesQoS()); - tracker_info_pub_ - = this->create_publisher(tracker_info_topic, rclcpp::SensorDataQoS()); - target_pub_ = this->create_publisher(target_topic, rclcpp::SensorDataQoS()); + tracker_info_pub_ + = this->create_publisher(tracker_info_topic, rclcpp::SensorDataQoS()); + target_pub_ = this->create_publisher(target_topic, rclcpp::SensorDataQoS()); - armor_array_sub_ = this->create_subscription( - "armor", rclcpp::SensorDataQoS(), std::bind(&ArmorNode::armor_array_callback, this, std::placeholders::_1) - ); + armor_array_sub_ = this->create_subscription( + "armor", rclcpp::SensorDataQoS(), std::bind(&ArmorNode::armor_array_callback, this, std::placeholders::_1) + ); - init_markers(); -} + auto using_timer = this->declare_parameter("using_timer", false); + if (using_timer) + timer_ = this->create_wall_timer(1ms, std::bind(&ArmorNode::timer_callback, this)); -void ArmorNode::init_markers() -{ - position_marker_.ns = "position"; - position_marker_.type = visualization_msgs::msg::Marker::SPHERE; - position_marker_.scale.x = position_marker_.scale.y = position_marker_.scale.z = 0.1; - position_marker_.color.a = 1.0; - position_marker_.color.g = 1.0; - linear_v_marker_.type = visualization_msgs::msg::Marker::ARROW; - linear_v_marker_.ns = "linear_v"; - linear_v_marker_.scale.x = 0.03; - linear_v_marker_.scale.y = 0.05; - linear_v_marker_.color.a = 1.0; - linear_v_marker_.color.r = 1.0; - linear_v_marker_.color.g = 1.0; - angular_v_marker_.type = visualization_msgs::msg::Marker::ARROW; - angular_v_marker_.ns = "angular_v"; - angular_v_marker_.scale.x = 0.03; - angular_v_marker_.scale.y = 0.05; - angular_v_marker_.color.a = 1.0; - angular_v_marker_.color.b = 1.0; - angular_v_marker_.color.g = 1.0; - armor_marker_.ns = "armors"; - armor_marker_.type = visualization_msgs::msg::Marker::CUBE; - armor_marker_.scale.x = 0.03; - armor_marker_.scale.z = 0.125; - armor_marker_.color.a = 1.0; - armor_marker_.color.r = 1.0; - std::string topic = this->declare_parameter("marker_topic", "/tracker/marker"); - marker_pub_ = this->create_publisher(topic, 10); -} - -void ArmorNode::armor_array_callback(const hnurm_detect::msg::ArmorArray::SharedPtr msg) -{ - TargetInfo tmp_target; - - auto armors = fromROSMsg(*msg); - - // update processor and tracker - processor_->ProcessArmor(armors, msg->recv_uart, tmp_target); - - // send target info over uart - send_target(tmp_target, msg->recv_uart); - - // publish info and markers - // tracker info - hnurm_armor::msg::TrackerInfo info_msg; - hnurm_armor::msg::Target target_msg; - target_msg.header.stamp = msg->header.stamp; - target_msg.header.frame_id = "odom"; - - info_msg.position_diff = processor_->tracker->info_position_diff; - info_msg.yaw_diff = processor_->tracker->info_yaw_diff; - info_msg.position.x = processor_->tracker->measurement(0); - info_msg.position.y = processor_->tracker->measurement(1); - info_msg.position.z = processor_->tracker->measurement(2); - info_msg.yaw = processor_->tracker->measurement(3); - info_msg.yaw = angles::to_degrees(info_msg.yaw); - info_msg.distance = processor_->tracker->measurement.norm(); - tracker_info_pub_->publish(info_msg); - - if(processor_->tracker->tracker_state == Tracker::DETECTING) + init_markers(); + } + float ArmorNode::calculateAverage(const std::vector &vec) { - target_msg.tracking = false; + int n = vec.size(); + if (n == 0) return 0.0f; + + float sum = 0.0f; + for (float value: vec) + { + sum += value; + } + return sum / n; } - else if(processor_->tracker->tracker_state == Tracker::TRACKING || processor_->tracker->tracker_state == Tracker::TEMP_LOST) + void ArmorNode::Averagedistance(std::vector &p, float value) { - target_msg.tracking = true; - // Fill target message - const auto &state = processor_->tracker->target_state; - target_msg.id = processor_->tracker->tracked_id; - target_msg.armors_num = static_cast(processor_->tracker->tracked_armors_num); - target_msg.position.x = state(0); - target_msg.velocity.x = state(1); - target_msg.position.y = state(2); - target_msg.velocity.y = state(3); - target_msg.position.z = state(4); - target_msg.velocity.z = state(5); - target_msg.yaw = state(6); - target_msg.v_yaw = state(7); - target_msg.radius_1 = state(8); - target_msg.radius_2 = processor_->tracker->another_r; - target_msg.dz = processor_->tracker->dz; + if (p.size() >= 50) + { + p.erase(p.begin()); + } + p.push_back(value); } - target_pub_->publish(target_msg); + void ArmorNode::timer_callback() + { + std::lock_guard lock(mtx); + TargetInfo tmp_target; - publish_markers(target_msg); -} + // update processor and tracker + processor_->ProcessArmor(armors, last_recv_array_.recv_uart, tmp_target); -void ArmorNode::send_target(TargetInfo &target, hnurm_uart::msg::VisionRecvData &uart_msg) -{ - hnurm_uart::msg::VisionSendData send; - send.header.frame_id = "serial_send"; - send.header.stamp = this->now(); - send.control_id = uart_msg.control_id; // copy the control id + // send target info over uart + send_target(tmp_target, last_recv_array_.recv_uart); + } - if(processor_->tracker->tracker_state != Tracker::LOST) + void ArmorNode::init_markers() { - float armor_yaw=compensator_->CalcFinalAngle(target, uart_msg, send, processor_->tracker->tracked_armors_num); - //转的飞快的目标,瞄中间,不跟装甲 - if (abs(target.w_yaw)> 7) { - if (abs(send.yaw - uart_msg.yaw) < 2 && abs(send.pitch - uart_msg.pitch) < 0.5 && abs(send.yaw - armor_yaw) < 2 ) - { - send.target_state.data = hnurm_uart::msg::TargetState::FIRE; - } else - { - send.target_state.data = hnurm_uart::msg::TargetState::CONVERGING; - } - } - //转的不快的目标,跟装甲 - else { - send.yaw = armor_yaw; - if (abs(send.yaw - uart_msg.yaw) < 2 && abs(send.pitch - uart_msg.pitch) < 0.8) - { - send.target_state.data = hnurm_uart::msg::TargetState::FIRE; - } else - { - send.target_state.data = hnurm_uart::msg::TargetState::CONVERGING; - } - } - send.target_distance = Eigen::Vector3f(target.x, target.y, target.z).norm(); - //添加偏置环节 - send.pitch += compensator_->pitch_bias_; - send.pitch += compensator_->pitch_bias_; - send_data_pub_->publish(send); + position_marker_.ns = "position"; + position_marker_.type = visualization_msgs::msg::Marker::SPHERE; + position_marker_.scale.x = position_marker_.scale.y = position_marker_.scale.z = 0.1; + position_marker_.color.a = 1.0; + position_marker_.color.g = 1.0; + linear_v_marker_.type = visualization_msgs::msg::Marker::ARROW; + linear_v_marker_.ns = "linear_v"; + linear_v_marker_.scale.x = 0.03; + linear_v_marker_.scale.y = 0.05; + linear_v_marker_.color.a = 1.0; + linear_v_marker_.color.r = 1.0; + linear_v_marker_.color.g = 1.0; + angular_v_marker_.type = visualization_msgs::msg::Marker::ARROW; + angular_v_marker_.ns = "angular_v"; + angular_v_marker_.scale.x = 0.03; + angular_v_marker_.scale.y = 0.05; + angular_v_marker_.color.a = 1.0; + angular_v_marker_.color.b = 1.0; + angular_v_marker_.color.g = 1.0; + armor_marker_.ns = "armors"; + armor_marker_.type = visualization_msgs::msg::Marker::CUBE; + armor_marker_.scale.x = 0.03; + armor_marker_.scale.z = 0.125; + armor_marker_.color.a = 1.0; + armor_marker_.color.r = 1.0; + std::string topic = this->declare_parameter("marker_topic", "/tracker/marker"); + marker_pub_ = this->create_publisher(topic, 10); } - else + + void ArmorNode::armor_array_callback(const hnurm_interfaces::msg::ArmorArray::SharedPtr msg) { - send.target_state.data = hnurm_uart::msg::TargetState::LOST_TARGET; - send_data_pub_->publish(send); - } -} + std::lock_guard lock(mtx); + last_recv_array_ = *msg; -void ArmorNode::publish_markers(hnurm_armor::msg::Target &target_msg) -{ - position_marker_.header = target_msg.header; - linear_v_marker_.header = target_msg.header; - angular_v_marker_.header = target_msg.header; - armor_marker_.header = target_msg.header; + TargetInfo tmp_target; + + armors = fromROSMsg(*msg); + + // update processor and tracker + processor_->ProcessArmor(armors, msg->recv_uart, tmp_target); + + // send target info over uart + send_target(tmp_target, msg->recv_uart); + + // publish info and markers + // tracker info + hnurm_interfaces::msg::TrackerInfo info_msg; + hnurm_interfaces::msg::Target target_msg; + target_msg.header.stamp = msg->header.stamp; + target_msg.header.frame_id = "odom"; - visualization_msgs::msg::MarkerArray marker_array; - if(target_msg.tracking) + info_msg.position_diff = processor_->tracker->info_position_diff; + info_msg.yaw_diff = processor_->tracker->info_yaw_diff; + info_msg.position.x = processor_->tracker->measurement(0); + info_msg.position.y = processor_->tracker->measurement(1); + info_msg.position.z = processor_->tracker->measurement(2); + info_msg.yaw = processor_->tracker->measurement(3); + info_msg.yaw = angles::to_degrees(info_msg.yaw); + info_msg.distance = processor_->tracker->measurement.norm(); + tracker_info_pub_->publish(info_msg); + + if (processor_->tracker->tracker_state == Tracker::DETECTING) + { + target_msg.tracking = false; + } + else if (processor_->tracker->tracker_state == Tracker::TRACKING + || processor_->tracker->tracker_state == Tracker::TEMP_LOST) + { + target_msg.tracking = true; + // Fill target message + const auto &state = processor_->tracker->target_state; + Averagedistance(pv, state(7)); + target_msg.id = processor_->tracker->tracked_id; + target_msg.armors_num = static_cast(processor_->tracker->tracked_armors_num); + target_msg.position.x = state(0); + target_msg.velocity.x = state(1); + target_msg.position.y = state(2); + target_msg.velocity.y = state(3); + target_msg.position.z = state(4); + target_msg.velocity.z = state(5); + target_msg.yaw = state(6); + target_msg.v_yaw = calculateAverage(pv); + target_msg.radius_1 = state(8); + target_msg.radius_2 = processor_->tracker->another_r; + target_msg.dz = processor_->tracker->dz; + target_msg.armor_pitch = processor_->tracker->armor_pitch; + target_msg.armor_yaw = processor_->tracker->armor_yaw; + } + if (!armors.empty()) + { + target_pub_->publish(target_msg); + } + + publish_markers(target_msg); + } + + void ArmorNode::send_target(TargetInfo &target, hnurm_interfaces::msg::VisionRecvData &uart_msg) { - double yaw = target_msg.yaw, r1 = target_msg.radius_1, r2 = target_msg.radius_2; - double xc = target_msg.position.x, yc = target_msg.position.y, za = target_msg.position.z; - double vx = target_msg.velocity.x, vy = target_msg.velocity.y, vz = target_msg.velocity.z; - double dz = target_msg.dz; - - position_marker_.action = visualization_msgs::msg::Marker::ADD; - position_marker_.pose.position.x = xc; - position_marker_.pose.position.y = yc; - position_marker_.pose.position.z = za + dz / 2; - - linear_v_marker_.action = visualization_msgs::msg::Marker::ADD; - linear_v_marker_.points.clear(); - linear_v_marker_.points.emplace_back(position_marker_.pose.position); - geometry_msgs::msg::Point arrow_end = position_marker_.pose.position; - arrow_end.x += vx; - arrow_end.y += vy; - arrow_end.z += vz; - linear_v_marker_.points.emplace_back(arrow_end); - - angular_v_marker_.action = visualization_msgs::msg::Marker::ADD; - angular_v_marker_.points.clear(); - angular_v_marker_.points.emplace_back(position_marker_.pose.position); - arrow_end = position_marker_.pose.position; - arrow_end.z += target_msg.v_yaw / M_PI; - angular_v_marker_.points.emplace_back(arrow_end); - - armor_marker_.action = visualization_msgs::msg::Marker::ADD; - armor_marker_.scale.y = processor_->tracker->tracked_armor.armor_type == ArmorType::SMALL ? 0.135 : 0.23; - bool is_current_pair = true; - size_t a_n = target_msg.armors_num; - geometry_msgs::msg::Point p_a; - double r = 0; - for(size_t i = 0; i < a_n; i++) + hnurm_interfaces::msg::VisionSendData send; + send.header.frame_id = "serial_send"; + send.header.stamp = this->now(); + send.control_id = uart_msg.control_id; // copy the control id + if (processor_->tracker->tracker_state != Tracker::LOST && processor_->tracker->tracker_state != Tracker::JUMP) { - double tmp_yaw = yaw + i * (2 * M_PI / a_n); - // Only 4 armors has 2 radius and height - if(a_n == 4) + float armor_yaw = + compensator_->CalcFinalAngle(target, uart_msg, send, processor_->tracker->tracked_armors_num); + if (abs(send.yaw - uart_msg.yaw) < 1 && abs(send.pitch - uart_msg.pitch) < 0.5 && armor_yaw < 30) { - r = is_current_pair ? r1 : r2; - p_a.z = za + (is_current_pair ? 0 : dz); - is_current_pair = !is_current_pair; + send.target_state.data = hnurm_interfaces::msg::TargetState::FIRE; } else { - r = r1; - p_a.z = za; + send.target_state.data = hnurm_interfaces::msg::TargetState::CONVERGING; } - p_a.x = xc - r * cos(tmp_yaw); - p_a.y = yc - r * sin(tmp_yaw); - - armor_marker_.id = i; - armor_marker_.pose.position = p_a; - tf2::Quaternion q; - q.setRPY(0, target_msg.id == "outpost" ? -0.26 : 0.26, tmp_yaw); - armor_marker_.pose.orientation = tf2::toMsg(q); - marker_array.markers.emplace_back(armor_marker_); + send.target_distance = Eigen::Vector3f(target.x, target.y, target.z).norm(); + send_data_pub_->publish(send); + } + else + { + send.target_state.data = hnurm_interfaces::msg::TargetState::LOST_TARGET; + send_data_pub_->publish(send); } } - else + + void ArmorNode::publish_markers(hnurm_interfaces::msg::Target &target_msg) { - position_marker_.action = visualization_msgs::msg::Marker::DELETE; - linear_v_marker_.action = visualization_msgs::msg::Marker::DELETE; - angular_v_marker_.action = visualization_msgs::msg::Marker::DELETE; + position_marker_.header = target_msg.header; + linear_v_marker_.header = target_msg.header; + angular_v_marker_.header = target_msg.header; + armor_marker_.header = target_msg.header; - armor_marker_.action = visualization_msgs::msg::Marker::DELETE; - marker_array.markers.emplace_back(armor_marker_); - } + visualization_msgs::msg::MarkerArray marker_array; + if (target_msg.tracking) + { + double yaw = target_msg.yaw, r1 = target_msg.radius_1, r2 = target_msg.radius_2; + double xc = target_msg.position.x, yc = target_msg.position.y, za = target_msg.position.z; + double vx = target_msg.velocity.x, vy = target_msg.velocity.y, vz = target_msg.velocity.z; + double dz = target_msg.dz; + + position_marker_.action = visualization_msgs::msg::Marker::ADD; + position_marker_.pose.position.x = xc; + position_marker_.pose.position.y = yc; + position_marker_.pose.position.z = za + dz / 2; + + linear_v_marker_.action = visualization_msgs::msg::Marker::ADD; + linear_v_marker_.points.clear(); + linear_v_marker_.points.emplace_back(position_marker_.pose.position); + geometry_msgs::msg::Point arrow_end = position_marker_.pose.position; + arrow_end.x += vx; + arrow_end.y += vy; + arrow_end.z += vz; + linear_v_marker_.points.emplace_back(arrow_end); + + angular_v_marker_.action = visualization_msgs::msg::Marker::ADD; + angular_v_marker_.points.clear(); + angular_v_marker_.points.emplace_back(position_marker_.pose.position); + arrow_end = position_marker_.pose.position; + arrow_end.z += target_msg.v_yaw / M_PI; + angular_v_marker_.points.emplace_back(arrow_end); + + armor_marker_.action = visualization_msgs::msg::Marker::ADD; + armor_marker_.scale.y = processor_->tracker->tracked_armor.armor_type == ArmorType::SMALL ? 0.135 : 0.23; + bool is_current_pair = true; + size_t a_n = target_msg.armors_num; + geometry_msgs::msg::Point p_a; + double r = 0; + for (size_t i = 0; i < a_n; i++) + { + double tmp_yaw = yaw + i * (2 * M_PI / a_n); + // Only 4 armors has 2 radius and height + if (a_n == 4) + { + r = is_current_pair ? r1 : r2; + p_a.z = za + (is_current_pair ? 0 : dz); + is_current_pair = !is_current_pair; + } + else + { + r = r1; + p_a.z = za; + } + p_a.x = xc - r * cos(tmp_yaw); + p_a.y = yc - r * sin(tmp_yaw); + + armor_marker_.id = i; + armor_marker_.pose.position = p_a; + tf2::Quaternion q; + q.setRPY(0, target_msg.id == "outpost" ? -0.26 : 0.26, tmp_yaw); + armor_marker_.pose.orientation = tf2::toMsg(q); + marker_array.markers.emplace_back(armor_marker_); + } + } + else + { + position_marker_.action = visualization_msgs::msg::Marker::DELETE; + linear_v_marker_.action = visualization_msgs::msg::Marker::DELETE; + angular_v_marker_.action = visualization_msgs::msg::Marker::DELETE; + + armor_marker_.action = visualization_msgs::msg::Marker::DELETE; + marker_array.markers.emplace_back(armor_marker_); + } - marker_array.markers.emplace_back(position_marker_); - marker_array.markers.emplace_back(linear_v_marker_); - marker_array.markers.emplace_back(angular_v_marker_); - marker_pub_->publish(marker_array); -} + marker_array.markers.emplace_back(position_marker_); + marker_array.markers.emplace_back(linear_v_marker_); + marker_array.markers.emplace_back(angular_v_marker_); + marker_pub_->publish(marker_array); + } -std::vector fromROSMsg(const hnurm_detect::msg::ArmorArray &msg) -{ - std::vector armors; - armors.resize(msg.armors.size()); - for(size_t i = 0; i < msg.armors.size(); i++) + std::vector fromROSMsg(const hnurm_interfaces::msg::ArmorArray &msg) { - armors[i].left_light.color = msg.armors[i].left_light.color; - armors[i].left_light.top.x = msg.armors[i].left_light.top.x; - armors[i].left_light.top.y = msg.armors[i].left_light.top.y; - armors[i].left_light.center.x = msg.armors[i].left_light.center.x; - armors[i].left_light.center.y = msg.armors[i].left_light.center.y; - armors[i].left_light.bottom.x = msg.armors[i].left_light.bottom.x; - armors[i].left_light.bottom.y = msg.armors[i].left_light.bottom.y; - armors[i].left_light.size.width = msg.armors[i].left_light.size.x; - armors[i].left_light.size.height = msg.armors[i].left_light.size.y; - armors[i].left_light.length = msg.armors[i].left_light.length; - armors[i].left_light.width = msg.armors[i].left_light.width; - armors[i].left_light.tilt_angle = msg.armors[i].left_light.tilt_angle; - armors[i].left_light.angle = msg.armors[i].left_light.angle; - - armors[i].right_light.color = msg.armors[i].right_light.color; - armors[i].right_light.top.x = msg.armors[i].right_light.top.x; - armors[i].right_light.top.y = msg.armors[i].right_light.top.y; - armors[i].right_light.center.x = msg.armors[i].right_light.center.x; - armors[i].right_light.center.y = msg.armors[i].right_light.center.y; - armors[i].right_light.bottom.x = msg.armors[i].right_light.bottom.x; - armors[i].right_light.bottom.y = msg.armors[i].right_light.bottom.y; - armors[i].right_light.size.width = msg.armors[i].right_light.size.x; - armors[i].right_light.size.height = msg.armors[i].right_light.size.y; - armors[i].right_light.length = msg.armors[i].right_light.length; - armors[i].right_light.width = msg.armors[i].right_light.width; - armors[i].right_light.tilt_angle = msg.armors[i].right_light.tilt_angle; - armors[i].right_light.angle = msg.armors[i].right_light.angle; - - armors[i].center.x = msg.armors[i].center.x; - armors[i].center.y = msg.armors[i].center.y; - - armors[i].points2d.resize(msg.armors[i].points2d.size()); - for(size_t j = 0; j < msg.armors[i].points2d.size(); j++) + std::vector armors; + armors.resize(msg.armors.size()); + for (size_t i = 0; i < msg.armors.size(); i++) { - armors[i].points2d[j].x = msg.armors[i].points2d[j].x; - armors[i].points2d[j].y = msg.armors[i].points2d[j].y; + armors[i].left_light.color = msg.armors[i].left_light.color; + armors[i].left_light.top.x = msg.armors[i].left_light.top.x; + armors[i].left_light.top.y = msg.armors[i].left_light.top.y; + armors[i].left_light.center.x = msg.armors[i].left_light.center.x; + armors[i].left_light.center.y = msg.armors[i].left_light.center.y; + armors[i].left_light.bottom.x = msg.armors[i].left_light.bottom.x; + armors[i].left_light.bottom.y = msg.armors[i].left_light.bottom.y; + armors[i].left_light.size.width = msg.armors[i].left_light.size.x; + armors[i].left_light.size.height = msg.armors[i].left_light.size.y; + armors[i].left_light.length = msg.armors[i].left_light.length; + armors[i].left_light.width = msg.armors[i].left_light.width; + armors[i].left_light.tilt_angle = msg.armors[i].left_light.tilt_angle; + armors[i].left_light.angle = msg.armors[i].left_light.angle; + + armors[i].right_light.color = msg.armors[i].right_light.color; + armors[i].right_light.top.x = msg.armors[i].right_light.top.x; + armors[i].right_light.top.y = msg.armors[i].right_light.top.y; + armors[i].right_light.center.x = msg.armors[i].right_light.center.x; + armors[i].right_light.center.y = msg.armors[i].right_light.center.y; + armors[i].right_light.bottom.x = msg.armors[i].right_light.bottom.x; + armors[i].right_light.bottom.y = msg.armors[i].right_light.bottom.y; + armors[i].right_light.size.width = msg.armors[i].right_light.size.x; + armors[i].right_light.size.height = msg.armors[i].right_light.size.y; + armors[i].right_light.length = msg.armors[i].right_light.length; + armors[i].right_light.width = msg.armors[i].right_light.width; + armors[i].right_light.tilt_angle = msg.armors[i].right_light.tilt_angle; + armors[i].right_light.angle = msg.armors[i].right_light.angle; + + armors[i].center.x = msg.armors[i].center.x; + armors[i].center.y = msg.armors[i].center.y; + + armors[i].points2d.resize(msg.armors[i].points2d.size()); + for (size_t j = 0; j < msg.armors[i].points2d.size(); j++) + { + armors[i].points2d[j].x = msg.armors[i].points2d[j].x; + armors[i].points2d[j].y = msg.armors[i].points2d[j].y; + } + + armors[i].number_img + = cv_bridge::toCvCopy(msg.armors[i].number_img, sensor_msgs::image_encodings::MONO8)->image; + armors[i].number = msg.armors[i].number; + armors[i].idx = msg.armors[i].idx; + armors[i].similarity = msg.armors[i].similarity; + armors[i].confidence = msg.armors[i].confidence; + armors[i].classification_result = msg.armors[i].classification_result; + armors[i].armor_type = ArmorType(msg.armors[i].armor_type.data); } - armors[i].number_img - = cv_bridge::toCvCopy(msg.armors[i].number_img, sensor_msgs::image_encodings::MONO8)->image; - armors[i].number = msg.armors[i].number; - armors[i].idx = msg.armors[i].idx; - armors[i].similarity = msg.armors[i].similarity; - armors[i].confidence = msg.armors[i].confidence; - armors[i].classification_result = msg.armors[i].classification_result; - armors[i].armor_type = ArmorType(msg.armors[i].armor_type.data); + return armors; } - return armors; -} - } // namespace hnurm \ No newline at end of file diff --git a/hnurm_armor/src/main.cpp b/hnurm_armor/src/main.cpp index ba25f4e546907c06015cf12f62e0e92d61ea7e96..22b25ca001c76f69fc3df8430a7c0ce675ffbc09 100644 --- a/hnurm_armor/src/main.cpp +++ b/hnurm_armor/src/main.cpp @@ -5,6 +5,9 @@ int main(int argc, char *argv[]) rclcpp::init(argc, argv); rclcpp::NodeOptions options; auto node = std::make_shared(options); - rclcpp::spin(node); + // rclcpp::spin(node); + rclcpp::executors::MultiThreadedExecutor executor; + executor.add_node(node); + executor.spin(); rclcpp::shutdown(); } \ No newline at end of file diff --git a/hnurm_armor/src/solvePnPBA.cpp b/hnurm_armor/src/solvePnPBA.cpp deleted file mode 100644 index da98abd6bf77f647393c26a0f96a31afe006a8b2..0000000000000000000000000000000000000000 --- a/hnurm_armor/src/solvePnPBA.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// Created by Kai Wang on 24-3-14. -// - -#include "solvePnPBA/solvePnPBA.h" - -void bundleAdjustmentG2O( - const VecVector3d &points_3d, const VecVector2d &points_2d, const cv::Mat &K, Sophus::SE3d &pose) -{ - - using BlockSolverType = g2o::BlockSolver>; - using LinearSolverType = g2o::LinearSolverDense; - - // GN, LM, DogLeg - auto solver = new g2o::OptimizationAlgorithmGaussNewton( - g2o::make_unique(g2o::make_unique())); - g2o::SparseOptimizer optimizer; - optimizer.setAlgorithm(solver); - optimizer.setVerbose(true); - - // vertex - auto *vertex_pose = new VertexPose();// camera vertex_pose - vertex_pose->setId(0); - vertex_pose->setEstimate(pose); - optimizer.addVertex(vertex_pose); - - // K - Eigen::Matrix3d K_eigen; - cv::cv2eigen(K, K_eigen); - - // edges - int index = 1; - for (size_t i = 0; i < points_2d.size(); ++i) - { - const auto &p2d = points_2d[i]; - const auto &p3d = points_3d[i]; - auto *edge = new EdgeProjection(p3d, K_eigen); - edge->setId(index); - edge->setVertex(0, vertex_pose); - edge->setMeasurement(p2d); - edge->setInformation(Eigen::Matrix2d::Identity()); - optimizer.addEdge(edge); - index++; - } - - TIMEIT(optimizer.initializeOptimization(); optimizer.optimize(16);); - pose = vertex_pose->estimate(); -} - -bool solvePnPBA( - cv::InputArray object_points, - cv::InputArray image_points, - cv::InputArray cameraMatrix, - cv::InputArray distCoeffs, - cv::OutputArray rvec, - cv::OutputArray tvec, - bool useExtrinsicGuess) -{ - (void) distCoeffs; - (void) useExtrinsicGuess; - - cv::Mat obj_mat; - cv::Mat img_mat; - - object_points.getMat().convertTo(obj_mat, CV_64F); - image_points.getMat().convertTo(img_mat, CV_64F); - - std::cout << "obj mat\n" - << obj_mat << "\n" - << "sz" << obj_mat.size << "\n"; - std::cout << "img mat\n" - << img_mat << "\n" - << "sz" << img_mat.size << "\n"; - - VecVector3d obj_points_vec; - VecVector2d img_points_vec; - for (int i = 0; i < 4; i++) - { - obj_points_vec.emplace_back(obj_mat.at(i * 3), obj_mat.at(i * 3 + 1), obj_mat.at(i * 3 + 2)); - img_points_vec.emplace_back(img_mat.at(i * 2), img_mat.at(i * 2 + 1)); - } - - Sophus::SE3d pose; - if (useExtrinsicGuess) - { - Eigen::Vector3f init_tvec, init_rvec; - cv::cv2eigen(tvec.getMat(), init_tvec); - cv::cv2eigen(rvec.getMat(), init_rvec); - - pose.translation() = init_tvec.cast(); - pose.so3() = Sophus::SO3d::exp(init_rvec.cast()); - } - - // do bundle adjustment - bundleAdjustmentG2O(obj_points_vec, img_points_vec, cameraMatrix.getMat(), pose); - - // get results - rvec.create(3, 1, CV_64F); - tvec.create(3, 1, CV_64F); - cv::eigen2cv(pose.so3().log(), rvec.getMat()); - cv::eigen2cv(pose.translation(), tvec.getMat()); - - return true; -} diff --git a/hnurm_armor/src/tracker.cpp b/hnurm_armor/src/tracker.cpp index 92581b2133429fec01e9bbe0512c7675ea7e9945..068fac583223afd250fa52ad26d28afb57110bd7 100755 --- a/hnurm_armor/src/tracker.cpp +++ b/hnurm_armor/src/tracker.cpp @@ -14,89 +14,89 @@ namespace hnurm { -Tracker::Tracker(rclcpp::Node::SharedPtr node) -{ - tracker_state = LOST; - tracked_id = std::string(""); - target_state = Eigen::VectorXd::Zero(9); - - max_match_distance_ = node->declare_parameter("processor.tracker.max_match_distance", 0.5); - max_match_yaw_diff_ = node->declare_parameter("processor.tracker.max_match_yaw_diff", 0.5); - tracking_threshold_ = node->declare_parameter("processor.tracker.tracking_threshold", 0.0); - lost_threshold_ = node->declare_parameter("processor.tracker.lost_threshold", 15.0); - - measurement = Eigen::Vector4d::Zero(); -} - -Tracker::Tracker(double max_match_distance, int tracking_threshold, int lost_threshold) - : tracker_state(LOST), - tracked_id(std::string("")), - target_state(Eigen::VectorXd::Zero(9)), - max_match_distance_(max_match_distance), - tracking_threshold_(tracking_threshold), - lost_threshold_(lost_threshold) -{ -} + Tracker::Tracker(rclcpp::Node::SharedPtr node) + { + tracker_state = LOST; + tracked_id = std::string(""); + target_state = Eigen::VectorXd::Zero(9); -void Tracker::init(const std::vector &armors_msg) -{ - if(armors_msg.empty()) + max_match_distance_ = node->declare_parameter("processor.tracker.max_match_distance", 0.5); + max_match_yaw_diff_ = node->declare_parameter("processor.tracker.max_match_yaw_diff", 0.5); + tracking_threshold_ = node->declare_parameter("processor.tracker.tracking_threshold", 0.0); + lost_threshold_ = node->declare_parameter("processor.tracker.lost_threshold", 100.0); + + measurement = Eigen::Vector4d::Zero(); + } + + Tracker::Tracker(double max_match_distance, int tracking_threshold, int lost_threshold) + : tracker_state(LOST), + tracked_id(std::string("")), + target_state(Eigen::VectorXd::Zero(9)), + max_match_distance_(max_match_distance), + tracking_threshold_(tracking_threshold), + lost_threshold_(lost_threshold) { - return; } - // Simply choose the armor that is closest to image center - auto min_distance = DBL_MAX; - tracked_armor = armors_msg[0]; - for(const auto &armor : armors_msg) + + void Tracker::init(const std::vector &armors_msg) { - if(armor.distance_to_image_center < min_distance) + if (armors_msg.empty()) { - min_distance = armor.distance_to_image_center; - tracked_armor = armor; + return; + } + // Simply choose the armor that is closest to image center + auto min_distance = DBL_MAX; + tracked_armor = armors_msg[0]; + for (const auto &armor: armors_msg) + { + if (armor.distance_to_image_center < min_distance) + { + min_distance = armor.distance_to_image_center; + tracked_armor = armor; + } } - } - - initEKF(tracked_armor); - - tracked_id = tracked_armor.number; - tracker_state = DETECTING; - updateArmorsNum(tracked_armor); -} + initEKF(tracked_armor); -void Tracker::update(const std::vector &armors_msg) -{ - // KF predict - Eigen::VectorXd ekf_prediction = ekf.predict(); - // RCLCPP_DEBUG(rclcpp::get_logger("armor_processor"), "EKF predict"); + tracked_id = tracked_armor.number; + tracker_state = DETECTING; - bool matched = false; - // Use KF prediction as default target state if no matched armor is found - target_state = ekf_prediction; + updateArmorsNum(tracked_armor); + } - if (!armors_msg.empty()) + void Tracker::update(const std::vector &armors_msg) { - auto min_position_diff = DBL_MAX; - auto yaw_diff = DBL_MAX; + // KF predict + Eigen::VectorXd ekf_prediction = ekf.predict(); + // RCLCPP_DEBUG(rclcpp::get_logger("armor_processor"), "EKF predict"); + + bool matched = false; + // Use KF prediction as default target state if no matched armor is found + target_state = ekf_prediction; - auto predicted_position = getArmorPositionFromState(ekf_prediction); - for (const auto &armor : armors_msg) + if (!armors_msg.empty()) { - // 仅考虑相同ID的装甲板 - if (armor.number == tracked_id) + auto min_position_diff = DBL_MAX; + auto yaw_diff = DBL_MAX; + + auto predicted_position = getArmorPositionFromState(ekf_prediction); + for (const auto &armor: armors_msg) { - auto p = armor.position; - // 当前装甲板位置与跟踪装甲板的预测位置的差异 - double position_diff = (predicted_position - p).norm(); - if (position_diff < min_position_diff) + // 仅考虑相同ID的装甲板 + if (armor.number == tracked_id) { - min_position_diff = position_diff; - // 计算当前装甲板的姿态与EKF预测的姿态之间的差异 - yaw_diff = abs(orientationToYaw(armor.rotation) - ekf_prediction(6)); - tracked_armor = armor; + auto p = armor.position; + // 当前装甲板位置与跟踪装甲板的预测位置的差异 + double position_diff = (predicted_position - p).norm(); + if (position_diff < min_position_diff) + { + min_position_diff = position_diff; + // 计算当前装甲板的姿态与EKF预测的姿态之间的差异 + yaw_diff = abs(orientationToYaw(armor.rotation) - ekf_prediction(6)); + tracked_armor = armor; + } } } - } // 保存差异信息 info_position_diff = min_position_diff; info_yaw_diff = yaw_diff; @@ -115,152 +115,192 @@ void Tracker::update(const std::vector &armors_msg) { // 处理装甲板跳变情况 handleArmorJump(tracked_armor); + if (tracker_state == TRACKING) + { + tracker_state = JUMP; + } } else { // 装甲板未匹配,追踪状态设置为丢失 tracker_state = LOST; } - } + } - // Prevent radius from spreading - target_state(8) = CLAMP(target_state(8), 0.14, 0.33); - another_r = CLAMP(another_r, 0.14, 0.33); - // Tracking state machine - if(tracker_state == DETECTING) - { - if(matched) + // Prevent radius from spreading + target_state(8) = CLAMP(target_state(8), 0.14, 0.33); + another_r = CLAMP(another_r, 0.14, 0.33); + // Tracking state machine + if (tracker_state == DETECTING) { - detect_count_++; - if(detect_count_ > tracking_threshold_) + if (matched) + { + detect_count_++; + if (detect_count_ > tracking_threshold_) + { + detect_count_ = 0; + tracker_state = TRACKING; + } + } + else { detect_count_ = 0; - tracker_state = TRACKING; + tracker_state = LOST; } } - else + else if (tracker_state == TRACKING || tracker_state == JUMP) { - detect_count_ = 0; - tracker_state = LOST; - } - } - else if(tracker_state == TRACKING) - { - if(!matched) - { - tracker_state = TEMP_LOST; - lost_count_++; - } - } - else if(tracker_state == TEMP_LOST) - { - if(!matched) - { - lost_count_++; - if(lost_count_ > lost_threshold_) + if (!matched && tracker_state != JUMP) { - lost_count_ = 0; - tracker_state = LOST; + tracker_state = TEMP_LOST; + lost_count_++; + } + if (matched && tracker_state == JUMP) + { + tracker_state = TRACKING; + } + if (!matched && tracker_state == JUMP) + { + lost_count_++; + if (lost_count_ > lost_threshold_) + { + lost_count_ = 0; + tracker_state = LOST; + } } } - else + else if (tracker_state == TEMP_LOST) { - tracker_state = TRACKING; - lost_count_ = 0; + if (!matched) + { + lost_count_++; + if (lost_count_ > lost_threshold_) + { + lost_count_ = 0; + tracker_state = LOST; + } + } + else + { + tracker_state = TRACKING; + lost_count_ = 0; + } } } -} -void Tracker::initEKF(const Armor &a) -{ - double xa = a.position(0); - double ya = a.position(1); - double za = a.position(2); - last_yaw_ = 0; - // todo - double yaw = orientationToYaw(a.rotation); - - // Set initial position at 0.2m behind the target - target_state = Eigen::VectorXd::Zero(9); - double r = 0.20; - double xc = xa + r * cos(yaw); - double yc = ya + r * sin(yaw); - dz = 0, another_r = r; - target_state << xc, 0, yc, 0, za, 0, yaw, 0, r; - - ekf.setState(target_state); - // RCLCPP_DEBUG(rclcpp::get_logger("armor_processor"), "Init EKF!"); -} - -void Tracker::handleArmorJump(const Armor &a) -{ - // todo - double yaw = orientationToYaw(a.rotation); - target_state(6) = yaw; + void Tracker::initEKF(const Armor &a) + { + double xa = a.position(0); + double ya = a.position(1); + double za = a.position(2); + last_yaw_ = 0; + // todo + double yaw = orientationToYaw(a.rotation); - updateArmorsNum(a); + // Set initial position at 0.2m behind the target + target_state = Eigen::VectorXd::Zero(9); + double r = 0.20; + double xc = xa + r * cos(yaw); + double yc = ya + r * sin(yaw); + dz = 0, another_r = r; + target_state << xc, 0, yc, 0, za, 0, yaw, 0, r; - if(tracked_armors_num == ArmorsNum::NORMAL_4) - { - dz = target_state(4) - a.position(2); - target_state(4) = a.position(2); - std::swap(target_state(8), another_r); + ekf.setState(target_state); + // RCLCPP_DEBUG(rclcpp::get_logger("armor_processor"), "Init EKF!"); } - auto p = a.position; + void Tracker::handleArmorJump(const Armor &a) + { + // todo + double yaw = orientationToYaw(a.rotation); + target_state(6) = yaw; - Eigen::Vector3d infer_p = getArmorPositionFromState(target_state); + updateArmorsNum(a); - if((p - infer_p).norm() > max_match_distance_) - { - double r = target_state(8); - target_state(0) = p(0) + r * cos(yaw); // xc - target_state(1) = 0; // vxc - target_state(2) = p(1) + r * sin(yaw); // yc - target_state(3) = 0; // vyc - target_state(4) = p(2); // za - target_state(5) = 0; // vza - // CLOG(WARNING, "process") << "Reset state!"; - RCLCPP_WARN(rclcpp::get_logger("armor_processor"), "Reset state!"); - } + if (tracked_armors_num == ArmorsNum::NORMAL_4) + { + dz = target_state(4) - a.position(2); + target_state(4) = a.position(2); + std::swap(target_state(8), another_r); + } - ekf.setState(target_state); -} + auto p = a.position; -// todo Get armor yaw -double Tracker::orientationToYaw(const Eigen::Matrix3d &R) -{ - double yaw = atan2(R(1, 1), R(0, 1)); - armor_pitch=atan2(R(2,2),R(1,2))/CV_PI*180; - yaw = last_yaw_ + angles::shortest_angular_distance(last_yaw_, yaw); - last_yaw_ = yaw; - return yaw; -} - -Eigen::Vector3d Tracker::getArmorPositionFromState(const Eigen::VectorXd &x) -{ - // Calculate predicted position of the current armor - double xc = x(0), yc = x(2), zc = x(4); - double yaw = x(6), r = x(8); - double xa = xc - r * cos(yaw); - double ya = yc - r * sin(yaw); - return {xa, ya, zc}; -} - -void Tracker::updateArmorsNum(const Armor &armor) -{ - if(armor.armor_type == LARGE && (tracked_id == "3" || tracked_id == "4" || tracked_id == "5")) + Eigen::Vector3d infer_p = getArmorPositionFromState(target_state); + + if ((p - infer_p).norm() > max_match_distance_) + { + double r = target_state(8); + target_state(0) = p(0) + r * cos(yaw); // xc + target_state(1) = 0; // vxc + target_state(2) = p(1) + r * sin(yaw); // yc + target_state(3) = 0; // vyc + target_state(4) = p(2); // za + target_state(5) = 0; // vza + // CLOG(WARNING, "process") << "Reset state!"; + RCLCPP_WARN(rclcpp::get_logger("armor_processor"), "Reset state!"); + } + + ekf.setState(target_state); + } + + double Tracker::orientationToYaw(const Eigen::Matrix3d &R) { - tracked_armors_num = ArmorsNum::BALANCE_2; + double sy = sqrt(R(0, 0) * R(0, 0) + R(1, 0) * R(1, 0)); + Eigen::Vector3d eulerAngles; + bool singular = sy < 1e-6; // If + + if (!singular) + { + eulerAngles[0] = atan2(R(2, 1), R(2, 2)); // X-axis rotation + eulerAngles[1] = atan2(-R(2, 0), sy); // Y-axis rotation + eulerAngles[2] = atan2(R(1, 0), R(0, 0)); // Z-axis rotation + } + else + { + eulerAngles[0] = atan2(-R(1, 2), R(1, 1)); // X-axis rotation + eulerAngles[1] = atan2(-R(2, 0), sy); // Y-axis rotation + eulerAngles[2] = 0; // Z-axis rotation + } + double yaw = eulerAngles[2] + CV_PI / 2; + armor_pitch = eulerAngles[0] / CV_PI * 180; + armor_yaw = eulerAngles[2] / CV_PI * 180; +// double yaw = atan2(R(1, 1), R(0, 1)); +// armor_pitch=atan2(R(2,2),R(1,2))/CV_PI*180; +// armor_yaw=yaw/CV_PI*180; + yaw = last_yaw_ + angles::shortest_angular_distance(last_yaw_, yaw); + last_yaw_ = yaw; + return yaw; } - else if(tracked_id == "outpost") + + Eigen::Vector3d Tracker::getArmorPositionFromState(const Eigen::VectorXd &x) { - tracked_armors_num = ArmorsNum::OUTPOST_3; + // Calculate predicted position of the current armor + double xc = x(0), yc = x(2), zc = x(4); + double yaw = x(6), r = x(8); + double xa = xc - r * cos(yaw); + double ya = yc - r * sin(yaw); + return {xa, ya, zc}; } - else + + void Tracker::updateArmorsNum(const Armor &armor) { - tracked_armors_num = ArmorsNum::NORMAL_4; + if (armor.armor_type == LARGE && (tracked_id == "3" || tracked_id == "4" || tracked_id == "5")) + { + tracked_armors_num = ArmorsNum::BALANCE_2; + } + else if (tracked_id == "outpost") + { + tracked_armors_num = ArmorsNum::OUTPOST_3; + } + else if (tracked_id == "base") + { + tracked_armors_num = ArmorsNum::BASE_1; + } + else + { + tracked_armors_num = ArmorsNum::NORMAL_4; + } } -} } // namespace hnurm diff --git a/hnurm_bringup/CMakeLists.txt b/hnurm_bringup/CMakeLists.txt index 4207d86169029ad84b7515553b5e80e7801823eb..35873f6834c98cab027e4dba578c74aa15ab0c45 100644 --- a/hnurm_bringup/CMakeLists.txt +++ b/hnurm_bringup/CMakeLists.txt @@ -9,17 +9,22 @@ endif () find_package(ament_cmake_auto REQUIRED) ament_auto_find_build_dependencies() -ament_auto_add_executable(hnurm_bringup_node - src/bringup_node.cpp +ament_auto_add_executable(sentry_manage_node + src/sentry_manage_node.cpp ) -install(TARGETS - hnurm_bringup_node - DESTINATION lib/${PROJECT_NAME} +ament_auto_add_executable(compose_node + src/compose_node.cpp ) - -install(DIRECTORY launch params - DESTINATION share/${PROJECT_NAME} +ament_target_dependencies(compose_node + hnurm_armor + hnurm_uart + hnurm_detect + hnurm_camera ) -ament_package() +ament_auto_package( + INSTALL_TO_SHARE + params + launch +) diff --git a/hnurm_bringup/include/hnurm_bringup/bringup_node.h b/hnurm_bringup/include/hnurm_bringup/sentry_manage_node.h similarity index 44% rename from hnurm_bringup/include/hnurm_bringup/bringup_node.h rename to hnurm_bringup/include/hnurm_bringup/sentry_manage_node.h index b1240d72e102075533db92ac7c3ae06172e226e5..f316fee307a2331c58ea1b2a4f76c7d7946cafd6 100644 --- a/hnurm_bringup/include/hnurm_bringup/bringup_node.h +++ b/hnurm_bringup/include/hnurm_bringup/sentry_manage_node.h @@ -8,28 +8,28 @@ #include #include -#include "hnurm_uart/msg/vision_send_data.hpp" +#include "hnurm_interfaces/msg/vision_send_data.hpp" namespace hnurm { -class BringUpNode : public rclcpp::Node +class SentryManageNode : public rclcpp::Node { public: - explicit BringUpNode(const rclcpp::NodeOptions &options); + explicit SentryManageNode(const rclcpp::NodeOptions &options); void init_params(); - void master_res_callback(hnurm_uart::msg::VisionSendData::ConstSharedPtr msg); - void slave_res_callback(hnurm_uart::msg::VisionSendData::ConstSharedPtr msg); + void master_res_callback(hnurm_interfaces::msg::VisionSendData::ConstSharedPtr msg); + void slave_res_callback(hnurm_interfaces::msg::VisionSendData::ConstSharedPtr msg); private: // subs - rclcpp::Subscription::SharedPtr master_res_sub_; - rclcpp::Subscription::SharedPtr slave_res_sub_; + rclcpp::Subscription::SharedPtr master_res_sub_; + rclcpp::Subscription::SharedPtr slave_res_sub_; // pubs - rclcpp::Publisher::SharedPtr master_res_pub_; - rclcpp::Publisher::SharedPtr slave_res_pub_; + rclcpp::Publisher::SharedPtr master_res_pub_; + rclcpp::Publisher::SharedPtr slave_res_pub_; // topics std::string master_res_sub_topic_; @@ -40,7 +40,7 @@ private: // buffers std::mutex master_res_buffer_mutex_; - std::deque master_res_buffer_; + std::deque master_res_buffer_; // params bool use_cross_fire = false; diff --git a/hnurm_bringup/launch/compose.launch.py b/hnurm_bringup/launch/compose.launch.py new file mode 100644 index 0000000000000000000000000000000000000000..4ce6d7d70d15bd01ec2e3fa2ae9e91b11d6b3d6b --- /dev/null +++ b/hnurm_bringup/launch/compose.launch.py @@ -0,0 +1,60 @@ +import os + +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + hnurm_bringup_dir = get_package_share_directory('hnurm_bringup') + + # getting all params + hnurm_uart_dir = get_package_share_directory('hnurm_uart') + hnurm_camera_dir = get_package_share_directory('hnurm_camera') + hnurm_detect_dir = get_package_share_directory('hnurm_detect') + hnurm_armor_dir = get_package_share_directory('hnurm_armor') + + params_file_uart = LaunchConfiguration('uart_params_file') + params_file_camera = LaunchConfiguration('camera_params_file') + params_file_detect = LaunchConfiguration('detect_params_file') + params_file_armor = LaunchConfiguration('armor_params_file') + + hnurm_bringup_ld = LaunchDescription([ + DeclareLaunchArgument( + 'uart_params_file', + default_value=os.path.join(hnurm_uart_dir, 'params', 'default.yaml'), + description='uart params file' + ), + + DeclareLaunchArgument( + 'camera_params_file', + default_value=os.path.join(hnurm_camera_dir, 'params', 'default.yaml'), + description='camera params file' + ), + + DeclareLaunchArgument( + 'detect_params_file', + default_value=os.path.join(hnurm_detect_dir, 'params', 'default.yaml'), + description='detect params file' + ), + + DeclareLaunchArgument( + 'armor_params_file', + default_value=os.path.join(hnurm_armor_dir, 'params', 'default.yaml'), + description='armor params file' + ), + + Node( + package='hnurm_bringup', + executable='compose_node', + output='screen', + parameters=[params_file_uart, params_file_camera, params_file_detect, params_file_armor] + ), + ]) + + # now return the launch description + return LaunchDescription([ + hnurm_bringup_ld + ]) diff --git a/hnurm_bringup/launch/vision.uart.cam.launch.py b/hnurm_bringup/launch/vision.uart.cam.launch.py new file mode 100644 index 0000000000000000000000000000000000000000..961f254b556d471ddb5d35472c5e9e306a383d69 --- /dev/null +++ b/hnurm_bringup/launch/vision.uart.cam.launch.py @@ -0,0 +1,61 @@ +import os + +from ament_index_python.packages import get_package_share_directory + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + # firstly getting the uart node + # in this node, we need to solve control_id + hnurm_uart_dir = get_package_share_directory('hnurm_uart') + params_file_uart = LaunchConfiguration('uart_params_file') + control_id = LaunchConfiguration('control_id') + + hnurm_uart_ld = LaunchDescription([ + DeclareLaunchArgument( + 'uart_params_file', + default_value=os.path.join(hnurm_uart_dir, 'params', 'default.yaml'), + description='uart params file' + ), + DeclareLaunchArgument( + 'control_id', + default_value="1.0", + description='control id' + ), + Node( + package='hnurm_uart', + executable='hnurm_uart_node', + output='screen', + parameters=[params_file_uart, {'control_id': control_id}] + ), + ]) + + # getting the camera node + # should tell which camera to open + # so camera_id param should be rewritten + hnurm_camera_dir = get_package_share_directory('hnurm_camera') + params_file_camera = LaunchConfiguration('camera_params_file') + + hnurm_camera_ld = LaunchDescription([ + DeclareLaunchArgument( + 'camera_params_file', + default_value=os.path.join(hnurm_camera_dir, 'params', 'default.yaml'), + description='camera params file' + ), + Node( + package='hnurm_camera', + executable='hnurm_camera_node', + output='screen', + parameters=[params_file_camera] + ) + ]) + + # now return the launch description + return LaunchDescription([ + hnurm_uart_ld, + hnurm_camera_ld, + ]) diff --git a/hnurm_bringup/package.xml b/hnurm_bringup/package.xml index 9564c6ed4ddc30d5ff1fdcd762fa46ff71f77f58..6dd8ae3a5defd45f9dada9a6d6baf299ba154a5c 100644 --- a/hnurm_bringup/package.xml +++ b/hnurm_bringup/package.xml @@ -15,8 +15,12 @@ tf2 tf2_eigen angles - hnurm_uart + hnurm_interfaces + hnurm_detect + hnurm_camera + hnurm_uart + hnurm_armor ament_lint_auto ament_lint_common diff --git a/hnurm_bringup/src/compose_node.cpp b/hnurm_bringup/src/compose_node.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eef6dd47782d1de81af61640d3d4c617ad767637 --- /dev/null +++ b/hnurm_bringup/src/compose_node.cpp @@ -0,0 +1,36 @@ +// +// Created by Kai Wang on 24-5-22. +// +#include +#include +#include +#include + +using namespace std::chrono_literals; + +int main(int argc, char *argv[]) +{ + rclcpp::init(argc, argv); + + rclcpp::NodeOptions options; + options.use_intra_process_comms(true); + + auto uart_node = std::make_shared(options); + auto camera_node = std::make_shared(options); + auto detect_node = std::make_shared(options); + auto armor_node = std::make_shared(options); + + rclcpp::executors::MultiThreadedExecutor executor; + executor.add_node(uart_node); + executor.add_node(camera_node); + executor.add_node(detect_node); + executor.add_node(armor_node); + + uart_node->run(); + camera_node->run(); + + executor.spin(); + + rclcpp::shutdown(); + return 0; +} \ No newline at end of file diff --git a/hnurm_bringup/src/bringup_node.cpp b/hnurm_bringup/src/sentry_manage_node.cpp similarity index 58% rename from hnurm_bringup/src/bringup_node.cpp rename to hnurm_bringup/src/sentry_manage_node.cpp index 0f9495d4a354e3f157c0e40785da7d804b932ecf..5c9f727c6bf7d0fa955287e535cde1a47206c2fc 100644 --- a/hnurm_bringup/src/bringup_node.cpp +++ b/hnurm_bringup/src/sentry_manage_node.cpp @@ -2,28 +2,28 @@ // Created by rm on 24-4-8. // -#include "hnurm_bringup/bringup_node.h" +#include "hnurm_bringup/sentry_manage_node.h" #include namespace hnurm { -BringUpNode::BringUpNode(const rclcpp::NodeOptions &options) : rclcpp::Node("bringup_node", options) +SentryManageNode::SentryManageNode(const rclcpp::NodeOptions &options) : rclcpp::Node("SentryManageNode", options) { init_params(); - master_res_sub_ = this->create_subscription( - master_res_sub_topic_, 10, std::bind(&BringUpNode::master_res_callback, this, std::placeholders::_1) + master_res_sub_ = this->create_subscription( + master_res_sub_topic_, 10, std::bind(&SentryManageNode::master_res_callback, this, std::placeholders::_1) ); - slave_res_sub_ = this->create_subscription( - slave_res_sub_topic_, 10, std::bind(&BringUpNode::slave_res_callback, this, std::placeholders::_1) + slave_res_sub_ = this->create_subscription( + slave_res_sub_topic_, 10, std::bind(&SentryManageNode::slave_res_callback, this, std::placeholders::_1) ); - master_res_pub_ = this->create_publisher(master_res_pub_topic_, 10); - slave_res_pub_ = this->create_publisher(slave_res_pub_topic_, 10); + master_res_pub_ = this->create_publisher(master_res_pub_topic_, 10); + slave_res_pub_ = this->create_publisher(slave_res_pub_topic_, 10); } -void BringUpNode::init_params() +void SentryManageNode::init_params() { master_res_sub_topic_ = this->declare_parameter("/master_res", "/left/vision_send_res"); slave_res_sub_topic_ = this->declare_parameter("/slave_res", "/right/vision_send_res"); @@ -35,11 +35,11 @@ void BringUpNode::init_params() master_to_slave_offset = this->declare_parameter("/master_to_slave_offset", 0.335); } -void BringUpNode::master_res_callback(hnurm_uart::msg::VisionSendData::ConstSharedPtr msg) +void SentryManageNode::master_res_callback(hnurm_interfaces::msg::VisionSendData::ConstSharedPtr msg) { if(use_cross_fire) { - if(msg->target_state.data == hnurm_uart::msg::TargetState::FIRE) + if(msg->target_state.data == hnurm_interfaces::msg::TargetState::FIRE) master_res_buffer_.push_front(*msg); else master_res_buffer_.clear(); @@ -47,7 +47,7 @@ void BringUpNode::master_res_callback(hnurm_uart::msg::VisionSendData::ConstShar master_res_pub_->publish(*msg); } -void BringUpNode::slave_res_callback(hnurm_uart::msg::VisionSendData::ConstSharedPtr msg) +void SentryManageNode::slave_res_callback(hnurm_interfaces::msg::VisionSendData::ConstSharedPtr msg) { if(!use_cross_fire) { @@ -55,14 +55,14 @@ void BringUpNode::slave_res_callback(hnurm_uart::msg::VisionSendData::ConstShare return; } - if(msg->target_state.data == hnurm_uart::msg::TargetState::FIRE) + if(msg->target_state.data == hnurm_interfaces::msg::TargetState::FIRE) { // this means slave head has target slave_res_pub_->publish(*msg); return; } - if(msg->target_state.data == hnurm_uart::msg::TargetState::CONVERGING) + if(msg->target_state.data == hnurm_interfaces::msg::TargetState::CONVERGING) { // this means slave head has target slave_res_pub_->publish(*msg); @@ -77,7 +77,7 @@ void BringUpNode::slave_res_callback(hnurm_uart::msg::VisionSendData::ConstShare } // cross fire - auto master_res = master_res_buffer_.front(); + auto master_res = master_res_buffer_.front(); // auto master_time = rclcpp::Time(master_res.header.stamp); // auto slave_time = rclcpp::Time(msg->header.stamp); // auto diff = (master_time - slave_time).seconds(); @@ -93,15 +93,15 @@ void BringUpNode::slave_res_callback(hnurm_uart::msg::VisionSendData::ConstShare // get target const auto &d = master_to_slave_offset; const auto &r = master_res.target_distance; - const auto phi = angles::from_degrees(master_res.yaw); + const auto phi = angles::from_degrees(master_res.yaw); // theta is target - auto theta = static_cast(atan(r * sin(phi) / (r * cos(phi) - d))); - auto total_yaw = angles::from_degrees(msg->yaw); + auto theta = static_cast(atan(r * sin(phi) / (r * cos(phi) - d))); + auto total_yaw = angles::from_degrees(msg->yaw); // get angular distance in degs auto da = angles::to_degrees(angles::shortest_angular_distance(total_yaw, theta)); // calculate final target in degs - auto yaw_target = msg->yaw + da +12 ; - bool status_ = true; + auto yaw_target = msg->yaw + da + 12; + bool status_ = true; // if(master_res.yaw > 180) // { @@ -112,30 +112,27 @@ void BringUpNode::slave_res_callback(hnurm_uart::msg::VisionSendData::ConstShare yaw_target = yaw_target - 195; } + if(master_res.yaw > 80 && master_res.yaw < 110) + { + status_ = false; + } - if(master_res.yaw >80 && master_res.yaw <110) - { - status_ =false; - } - - if(status_){ - hnurm_uart::msg::VisionSendData res; + if(status_) + { + hnurm_interfaces::msg::VisionSendData res; res.header = msg->header; - res.target_state.data = hnurm_uart::msg::TargetState::CONVERGING; + res.target_state.data = hnurm_interfaces::msg::TargetState::CONVERGING; res.target_type = master_res.target_type; res.pitch = master_res.pitch; res.yaw = yaw_target; res.control_id = 1.000; slave_res_pub_->publish(res); master_res_buffer_.pop_front(); - if(master_res_buffer_.size()>10000) + if(master_res_buffer_.size() > 10'000) { master_res_buffer_.clear(); } } - - - } } // namespace hnurm @@ -143,7 +140,7 @@ int main(int argc, char *argv[]) { rclcpp::init(argc, argv); rclcpp::NodeOptions options; - auto node = std::make_shared(options); + auto node = std::make_shared(options); rclcpp::spin(node); rclcpp::shutdown(); return 0; diff --git a/hnurm_camera/CMakeLists.txt b/hnurm_camera/CMakeLists.txt index 933ef297bfd7f9ccf401379097bdd4510dbd46a7..37a1fd082377ecca38fc7db1dd3dd032d53f1b54 100644 --- a/hnurm_camera/CMakeLists.txt +++ b/hnurm_camera/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.22) project(hnurm_camera) - -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) if (${CMAKE_SYSTEM} MATCHES "Linux") file(GLOB SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/linux/*) @@ -10,48 +9,17 @@ elseif (${CMAKE_SYSTEM} MATCHES "Darwin") file(GLOB SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/darwin/*) endif () -find_package(ament_cmake REQUIRED) -find_package(rclcpp REQUIRED) -find_package(cv_bridge REQUIRED) -find_package(sensor_msgs REQUIRED) - -find_package(OpenCV REQUIRED) - -set(dependencies - rclcpp - OpenCV - cv_bridge - sensor_msgs -) +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() -add_library(hnurm_camera SHARED src/Camera.cpp) -target_include_directories(hnurm_camera PRIVATE - $ - $ -) -ament_target_dependencies(hnurm_camera ${dependencies}) +ament_auto_add_library(hnurm_camera SHARED src/Camera.cpp src/camera_node.cpp) target_link_libraries(hnurm_camera ${SDK_PATH}) -add_executable(${PROJECT_NAME}_node src/camera_node.cpp src/main.cpp) -target_include_directories(${PROJECT_NAME}_node PRIVATE - $ - $ -) -ament_target_dependencies(${PROJECT_NAME}_node ${dependencies}) -target_link_libraries(${PROJECT_NAME}_node hnurm_camera ${SDK_PATH}) +ament_auto_add_executable(hnurm_camera_node src/main.cpp) +target_link_libraries(hnurm_camera_node hnurm_camera) - -install(TARGETS hnurm_camera - DESTINATION lib -) -install(FILES ${SDK_PATH} - DESTINATION lib -) -install(TARGETS ${PROJECT_NAME}_node - DESTINATION lib/${PROJECT_NAME} +ament_auto_package( + INSTALL_TO_SHARE + launch + params ) -install(DIRECTORY launch params - DESTINATION share/${PROJECT_NAME} -) - -ament_package() diff --git a/hnurm_camera/CameraCalibration/CMakeLists.txt b/hnurm_camera/CameraCalibration/CMakeLists.txt deleted file mode 100755 index c157a739361fec3e6755fe540411ca9439286aaf..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(Camera_Calibration) -set(CMAKE_CXX_STANDARD 17) -set(ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) -find_package(OpenCV REQUIRED) - -include_directories(${OpenCV_INCLUDE_DIR} - include - ) - -file(GLOB_RECURSE src_lists - src/* - ) - -add_executable(Camera_Calibration camera_calibration.cpp ${src_lists}) - - -#dynamic link libraries - -target_link_libraries(Camera_Calibration ${OpenCV_LIBS} - ${ROOT}/hnurm_camera/lib/linux/libFormatConversion.so - ${ROOT}/hnurm_camera/lib/linux/libMediaProcess.so - ${ROOT}/hnurm_camera/lib/linux/libMvCameraControl.so - ${ROOT}/hnurm_camera/lib/linux/libMVRender.so - ${ROOT}/hnurm_camera/lib/linux/libMvUsb3vTL.so - ) \ No newline at end of file diff --git a/hnurm_camera/CameraCalibration/CameraParam.yaml b/hnurm_camera/CameraCalibration/CameraParam.yaml deleted file mode 100755 index 911bcb71d2b8810826d133db4164a83a4d6e6438..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/CameraParam.yaml +++ /dev/null @@ -1,66 +0,0 @@ -%YAML:1.0 - ---- -# 图像宽度:步进16 -nWidthValue: 1280 - -# 图像高度:步进2 -nHeightValue: 720 - -# 水平偏移 -nOffsetXValue: 0 - -# 垂直偏移 -nOffsetYValue: 152 - -# 水平镜像 -bSetBoolValue5: 0 - -# 垂直镜像 -bSetBoolValue1: 0 - -# 像素格式 -PixelFormat: 0x02180015 - -# 水平合并 -nBinningHorizontal: 1 - -# 垂直合并 -nBinningVertical: 1 - -# 水平下采样 -nDecimationHorizontal: 1 - -# 垂直下采样 -nDecimationVertical: 1 - -# 采集触发帧率 -nAcquisitionBurstFrameCountValue: 1 - -# 设置采集帧率 -fFPSValue: 404.0000 - -# 设置使能采集帧率控制 -nSetBoolValue3: 1 - -# 曝光时间 -fExposureTime: 30000.0000 - -# 增益 -fGainValue: 10.0000 - -# 自动增益 -nGainAuto: 0 - -# 黑电平 -nBlackLevelValue: 30 - -# 黑电平使能 -bSetBoolValue2: 1 - -# 伽马校正 -fGammaValue: 0.7 - -# 伽马校正使能 -bSetBoolValue4: 1 -... \ No newline at end of file diff --git a/hnurm_camera/CameraCalibration/camera_calibration.cpp b/hnurm_camera/CameraCalibration/camera_calibration.cpp deleted file mode 100755 index 41a9b835f7cb258ea03ef2e1fe7ed242a7737db6..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/camera_calibration.cpp +++ /dev/null @@ -1,722 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include "Camera.h" -using namespace cv; -using namespace std; -using namespace hnurm; - -class Settings -{ -public: - Settings() - { - goodInput = false; - } - enum Pattern { NOT_EXISTING, CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID }; - enum InputType { INVALID, CAMERA, VIDEO_FILE, IMAGE_LIST }; - void write(FileStorage& fs) const //Write serialization for this class - { - fs << "{" - << "BoardSize_Width" << boardSize.width - << "BoardSize_Height" << boardSize.height - << "Square_Size" << squareSize - << "Calibrate_Pattern" << patternToUse - << "Calibrate_NrOfFrameToUse" << nrFrames - << "Calibrate_FixAspectRatio" << aspectRatio - << "Calibrate_AssumeZeroTangentialDistortion" << calibZeroTangentDist - << "Calibrate_FixPrincipalPointAtTheCenter" << calibFixPrincipalPoint - - << "Write_DetectedFeaturePoints" << writePoints - << "Write_extrinsicParameters" << writeExtrinsics - << "Write_gridPoints" << writeGrid - << "Write_outputFileName" << outputFileName - - << "Show_UndistortedImage" << showUndistorsed - - << "Input_FlipAroundHorizontalAxis" << flipVertical - << "Input_Delay" << delay - << "Input" << input - << "}"; - } - void read(const FileNode& node) //Read serialization for this class - { - node["BoardSize_Width" ] >> boardSize.width; - node["BoardSize_Height"] >> boardSize.height; - node["Calibrate_Pattern"] >> patternToUse; - node["Square_Size"] >> squareSize; - node["Calibrate_NrOfFrameToUse"] >> nrFrames; - node["Calibrate_FixAspectRatio"] >> aspectRatio; - node["Write_DetectedFeaturePoints"] >> writePoints; - node["Write_extrinsicParameters"] >> writeExtrinsics; - node["Write_gridPoints"] >> writeGrid; - node["Write_outputFileName"] >> outputFileName; - node["Calibrate_AssumeZeroTangentialDistortion"] >> calibZeroTangentDist; - node["Calibrate_FixPrincipalPointAtTheCenter"] >> calibFixPrincipalPoint; - node["Calibrate_UseFisheyeModel"] >> useFisheye; - node["Input_FlipAroundHorizontalAxis"] >> flipVertical; - node["Show_UndistortedImage"] >> showUndistorsed; - node["Input"] >> input; - node["Input_Delay"] >> delay; - node["Fix_K1"] >> fixK1; - node["Fix_K2"] >> fixK2; - node["Fix_K3"] >> fixK3; - node["Fix_K4"] >> fixK4; - node["Fix_K5"] >> fixK5; - - validate(); - } - void validate() - { - goodInput = true; - if (boardSize.width <= 0 || boardSize.height <= 0) - { - cerr << "Invalid Board size: " << boardSize.width << " " << boardSize.height << endl; - goodInput = false; - } - if (squareSize <= 10e-6) - { - cerr << "Invalid square size " << squareSize << endl; - goodInput = false; - } - if (nrFrames <= 0) - { - cerr << "Invalid number of frames " << nrFrames << endl; - goodInput = false; - } - - if (input.empty()) // Check for valid input - inputType = INVALID; - else - { - if (input[0] >= '0' && input[0] <= '9') - { - stringstream ss(input); - ss >> cameraID; - inputType = CAMERA; - } - else - { - if (isListOfImages(input) && readStringList(input, imageList)) - { - inputType = IMAGE_LIST; - nrFrames = (nrFrames < (int) imageList.size()) ? nrFrames : (int) imageList.size(); - } - else - inputType = VIDEO_FILE; - } - if (inputType == CAMERA) - { - inputCapture.OpenCam(); - } - if (inputType == VIDEO_FILE) - { - inputCapture.OpenCam(); - } - if (inputType != IMAGE_LIST && !true) - inputType = INVALID; - } - if (inputType == INVALID) - { - cerr << " Input does not exist: " << input; - goodInput = false; - } - - flag = 0; - if(calibFixPrincipalPoint) flag |= CALIB_FIX_PRINCIPAL_POINT; - if(calibZeroTangentDist) flag |= CALIB_ZERO_TANGENT_DIST; - if(aspectRatio) flag |= CALIB_FIX_ASPECT_RATIO; - if(fixK1) flag |= CALIB_FIX_K1; - if(fixK2) flag |= CALIB_FIX_K2; - if(fixK3) flag |= CALIB_FIX_K3; - if(fixK4) flag |= CALIB_FIX_K4; - if(fixK5) flag |= CALIB_FIX_K5; - - if (useFisheye) { - // the fisheye model has its own enum, so overwrite the flags - flag = fisheye::CALIB_FIX_SKEW | fisheye::CALIB_RECOMPUTE_EXTRINSIC; - if(fixK1) flag |= fisheye::CALIB_FIX_K1; - if(fixK2) flag |= fisheye::CALIB_FIX_K2; - if(fixK3) flag |= fisheye::CALIB_FIX_K3; - if(fixK4) flag |= fisheye::CALIB_FIX_K4; - if (calibFixPrincipalPoint) flag |= fisheye::CALIB_FIX_PRINCIPAL_POINT; - } - - calibrationPattern = NOT_EXISTING; - if (!patternToUse.compare("CHESSBOARD")) calibrationPattern = CHESSBOARD; - if (!patternToUse.compare("CIRCLES_GRID")) calibrationPattern = CIRCLES_GRID; - if (!patternToUse.compare("ASYMMETRIC_CIRCLES_GRID")) calibrationPattern = ASYMMETRIC_CIRCLES_GRID; - if (calibrationPattern == NOT_EXISTING) - { - cerr << " Camera calibration mode does not exist: " << patternToUse << endl; - goodInput = false; - } - atImageList = 0; - - } - Mat nextImage() - { - Mat result; - if (true) - { - ImgInfo ifo; - inputCapture.SendFrame(ifo); - Mat view0 = ifo.img; - view0.copyTo(result); - } - else if (atImageList < imageList.size()) - result = imread(imageList[atImageList++], IMREAD_COLOR); - - return result; - } - - static bool readStringList( const string& filename, vector& l ) - { - l.clear(); - FileStorage fs(filename, FileStorage::READ); - if( !fs.isOpened() ) - return false; - FileNode n = fs.getFirstTopLevelNode(); - if( n.type() != FileNode::SEQ ) - return false; - FileNodeIterator it = n.begin(), it_end = n.end(); - for( ; it != it_end; ++it ) - l.push_back((string)*it); - return true; - } - - static bool isListOfImages( const string& filename) - { - string s(filename); - // Look for file extension - if( s.find(".xml") == string::npos && s.find(".yaml") == string::npos && s.find(".yml") == string::npos ) - return false; - else - return true; - } -public: - Size boardSize; // The size of the board -> Number of items by width and height - Pattern calibrationPattern; // One of the Chessboard, circles, or asymmetric circle pattern - float squareSize; // The size of a square in your defined unit (point, millimeter,etc). - int nrFrames; // The number of frames to use from the input for calibration - float aspectRatio; // The aspect ratio - int delay; // In case of a video input - bool writePoints; // Write detected feature points - bool writeExtrinsics; // Write extrinsic parameters - bool writeGrid; // Write refined 3D target grid points - bool calibZeroTangentDist; // Assume zero tangential distortion - bool calibFixPrincipalPoint; // Fix the principal point at the center - bool flipVertical; // Flip the captured images around the horizontal axis - string outputFileName; // The name of the file where to write - bool showUndistorsed; // Show undistorted images after calibration - string input; // The input -> - bool useFisheye; // use fisheye camera model for calibration - bool fixK1; // fix K1 distortion coefficient - bool fixK2; // fix K2 distortion coefficient - bool fixK3; // fix K3 distortion coefficient - bool fixK4; // fix K4 distortion coefficient - bool fixK5; // fix K5 distortion coefficient - - int cameraID; - vector imageList; - size_t atImageList; - HKcam inputCapture; - InputType inputType; - bool goodInput; - int flag; - -private: - string patternToUse; - - -}; - -static inline void read(const FileNode& node, Settings& x, const Settings& default_value = Settings()) -{ - if(node.empty()) - x = default_value; - else - x.read(node); -} - -enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 }; - -bool runCalibrationAndSave(Settings& s, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, - vector > imagePoints, float grid_width, bool release_object); -INITIALIZE_EASYLOGGINGPP - -int main(int argc, char* argv[]) -{ - const String keys - = "{help h usage ? | | print this message }" - "{@settings |default.xml| input setting file }" - "{d | | actual distance between top-left and top-right corners of " - "the calibration grid }" - "{winSize | 11 | Half of search window for cornerSubPix }"; - CommandLineParser parser(argc, argv, keys); - parser.about("This is a camera calibration sample.\n" - "Usage: camera_calibration [configuration_file -- default ./default.xml]\n" - "Near the sample file you'll find the configuration file, which has detailed help of " - "how to edit it. It may be any OpenCV supported file format XML/YAML."); - if (!parser.check()) { - parser.printErrors(); - return 0; - } - - if (parser.has("help")) { - parser.printMessage(); - return 0; - } - - //! [file_read] - Settings s; - const string inputSettingsFile = parser.get(0); - FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings - if (!fs.isOpened()) - { - cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl; - parser.printMessage(); - return -1; - } - fs["Settings"] >> s; - fs.release(); // close Settings file - //! [file_read] - - //FileStorage fout("settings.yml", FileStorage::WRITE); // write config as YAML - //fout << "Settings" << s; - - if (!s.goodInput) - { - cout << "Invalid input detected. Application stopping. " << endl; - return -1; - } - - int winSize = parser.get("winSize"); - - float grid_width = s.squareSize * (s.boardSize.width - 1); - bool release_object = false; - if (parser.has("d")) { - grid_width = parser.get("d"); - release_object = true; - } - - vector > imagePoints; - Mat cameraMatrix, distCoeffs; - Size imageSize; - int mode = s.inputType == Settings::IMAGE_LIST ? CAPTURING : DETECTION; - clock_t prevTimestamp = 0; - const Scalar RED(0,0,255), GREEN(0,255,0); - const char ESC_KEY = 27; - - //! [get_input] - for(;;) - { - Mat view; - bool blinkOutput = false; - - view = s.nextImage(); - - //----- If no more image, or got enough, then stop calibration and show result ------------- - if( mode == CAPTURING && imagePoints.size() >= (size_t)s.nrFrames ) - { - if (runCalibrationAndSave(s, imageSize, cameraMatrix, distCoeffs, imagePoints, grid_width, - release_object)) - mode = CALIBRATED; - else - mode = DETECTION; - } - if(view.empty()) // If there are no more images stop the loop - { - // if calibration threshold was not reached yet, calibrate now - if( mode != CALIBRATED && !imagePoints.empty() ) - runCalibrationAndSave(s, imageSize, cameraMatrix, distCoeffs, imagePoints, grid_width, - release_object); - break; - } - //! [get_input] - - imageSize = view.size(); // Format input image. - if( s.flipVertical ) flip( view, view, 0 ); - - //! [find_pattern] - vector pointBuf; - - bool found; - - int chessBoardFlags = CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE; - - if(!s.useFisheye) { - // fast check erroneously fails with high distortions like fisheye - chessBoardFlags |= CALIB_CB_FAST_CHECK; - } - - switch( s.calibrationPattern ) // Find feature points on the input format - { - case Settings::CHESSBOARD: - found = findChessboardCorners(view, s.boardSize, pointBuf, chessBoardFlags); - break; - case Settings::CIRCLES_GRID: - found = findCirclesGrid(view, s.boardSize, pointBuf); - break; - case Settings::ASYMMETRIC_CIRCLES_GRID: - found = findCirclesGrid(view, s.boardSize, pointBuf, CALIB_CB_ASYMMETRIC_GRID); - break; - default: - found = false; - break; - } - //! [find_pattern] - //! [pattern_found] - if ( found) // If done with success, - { - // improve the found corners' coordinate accuracy for chessboard - if (s.calibrationPattern == Settings::CHESSBOARD) - { - Mat viewGray; - cvtColor(view, viewGray, COLOR_BGR2GRAY); - cornerSubPix(viewGray, pointBuf, Size(winSize, winSize), - Size(-1, -1), TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 30, 0.0001)); - } - - if (mode == CAPTURING && // For camera only take new samples after delay time - (!true || clock() - prevTimestamp > s.delay * 1e-3 * CLOCKS_PER_SEC)) - { - imagePoints.push_back(pointBuf); - prevTimestamp = clock(); - blinkOutput = true; - } - - // Draw the corners. - drawChessboardCorners(view, s.boardSize, Mat(pointBuf), found); - } - //! [pattern_found] - //----------------------------- Output Text ------------------------------------------------ - //! [output_text] - string msg = (mode == CAPTURING) ? "100/100" : - mode == CALIBRATED ? "Calibrated" : "Press 'g' to start"; - int baseLine = 0; - Size textSize = getTextSize(msg, 1, 1, 1, &baseLine); - Point textOrigin(view.cols - 2*textSize.width - 10, view.rows - 2*baseLine - 10); - - if( mode == CAPTURING ) - { - if(s.showUndistorsed) - msg = format( "%d/%d Undist", (int)imagePoints.size(), s.nrFrames ); - else - msg = format( "%d/%d", (int)imagePoints.size(), s.nrFrames ); - } - - putText( view, msg, textOrigin, 1, 1, mode == CALIBRATED ? GREEN : RED); - - if( blinkOutput ) - bitwise_not(view, view); - //! [output_text] - //------------------------- Video capture output undistorted ------------------------------ - //! [output_undistorted] - if( mode == CALIBRATED && s.showUndistorsed ) - { - Mat temp = view.clone(); - if (s.useFisheye) - cv::fisheye::undistortImage(temp, view, cameraMatrix, distCoeffs); - else - undistort(temp, view, cameraMatrix, distCoeffs); - } - //! [output_undistorted] - //------------------------------ Show image and check for input commands ------------------- - //! [await_input] - namedWindow("Image View", WINDOW_NORMAL); - imshow("Image View", view); - char key = (char) waitKey(true ? 50 : s.delay); - - if( key == ESC_KEY ) - break; - - if( key == 'u' && mode == CALIBRATED ) - s.showUndistorsed = !s.showUndistorsed; - - if (true && key == 'g') - { - mode = CAPTURING; - imagePoints.clear(); - } - //! [await_input] - } - - // -----------------------Show the undistorted image for the image list ------------------------ - //! [show_results] - if( s.inputType == Settings::IMAGE_LIST && s.showUndistorsed ) - { - Mat view, rview, map1, map2; - - if (s.useFisheye) - { - Mat newCamMat; - fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, - Matx33d::eye(), newCamMat, 1); - fisheye::initUndistortRectifyMap(cameraMatrix, distCoeffs, Matx33d::eye(), newCamMat, imageSize, - CV_16SC2, map1, map2); - } - else - { - initUndistortRectifyMap( - cameraMatrix, distCoeffs, Mat(), - getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize, 0), imageSize, - CV_16SC2, map1, map2); - } - - for(size_t i = 0; i < s.imageList.size(); i++ ) - { - view = imread(s.imageList[i], IMREAD_COLOR); - if(view.empty()) - continue; - remap(view, rview, map1, map2, INTER_LINEAR); - imshow("Image View", rview); - char c = (char)waitKey(); - if( c == ESC_KEY || c == 'q' || c == 'Q' ) - break; - } - } - //! [show_results] - - return 0; -} - -//! [compute_errors] -static double computeReprojectionErrors( const vector >& objectPoints, - const vector >& imagePoints, - const vector& rvecs, const vector& tvecs, - const Mat& cameraMatrix , const Mat& distCoeffs, - vector& perViewErrors, bool fisheye) -{ - vector imagePoints2; - size_t totalPoints = 0; - double totalErr = 0, err; - perViewErrors.resize(objectPoints.size()); - - for(size_t i = 0; i < objectPoints.size(); ++i ) - { - if (fisheye) - { - fisheye::projectPoints(objectPoints[i], imagePoints2, rvecs[i], tvecs[i], cameraMatrix, - distCoeffs); - } - else - { - projectPoints(objectPoints[i], rvecs[i], tvecs[i], cameraMatrix, distCoeffs, imagePoints2); - } - err = norm(imagePoints[i], imagePoints2, NORM_L2); - - size_t n = objectPoints[i].size(); - perViewErrors[i] = (float) std::sqrt(err*err/n); - totalErr += err*err; - totalPoints += n; - } - - return std::sqrt(totalErr/totalPoints); -} -//! [compute_errors] -//! [board_corners] -static void calcBoardCornerPositions(Size boardSize, float squareSize, vector& corners, - Settings::Pattern patternType /*= Settings::CHESSBOARD*/) -{ - corners.clear(); - - switch(patternType) - { - case Settings::CHESSBOARD: - case Settings::CIRCLES_GRID: - for (int i = 0; i < boardSize.height; ++i) - for (int j = 0; j < boardSize.width; ++j) - corners.push_back(Point3f(j * squareSize, i * squareSize, 0)); - break; - - case Settings::ASYMMETRIC_CIRCLES_GRID: - for (int i = 0; i < boardSize.height; i++) - for (int j = 0; j < boardSize.width; j++) - corners.push_back(Point3f((2 * j + i % 2) * squareSize, i * squareSize, 0)); - break; - default: - break; - } -} -//! [board_corners] -static bool runCalibration( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat& distCoeffs, - vector > imagePoints, vector& rvecs, vector& tvecs, - vector& reprojErrs, double& totalAvgErr, vector& newObjPoints, - float grid_width, bool release_object) -{ - //! [fixed_aspect] - cameraMatrix = Mat::eye(3, 3, CV_64F); - if( s.flag & CALIB_FIX_ASPECT_RATIO ) - cameraMatrix.at(0,0) = s.aspectRatio; - //! [fixed_aspect] - if (s.useFisheye) { - distCoeffs = Mat::zeros(4, 1, CV_64F); - } else { - distCoeffs = Mat::zeros(8, 1, CV_64F); - } - - vector > objectPoints(1); - calcBoardCornerPositions(s.boardSize, s.squareSize, objectPoints[0], s.calibrationPattern); - objectPoints[0][s.boardSize.width - 1].x = objectPoints[0][0].x + grid_width; - newObjPoints = objectPoints[0]; - - objectPoints.resize(imagePoints.size(),objectPoints[0]); - - //Find intrinsic and extrinsic camera parameters - double rms; - - if (s.useFisheye) { - Mat _rvecs, _tvecs; - rms = fisheye::calibrate(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, _rvecs, - _tvecs, s.flag); - - rvecs.reserve(_rvecs.rows); - tvecs.reserve(_tvecs.rows); - for(int i = 0; i < int(objectPoints.size()); i++){ - rvecs.push_back(_rvecs.row(i)); - tvecs.push_back(_tvecs.row(i)); - } - } else { - int iFixedPoint = -1; - if (release_object) - iFixedPoint = s.boardSize.width - 1; - rms = calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint, - cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints, - s.flag | CALIB_USE_LU); - } - - if (release_object) { - cout << "New board corners: " << endl; - cout << newObjPoints[0] << endl; - cout << newObjPoints[s.boardSize.width - 1] << endl; - cout << newObjPoints[s.boardSize.width * (s.boardSize.height - 1)] << endl; - cout << newObjPoints.back() << endl; - } - - cout << "Re-projection error reported by calibrateCamera: "<< rms << endl; - - bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs); - - objectPoints.clear(); - objectPoints.resize(imagePoints.size(), newObjPoints); - totalAvgErr = computeReprojectionErrors(objectPoints, imagePoints, rvecs, tvecs, cameraMatrix, - distCoeffs, reprojErrs, s.useFisheye); - - return ok; -} - -// Print camera parameters to the output file -static void saveCameraParams( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat& distCoeffs, - const vector& rvecs, const vector& tvecs, - const vector& reprojErrs, const vector >& imagePoints, - double totalAvgErr, const vector& newObjPoints ) -{ - string outputFile = s.outputFileName + s.inputCapture.GetCamName() + ".yaml"; - FileStorage fs(outputFile, FileStorage::WRITE); - - time_t tm; - time(&tm); - struct tm *t2 = localtime(&tm); - char buf[1024]; - strftime(buf, sizeof(buf), "%c", t2); - - fs << "calibration_time" << buf; - - if (s.flag) - { - std::stringstream flagsStringStream; - if (s.useFisheye) - { - flagsStringStream << "flags:" - << (s.flag & fisheye::CALIB_FIX_SKEW ? " +fix_skew" : "") - << (s.flag & fisheye::CALIB_FIX_K1 ? " +fix_k1" : "") - << (s.flag & fisheye::CALIB_FIX_K2 ? " +fix_k2" : "") - << (s.flag & fisheye::CALIB_FIX_K3 ? " +fix_k3" : "") - << (s.flag & fisheye::CALIB_FIX_K4 ? " +fix_k4" : "") - << (s.flag & fisheye::CALIB_RECOMPUTE_EXTRINSIC ? " +recompute_extrinsic" : ""); - } - else - { - flagsStringStream << "flags:" - << (s.flag & CALIB_USE_INTRINSIC_GUESS ? " +use_intrinsic_guess" : "") - << (s.flag & CALIB_FIX_ASPECT_RATIO ? " +fix_aspectRatio" : "") - << (s.flag & CALIB_FIX_PRINCIPAL_POINT ? " +fix_principal_point" : "") - << (s.flag & CALIB_ZERO_TANGENT_DIST ? " +zero_tangent_dist" : "") - << (s.flag & CALIB_FIX_K1 ? " +fix_k1" : "") - << (s.flag & CALIB_FIX_K2 ? " +fix_k2" : "") - << (s.flag & CALIB_FIX_K3 ? " +fix_k3" : "") - << (s.flag & CALIB_FIX_K4 ? " +fix_k4" : "") - << (s.flag & CALIB_FIX_K5 ? " +fix_k5" : ""); - } - fs.writeComment(flagsStringStream.str()); - } - - fs << "flags" << s.flag; - - fs << "fisheye_model" << s.useFisheye; - - fs << "camera_matrix" << cameraMatrix; - fs << "distortion_coefficients" << distCoeffs; - - - if(s.writeExtrinsics && !rvecs.empty() && !tvecs.empty() ) - { - CV_Assert(rvecs[0].type() == tvecs[0].type()); - Mat bigmat((int)rvecs.size(), 6, CV_MAKETYPE(rvecs[0].type(), 1)); - bool needReshapeR = rvecs[0].depth() != 1 ? true : false; - bool needReshapeT = tvecs[0].depth() != 1 ? true : false; - - for( size_t i = 0; i < rvecs.size(); i++ ) - { - Mat r = bigmat(Range(int(i), int(i+1)), Range(0,3)); - Mat t = bigmat(Range(int(i), int(i+1)), Range(3,6)); - - if(needReshapeR) - rvecs[i].reshape(1, 1).copyTo(r); - else - { - //*.t() is MatExpr (not Mat) so we can use assignment operator - CV_Assert(rvecs[i].rows == 3 && rvecs[i].cols == 1); - r = rvecs[i].t(); - } - - if(needReshapeT) - tvecs[i].reshape(1, 1).copyTo(t); - else - { - CV_Assert(tvecs[i].rows == 3 && tvecs[i].cols == 1); - t = tvecs[i].t(); - } - } - } -} - -//! [run_and_save] -bool runCalibrationAndSave(Settings& s, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, - vector > imagePoints, float grid_width, bool release_object) -{ - vector rvecs, tvecs; - vector reprojErrs; - double totalAvgErr = 0; - vector newObjPoints; - - bool ok = runCalibration(s, imageSize, cameraMatrix, distCoeffs, imagePoints, rvecs, tvecs, reprojErrs, - totalAvgErr, newObjPoints, grid_width, release_object); - cout << (ok ? "Calibration succeeded" : "Calibration failed") - << ". avg re projection error = " << totalAvgErr << endl; - - if (ok) - saveCameraParams(s, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, reprojErrs, imagePoints, - totalAvgErr, newObjPoints); - return ok; -} -//! [run_and_save] diff --git a/hnurm_camera/CameraCalibration/default.xml b/hnurm_camera/CameraCalibration/default.xml deleted file mode 100755 index 9fc189494946f83726bf388622b43fe6d5ccbc88..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/default.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - 11 - 8 - - - 30 - - - "CHESSBOARD" - - - "1" - - 0 - - - 100 - - - 100 - - 1 - - 1 - - 1 - - - "../../../hnurm_armor/data/" - - 1 - - 1 - - 1 - - 1 - - 0 - - 0 - - 0 - - 0 - - 1 - - 1 - - diff --git a/hnurm_camera/CameraCalibration/include/Camera.h b/hnurm_camera/CameraCalibration/include/Camera.h deleted file mode 100755 index 6d6ac63a1c1e30711c2291afc2ae84ffd6f65309..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/Camera.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef HKCAM -#define HKCAM - -#include -#include -#include -#include -#include -#include "MvCameraControl.h" -#include -#include -#include -#include -#include -#include -#include -#include "DataType.hpp" - - -namespace hnurm -{ - class HKcam - { - - public: - - /** - * @brief - * - */ - HKcam() - { - _cfg_path = "../CameraParam.yaml"; - _id = ""; - } - - HKcam(const cv::FileNode &cfg_node); - - ~HKcam(); - - - /** - * @brief - * - * @return true - * @return false - */ - bool OpenCam(const std::string &cameraId = ""); - - - /** - * @brief - * - * @return true - * @return false - */ - bool CloseCam(); - - - /** - * @brief - * - */ -// bool SendFrame(cv::Mat& img); - bool SendFrame(ImgInfo& img); - - /** - * @brief Set params for camera - * - */ - void SetParam(const std::string &cfg_path); - - std::string GetCamName(); - - bool SendFromVideoCapture(ImgInfo &img); - - bool _if_record = false; - - cv::VideoWriter video_writer; - - private: - - //state num - int nRet; - - //handle for manipulating the Camera - void* handle; - - //camera param - MVCC_INTVALUE stParam{}; - - //frame ptr - unsigned char *pData; - - //format of frame ,read from camera - MV_FRAME_OUT_INFO_EX stImageInfo{}; - - //indicating whether the camera is connected or not - //a flag for daemon thread -// bool connected_flag; - - std::string _cfg_path = "none"; - std::string _id = "none"; - std::string _video_path = "none"; - - int _nImageOrientation = 0; - - cv::VideoCapture video; - - - }; // HKcam - -} // hnurm -#endif diff --git a/hnurm_camera/CameraCalibration/include/CameraParams.h b/hnurm_camera/CameraCalibration/include/CameraParams.h deleted file mode 100755 index 0b4906c311c074467ddad31d2bdaea893d66126d..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/CameraParams.h +++ /dev/null @@ -1,944 +0,0 @@ - -#ifndef _MV_CAMERA_PARAMS_H_ -#define _MV_CAMERA_PARAMS_H_ - -#include "PixelType.h" - -#ifndef __cplusplus -typedef char bool; -#define true 1 -#define false 0 -#endif - -/// \~chinese -/// 设备类型定义 -/// \~english -/// Device Type Definition -#define MV_UNKNOW_DEVICE 0x00000000 ///< \~chinese 未知设备类型,保留意义 \~english Unknown Device Type, Reserved -#define MV_GIGE_DEVICE 0x00000001 ///< \~chinese GigE设备 \~english GigE Device -#define MV_1394_DEVICE 0x00000002 ///< \~chinese 1394-a/b 设备 \~english 1394-a/b Device -#define MV_USB_DEVICE 0x00000004 ///< \~chinese USB 设备 \~english USB Device -#define MV_CAMERALINK_DEVICE 0x00000008 ///< \~chinese CamLink设备 \~english CamLink Device - -/// \~chinese GigE设备信息 \~english GigE device info -typedef struct _MV_GIGE_DEVICE_INFO_ -{ - unsigned int nIpCfgOption; - unsigned int nIpCfgCurrent; ///< \~chinese \~english IP configuration:bit31-static bit30-dhcp bit29-lla - unsigned int nCurrentIp; - unsigned int nCurrentSubNetMask; ///< \~chinese \~english curtent subnet mask - unsigned int nDefultGateWay; ///< \~chinese \~english current gateway - unsigned char chManufacturerName[32]; - unsigned char chModelName[32]; - unsigned char chDeviceVersion[32]; - unsigned char chManufacturerSpecificInfo[48]; - unsigned char chSerialNumber[16]; - unsigned char chUserDefinedName[16]; - unsigned int nNetExport; ///< \~chinese 网口IP地址 \~english NetWork IP Address - - unsigned int nReserved[4]; -}MV_GIGE_DEVICE_INFO; - -#define INFO_MAX_BUFFER_SIZE 64 - -/// \~chinese USB设备信息 \~english USB device info -typedef struct _MV_USB3_DEVICE_INFO_ -{ - unsigned char CrtlInEndPoint; ///< \~chinese 控制输入端点 \~english Control input endpoint - unsigned char CrtlOutEndPoint; ///< \~chinese 控制输出端点 \~english Control output endpoint - unsigned char StreamEndPoint; ///< \~chinese 流端点 \~english Flow endpoint - unsigned char EventEndPoint; ///< \~chinese 事件端点 \~english Event endpoint - unsigned short idVendor; ///< \~chinese 供应商ID号 \~english Vendor ID Number - unsigned short idProduct; ///< \~chinese 产品ID号 \~english Device ID Number - unsigned int nDeviceNumber; ///< \~chinese 设备序列号 \~english Device Serial Number - unsigned char chDeviceGUID[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 设备GUID号 \~english Device GUID Number - unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 供应商名字 \~english Vendor Name - unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 型号名字 \~english Model Name - unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 家族名字 \~english Family Name - unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 设备版本号 \~english Device Version - unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 制造商名字 \~english Manufacturer Name - unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 序列号 \~english Serial Number - unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 用户自定义名字 \~english User Defined Name - unsigned int nbcdUSB; ///< \~chinese 支持的USB协议 \~english Support USB Protocol - - unsigned int nReserved[3]; ///< \~chinese 保留字节 \~english Reserved bytes -}MV_USB3_DEVICE_INFO; - -/// \~chinese -/// \brief CamLink设备信息 -/// \~english -/// \brief CamLink device info -typedef struct _MV_CamL_DEV_INFO_ -{ - unsigned char chPortID[INFO_MAX_BUFFER_SIZE]; - unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; - unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; - unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; - unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; - unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; - - unsigned int nReserved[38]; -}MV_CamL_DEV_INFO; - -/// \~chinese -/// \brief 设备信息 -/// \~english -/// \brief Device info -typedef struct _MV_CC_DEVICE_INFO_ -{ - unsigned short nMajorVer; - unsigned short nMinorVer; - unsigned int nMacAddrHigh; ///< \~chinese MAC 地址\~english MAC Address - unsigned int nMacAddrLow; - - unsigned int nTLayerType; ///< \~chinese 设备传输层协议类型,e.g. MV_GIGE_DEVICE\~english Device Transport Layer Protocol Type, e.g. MV_GIGE_DEVICE - - unsigned int nReserved[4]; - - union - { - MV_GIGE_DEVICE_INFO stGigEInfo; - MV_USB3_DEVICE_INFO stUsb3VInfo; - MV_CamL_DEV_INFO stCamLInfo; - // more ... - }SpecialInfo; - -}MV_CC_DEVICE_INFO; - -/// \~chinese 网络传输的相关信息\~english Network transmission information -typedef struct _MV_NETTRANS_INFO_ -{ - int64_t nReviceDataSize; ///< \~chinese 已接收数据大小 [统计StartGrabbing和StopGrabbing之间的数据量]\~english Received Data Size [Calculate the Data Size between StartGrabbing and StopGrabbing] - int nThrowFrameCount; ///< \~chinese 丢帧数量\~english Throw frame number - unsigned int nNetRecvFrameCount; - int64_t nRequestResendPacketCount; ///< \~chinese 请求重发包数 - int64_t nResendPacketCount; ///< \~chinese 重发包数 - -}MV_NETTRANS_INFO; - -#define MV_MAX_TLS_NUM 8 ///< \~chinese 最多支持的传输层实例个数\~english The maximum number of supported transport layer instances -#define MV_MAX_DEVICE_NUM 256 ///< \~chinese 最大支持的设备个数\~english The maximum number of supported devices - -/// \~chinese -/// \brief 设备信息列表 -/// \~english -/// \brief Device Information List -typedef struct _MV_CC_DEVICE_INFO_LIST_ -{ - unsigned int nDeviceNum; ///< \~chinese 在线设备数量\~english Online Device Number - MV_CC_DEVICE_INFO* pDeviceInfo[MV_MAX_DEVICE_NUM]; ///< \~chinese 支持最多256个设备\~english Support up to 256 devices - -}MV_CC_DEVICE_INFO_LIST; - - -/// \~chinese Chunk内容 \~english The content of ChunkData -typedef struct _MV_CHUNK_DATA_CONTENT_ -{ - unsigned char* pChunkData; - unsigned int nChunkID; - unsigned int nChunkLen; - - unsigned int nReserved[8]; // 保留 - -}MV_CHUNK_DATA_CONTENT; - -/// \~chinese 输出帧的信息\~english Output Frame Information -typedef struct _MV_FRAME_OUT_INFO_ -{ - unsigned short nWidth; ///< \~chinese 图像宽 \~english Image Width - unsigned short nHeight; ///< \~chinese 图像高 \~english Image Height - enum MvGvspPixelType enPixelType; ///< \~chinese 像素格式 \~english Pixel Type - - unsigned int nFrameNum; ///< \~chinese 帧号 \~english Frame Number - unsigned int nDevTimeStampHigh; ///< \~chinese 时间戳高32位\~english Timestamp high 32 bits - unsigned int nDevTimeStampLow; ///< \~chinese 时间戳低32位\~english Timestamp low 32 bits - unsigned int nReserved0; ///< \~chinese 保留,8字节对齐\~english Reserved, 8-byte aligned - int64_t nHostTimeStamp; ///< \~chinese 主机生成的时间戳\~english Host-generated timestamp - - unsigned int nFrameLen; - - unsigned int nLostPacket; ///< \~chinese 本帧丢包数\~english Lost Pacekt Number In This Frame - unsigned int nReserved[2]; -}MV_FRAME_OUT_INFO; - -/// \~chinese 输出帧的信息\~english Output Frame Information -typedef struct _MV_FRAME_OUT_INFO_EX_ -{ - unsigned short nWidth; ///< \~chinese 图像宽 \~english Image Width - unsigned short nHeight; ///< \~chinese 图像高 \~english Image Height - enum MvGvspPixelType enPixelType; ///< \~chinese 像素格式 \~english Pixel Type - - unsigned int nFrameNum; ///< \~chinese 帧号 \~english Frame Number - unsigned int nDevTimeStampHigh; ///< \~chinese 时间戳高32位\~english Timestamp high 32 bits - unsigned int nDevTimeStampLow; ///< \~chinese 时间戳低32位\~english Timestamp low 32 bits - unsigned int nReserved0; ///< \~chinese 保留,8字节对齐\~english Reserved, 8-byte aligned - int64_t nHostTimeStamp; ///< \~chinese 主机生成的时间戳\~english Host-generated timestamp - - unsigned int nFrameLen; - - /// \~chinese 设备水印时标\~english Device frame-specific time scale - unsigned int nSecondCount; - unsigned int nCycleCount; - unsigned int nCycleOffset; - - float fGain; - float fExposureTime; - unsigned int nAverageBrightness; ///< \~chinese 平均亮度\~english Average brightness - - /// \~chinese 白平衡相关\~english White balance - unsigned int nRed; - unsigned int nGreen; - unsigned int nBlue; - - unsigned int nFrameCounter; - unsigned int nTriggerIndex; ///< \~chinese 触发计数\~english Trigger Counting - - unsigned int nInput; ///< \~chinese 输入\~english Input - unsigned int nOutput; ///< \~chinese 输出\~english Output - - /// \~chinese ROI区域\~english ROI Region - unsigned short nOffsetX; - unsigned short nOffsetY; - unsigned short nChunkWidth; - unsigned short nChunkHeight; - - unsigned int nLostPacket; ///< \~chinese 本帧丢包数\~english Lost Pacekt Number In This Frame - - unsigned int nUnparsedChunkNum;///< \~chinese 未解析的Chunkdata个数 - union - { - MV_CHUNK_DATA_CONTENT* pUnparsedChunkContent; - int64_t nAligning; - }UnparsedChunkList; - - unsigned int nReserved[36]; // 保留 -}MV_FRAME_OUT_INFO_EX; - -/// \~chinese 图像结构体,输出图像指针地址及图像信息\~english Image Struct, output the pointer of Image and the information of the specific image -typedef struct _MV_FRAME_OUT_ -{ - unsigned char* pBufAddr; ///< \~chinese 图像指针地址\~english pointer of image - MV_FRAME_OUT_INFO_EX stFrameInfo; ///< \~chinese 图像信息\~english information of the specific image - - unsigned int nRes[16]; ///< \~chinese 保留\~english reserved -}MV_FRAME_OUT; - - -typedef struct _MV_DISPLAY_FRAME_INFO_ -{ - void* hWnd; ///< \~chinese 窗口句柄\~english HWND - unsigned char* pData; ///< \~chinese 显示的数据\~english Data Buffer - unsigned int nDataLen; ///< \~chinese 数据长度\~english Data Size - unsigned short nWidth; ///< \~chinese 图像宽\~english Width - unsigned short nHeight; ///< \~chinese 图像高\~english Height - enum MvGvspPixelType enPixelType; ///< \~chinese 像素格式\~english Pixel format - unsigned int nRes[4]; - -}MV_DISPLAY_FRAME_INFO; - -/// \~chinese 保存图片格式\~english Save image type -enum MV_SAVE_IAMGE_TYPE -{ - MV_Image_Undefined = 0, - MV_Image_Bmp = 1, - MV_Image_Jpeg = 2, - MV_Image_Png = 3, - MV_Image_Tif = 4, -}; - -/// \~chinese 图片保存参数\~english Save Image Parameters -typedef struct _MV_SAVE_IMAGE_PARAM_T_ -{ - unsigned char* pData; ///< [IN] \~chinese 输入数据缓存\~english Input Data Buffer - unsigned int nDataLen; ///< [IN] \~chinese 输入数据大小\~english Input Data Size - enum MvGvspPixelType enPixelType; ///< [IN] \~chinese 输入数据的像素格式\~english Input Data Pixel Format - unsigned short nWidth; ///< [IN] \~chinese 图像宽\~english Image Width - unsigned short nHeight; ///< [IN] \~chinese 图像高\~english Image Height - - unsigned char* pImageBuffer; ///< [OUT] \~chinese 输出图片缓存\~english Output Image Buffer - unsigned int nImageLen; ///< [OUT] \~chinese 输出图片大小\~english Output Image Size - unsigned int nBufferSize; ///< [IN] \~chinese 提供的输出缓冲区大小\~english Output buffer size provided - enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese 输出图片格式\~english Output Image Format - -}MV_SAVE_IMAGE_PARAM; - -/// \~chinese 图片保存参数\~english Save Image Parameters -typedef struct _MV_SAVE_IMAGE_PARAM_T_EX_ -{ - unsigned char* pData; ///< [IN] \~chinese 输入数据缓存\~english Input Data Buffer - unsigned int nDataLen; ///< [IN] \~chinese 输入数据大小\~english Input Data Size - enum MvGvspPixelType enPixelType; ///< [IN] \~chinese 输入数据的像素格式\~english Input Data Pixel Format - unsigned short nWidth; ///< [IN] \~chinese 图像宽\~english Image Width - unsigned short nHeight; ///< [IN] \~chinese 图像高\~english Image Height - - unsigned char* pImageBuffer; ///< [OUT] \~chinese 输出图片缓存\~english Output Image Buffer - unsigned int nImageLen; ///< [OUT] \~chinese 输出图片大小\~english Output Image Size - unsigned int nBufferSize; ///< [IN] \~chinese 提供的输出缓冲区大小\~english Output buffer size provided - enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese 输出图片格式\~english Output Image Format - unsigned int nJpgQuality; ///< [IN] \~chinese JPG编码质量(50-99],其它格式无效\~english Encoding quality(50-99],Other formats are invalid - - ///< [IN] \~chinese Bayer格式转为RGB24的插值方法 0-最近邻 1-双线性 2-Hamilton (如果传入其它值则默认为最近邻) - ///< [IN] \~english Interpolation method of convert Bayer to RGB24 0-nearest neighbour 1-bilinearity 2-Hamilton - unsigned int iMethodValue; - unsigned int nReserved[3]; - -}MV_SAVE_IMAGE_PARAM_EX; - - -/// \~chinese 图像转换结构体 \~english Pixel convert structure -typedef struct _MV_PIXEL_CONVERT_PARAM_T_ -{ - unsigned short nWidth; ///< [IN] \~chinese 图像宽 \~english Width - unsigned short nHeight; ///< [IN] \~chinese 图像高\~english Height - - enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese 源像素格式\~english Source pixel format - unsigned char* pSrcData; ///< [IN] \~chinese 输入数据缓存\~english Input data buffer - unsigned int nSrcDataLen; ///< [IN] \~chinese 输入数据大小\~english Input data size - - enum MvGvspPixelType enDstPixelType; ///< [IN] \~chinese 目标像素格式\~english Destination pixel format - unsigned char* pDstBuffer; ///< [OUT] \~chinese 输出数据缓存\~english Output data buffer - unsigned int nDstLen; ///< [OUT] \~chinese 输出数据大小\~english Output data size - unsigned int nDstBufferSize; ///< [IN] \~chinese 提供的输出缓冲区大小\~english Provided outbut buffer size - - unsigned int nRes[4]; -}MV_CC_PIXEL_CONVERT_PARAM; - -/// \~chinese 录像格式定义\~english Record Format Type -typedef enum _MV_RECORD_FORMAT_TYPE_ -{ - MV_FormatType_Undefined = 0, - MV_FormatType_AVI = 1, - -}MV_RECORD_FORMAT_TYPE; - -/// \~chinese 录像参数\~english Record Parameters -typedef struct _MV_CC_RECORD_PARAM_T_ -{ - enum MvGvspPixelType enPixelType; ///< [IN] \~chinese 输入数据的像素格式 - - unsigned short nWidth; ///< [IN] \~chinese 图像宽(指定目标参数时需为2的倍数) - unsigned short nHeight; ///< [IN] \~chinese 图像高(指定目标参数时需为2的倍数) - - float fFrameRate; ///< [IN] \~chinese 帧率fps(1/16-120) - unsigned int nBitRate; ///< [IN] \~chinese 码率kbps(128kbps-16Mbps) - - MV_RECORD_FORMAT_TYPE enRecordFmtType; ///< [IN] \~chinese 录像格式 - - char* strFilePath; ///< [IN] \~chinese 录像文件存放路径(如果路径中存在中文,需转成utf-8) - - unsigned int nRes[8]; - -}MV_CC_RECORD_PARAM; - -/// \~chinese 录像数据\~english Record Data -typedef struct _MV_CC_INPUT_FRAME_INFO_T_ -{ - unsigned char* pData; ///< [IN] \~chinese 图像数据指针 - unsigned int nDataLen; ///< [IN] \~chinese 图像大小 - - unsigned int nRes[8]; - -}MV_CC_INPUT_FRAME_INFO; - -/// \~chinese 采集模式\~english Acquisition mode -typedef enum _MV_CAM_ACQUISITION_MODE_ -{ - MV_ACQ_MODE_SINGLE = 0, ///< \~chinese 单帧模式\~english Single Mode - MV_ACQ_MODE_MUTLI = 1, ///< \~chinese 多帧模式\~english Multi Mode - MV_ACQ_MODE_CONTINUOUS = 2, ///< \~chinese 持续采集模式\~english Continuous Mode - -}MV_CAM_ACQUISITION_MODE; - -/// \~chinese 增益模式\~english Gain Mode -typedef enum _MV_CAM_GAIN_MODE_ -{ - MV_GAIN_MODE_OFF = 0, ///< \~chinese 关闭\~english Single Mode - MV_GAIN_MODE_ONCE = 1, ///< \~chinese 一次\~english Multi Mode - MV_GAIN_MODE_CONTINUOUS = 2, ///< \~chinese 连续\~english Continuous Mode - -}MV_CAM_GAIN_MODE; - -/// \~chinese 曝光模式\~english Exposure Mode -typedef enum _MV_CAM_EXPOSURE_MODE_ -{ - MV_EXPOSURE_MODE_TIMED = 0, ///< Timed - MV_EXPOSURE_MODE_TRIGGER_WIDTH = 1, ///< TriggerWidth -}MV_CAM_EXPOSURE_MODE; - -/// \~chinese 自动曝光模式 \~english Auto Exposure Mode -typedef enum _MV_CAM_EXPOSURE_AUTO_MODE_ -{ - MV_EXPOSURE_AUTO_MODE_OFF = 0, ///< \~chinese 关闭\~english Off - MV_EXPOSURE_AUTO_MODE_ONCE = 1, ///< \~chinese 一次\~english Once - MV_EXPOSURE_AUTO_MODE_CONTINUOUS = 2, ///< \~chinese 连续\~english Continuous - -}MV_CAM_EXPOSURE_AUTO_MODE; - -/// \~chinese 触发模式 \~english Trigger Mode -typedef enum _MV_CAM_TRIGGER_MODE_ -{ - MV_TRIGGER_MODE_OFF = 0, ///< \~chinese 关闭\~english Off - MV_TRIGGER_MODE_ON = 1, ///< \~chinese 打开\~english ON - -}MV_CAM_TRIGGER_MODE; - -typedef enum _MV_CAM_GAMMA_SELECTOR_ -{ - MV_GAMMA_SELECTOR_USER = 1, - MV_GAMMA_SELECTOR_SRGB = 2, - -}MV_CAM_GAMMA_SELECTOR; - -typedef enum _MV_CAM_BALANCEWHITE_AUTO_ -{ - MV_BALANCEWHITE_AUTO_OFF = 0, - MV_BALANCEWHITE_AUTO_ONCE = 2, - MV_BALANCEWHITE_AUTO_CONTINUOUS = 1, ///< \~chinese 连续\~english Continuous - -}MV_CAM_BALANCEWHITE_AUTO; - -typedef enum _MV_CAM_TRIGGER_SOURCE_ -{ - MV_TRIGGER_SOURCE_LINE0 = 0, - MV_TRIGGER_SOURCE_LINE1 = 1, - MV_TRIGGER_SOURCE_LINE2 = 2, - MV_TRIGGER_SOURCE_LINE3 = 3, - MV_TRIGGER_SOURCE_COUNTER0 = 4, - - MV_TRIGGER_SOURCE_SOFTWARE = 7, - MV_TRIGGER_SOURCE_FrequencyConverter= 8, - -}MV_CAM_TRIGGER_SOURCE; - -typedef enum _MV_GIGE_TRANSMISSION_TYPE_ -{ - MV_GIGE_TRANSTYPE_UNICAST = 0x0, ///< \~chinese 表示单播(默认)\~english Unicast mode - MV_GIGE_TRANSTYPE_MULTICAST = 0x1, ///< \~chinese 表示组播\~english Multicast mode - MV_GIGE_TRANSTYPE_LIMITEDBROADCAST = 0x2, ///< \~chinese 表示局域网内广播,暂不支持\~english Limited broadcast mode,not support - MV_GIGE_TRANSTYPE_SUBNETBROADCAST = 0x3, ///< \~chinese 表示子网内广播,暂不支持\~english Subnet broadcast mode,not support - MV_GIGE_TRANSTYPE_CAMERADEFINED = 0x4, ///< \~chinese 表示从相机获取,暂不支持\~english Transtype from camera,not support - MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT = 0x5, ///< \~chinese 表示用户自定义应用端接收图像数据Port号\~english User Defined Receive Data Port - MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV = 0x00010000, ///< \~chinese 表示设置了单播,但本实例不接收图像数据\~english Unicast without receive data - MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV = 0x00010001, ///< \~chinese 表示组播模式,但本实例不接收图像数据\~english Multicast without receive data -}MV_GIGE_TRANSMISSION_TYPE; -// GigEVision IP Configuration -#define MV_IP_CFG_STATIC 0x05000000 -#define MV_IP_CFG_DHCP 0x06000000 -#define MV_IP_CFG_LLA 0x04000000 - -// GigEVision Net Transfer Mode -#define MV_NET_TRANS_DRIVER 0x00000001 -#define MV_NET_TRANS_SOCKET 0x00000002 - -// CameraLink Baud Rates (CLUINT32) -#define MV_CAML_BAUDRATE_9600 0x00000001 -#define MV_CAML_BAUDRATE_19200 0x00000002 -#define MV_CAML_BAUDRATE_38400 0x00000004 -#define MV_CAML_BAUDRATE_57600 0x00000008 -#define MV_CAML_BAUDRATE_115200 0x00000010 -#define MV_CAML_BAUDRATE_230400 0x00000020 -#define MV_CAML_BAUDRATE_460800 0x00000040 -#define MV_CAML_BAUDRATE_921600 0x00000080 -#define MV_CAML_BAUDRATE_AUTOMAX 0x40000000 - -/// \~chinese 信息类型\~english Information Type -#define MV_MATCH_TYPE_NET_DETECT 0x00000001 ///< \~chinese 网络流量和丢包信息\~english Network traffic and packet loss information -#define MV_MATCH_TYPE_USB_DETECT 0x00000002 ///< \~chinese host接收到来自U3V设备的字节总数\~english The total number of bytes host received from U3V device - -/// \~chinese 某个节点对应的子节点个数最大值\~english The maximum number of child nodes corresponding to a node -#define MV_MAX_XML_NODE_NUM_C 128 - -/// \~chinese 节点名称字符串最大长度\~english The maximum length of node name string -#define MV_MAX_XML_NODE_STRLEN_C 64 - -/// \~chinese 节点String值最大长度\~english The maximum length of Node String -#define MV_MAX_XML_STRVALUE_STRLEN_C 64 - -/// \~chinese 节点描述字段最大长度\~english The maximum length of the node description field -#define MV_MAX_XML_DISC_STRLEN_C 512 - -/// \~chinese 最多的单元数\~englishThe maximum number of units -#define MV_MAX_XML_ENTRY_NUM 10 - -/// \~chinese 父节点个数上限\~english The maximum number of parent nodes -#define MV_MAX_XML_PARENTS_NUM 8 - -/// \~chinese 每个已经实现单元的名称长度\~english The length of the name of each unit that has been implemented -#define MV_MAX_XML_SYMBOLIC_STRLEN_C 64 - -#define MV_MAX_XML_SYMBOLIC_NUM 64 - - -/// \~chinese 全匹配的一种信息结构体\~english A fully matched information structure -typedef struct _MV_ALL_MATCH_INFO_ -{ - unsigned int nType; ///< \~chinese 需要输出的信息类型,e.g. MV_MATCH_TYPE_NET_DETECT\~english Information type need to output ,e.g. MV_MATCH_TYPE_NET_DETECT - void* pInfo; ///< \~chinese 输出的信息缓存,由调用者分配\~english Output information cache, which is allocated by the caller - unsigned int nInfoSize; ///< \~chinese 信息缓存的大小\~english Information cache size - -}MV_ALL_MATCH_INFO; - - - -/// \~chinese 网络流量和丢包信息反馈结构体,对应类型为 MV_MATCH_TYPE_NET_DETECT -/// \~en:Network traffic and packet loss feedback structure, the corresponding type is MV_MATCH_TYPE_NET_DETECT -typedef struct _MV_MATCH_INFO_NET_DETECT_ -{ - int64_t nReviceDataSize; ///< \~chinese 已接收数据大小 [统计StartGrabbing和StopGrabbing之间的数据量]\~english Received data size - int64_t nLostPacketCount; ///< \~chinese 丢失的包数量\~english Number of packets lost - unsigned int nLostFrameCount; ///< \~chinese 丢帧数量\~english Number of frames lost - unsigned int nNetRecvFrameCount; ///< \~chinese 保留\~english Reserved - int64_t nRequestResendPacketCount; ///< \~chinese 请求重发包数 - int64_t nResendPacketCount; ///< \~chinese 重发包数 -}MV_MATCH_INFO_NET_DETECT; - -/// \~chinese host收到从u3v设备端的总字节数,对应类型为 MV_MATCH_TYPE_USB_DETECT\~english The total number of bytes host received from the u3v device side, the corresponding type is MV_MATCH_TYPE_USB_DETECT -typedef struct _MV_MATCH_INFO_USB_DETECT_ -{ - int64_t nReviceDataSize; ///< \~chinese 已接收数据大小 [统计OpenDevicce和CloseDevice之间的数据量]\~english Received data size - unsigned int nRevicedFrameCount; ///< \~chinese 已收到的帧数\~english Number of frames received - unsigned int nErrorFrameCount; ///< \~chinese 错误帧数\~english Number of error frames - unsigned int nReserved[2]; ///< \~chinese 保留\~english Reserved -}MV_MATCH_INFO_USB_DETECT; - -typedef struct _MV_IMAGE_BASIC_INFO_ -{ - // width - unsigned short nWidthValue; - unsigned short nWidthMin; - unsigned int nWidthMax; - unsigned int nWidthInc; - - // height - unsigned int nHeightValue; - unsigned int nHeightMin; - unsigned int nHeightMax; - unsigned int nHeightInc; - - // framerate - float fFrameRateValue; - float fFrameRateMin; - float fFrameRateMax; - - /// \~chinese 像素格式\~english pixel format - unsigned int enPixelType; ///< \~chinese 当前的像素格式\~english Current pixel format - unsigned int nSupportedPixelFmtNum; ///< \~chinese 支持的像素格式种类\~english Support pixel format - unsigned int enPixelList[MV_MAX_XML_SYMBOLIC_NUM]; - unsigned int nReserved[8]; - -}MV_IMAGE_BASIC_INFO; - -/// \~chinese 异常消息类型\~english Exception message type -#define MV_EXCEPTION_DEV_DISCONNECT 0x00008001 ///< \~chinese 设备断开连接\~english The device is disconnected -#define MV_EXCEPTION_VERSION_CHECK 0x00008002 ///< \~chinese SDK与驱动版本不匹配\~english SDK does not match the driver version -/// \~chinese 设备的访问模式\~english Device Access Mode -/// \~chinese 独占权限,其他APP只允许读CCP寄存器\~english Exclusive authority, other APP is only allowed to read the CCP register -#define MV_ACCESS_Exclusive 1 -/// \~chinese 可以从5模式下抢占权限,然后以独占权限打开\~english You can seize the authority from the 5 mode, and then open with exclusive authority -#define MV_ACCESS_ExclusiveWithSwitch 2 -/// \~chinese 控制权限,其他APP允许读所有寄存器\~english Control authority, allows other APP reading all registers -#define MV_ACCESS_Control 3 -/// \~chinese 可以从5的模式下抢占权限,然后以控制权限打开\~english You can seize the authority from the 5 mode, and then open with control authority -#define MV_ACCESS_ControlWithSwitch 4 -/// \~chinese 以可被抢占的控制权限打开\~english Open with seized control authority -#define MV_ACCESS_ControlSwitchEnable 5 -/// \~chinese 可以从5的模式下抢占权限,然后以可被抢占的控制权限打开\~english You can seize the authority from the 5 mode, and then open with seized control authority -#define MV_ACCESS_ControlSwitchEnableWithKey 6 -/// \~chinese 读模式打开设备,适用于控制权限下\~english Open with read mode and is available under control authority -#define MV_ACCESS_Monitor 7 - - -/************************************************************************/ -/* 封装了GenICam的C接口相关参数定义 */ -/* Package of GenICam C interface-related parameters definition */ -/************************************************************************/ - -/// \~chinese 每个节点对应的接口类型\~english Interface type corresponds to each node -enum MV_XML_InterfaceType -{ - IFT_IValue, //!> IValue interface - IFT_IBase, //!> IBase interface - IFT_IInteger, //!> IInteger interface - IFT_IBoolean, //!> IBoolean interface - IFT_ICommand, //!> ICommand interface - IFT_IFloat, //!> IFloat interface - IFT_IString, //!> IString interface - IFT_IRegister, //!> IRegister interface - IFT_ICategory, //!> ICategory interface - IFT_IEnumeration, //!> IEnumeration interface - IFT_IEnumEntry, //!> IEnumEntry interface - IFT_IPort, //!> IPort interface -}; - -/// \~chinese 节点的访问模式\~english Node Access Mode -enum MV_XML_AccessMode -{ - AM_NI, //!< Not implemented - AM_NA, //!< Not available - AM_WO, //!< Write Only - AM_RO, //!< Read Only - AM_RW, //!< Read and Write - AM_Undefined, //!< Object is not yet initialized - AM_CycleDetect, //!< used internally for AccessMode cycle detection -}; - -/// \~chinese 节点的可见性权限\~english Node Visible Permission -enum MV_XML_Visibility -{ - V_Beginner = 0, //!< Always visible - V_Expert = 1, //!< Visible for experts or Gurus - V_Guru = 2, //!< Visible for Gurus - V_Invisible = 3, //!< Not Visible - V_Undefined = 99 //!< Object is not yet initialized -}; - -/// \~chinese Event事件回调信息\~english Event callback infomation -#define MAX_EVENT_NAME_SIZE 128 // 相机Event事件名称最大长度\~english Max length of event name - -typedef struct _MV_EVENT_OUT_INFO_ -{ - char EventName[MAX_EVENT_NAME_SIZE]; ///< \~chinese Event名称\~english Event name - - unsigned short nEventID; ///< \~chinese Event号\~english Event ID - unsigned short nStreamChannel; ///< \~chinese 流通道序号\~english Circulation number - - unsigned int nBlockIdHigh; ///< \~chinese 帧号高位\~english BlockId high - unsigned int nBlockIdLow; ///< \~chinese 帧号低位\~english BlockId low - - unsigned int nTimestampHigh; ///< \~chinese 时间戳高位\~english Timestramp high - unsigned int nTimestampLow; ///< \~chinese 时间戳低位\~english Timestramp low - - void* pEventData; ///< \~chinese Event数据\~english Event data - unsigned int nEventDataSize; ///< \~chinese Event数据长度\~english Event data len - - unsigned int nReserved[16]; ///< \~chinese 预留\~english Reserved -}MV_EVENT_OUT_INFO; - -/// \~chinese 文件存取\~english File Access -typedef struct _MV_CC_FILE_ACCESS_T -{ - const char* pUserFileName; ///< \~chinese 用户文件名\~english User file name - const char* pDevFileName; ///< \~chinese 设备文件名\~english Device file name - - unsigned int nReserved[32]; ///< \~chinese 预留\~english Reserved -}MV_CC_FILE_ACCESS; - -/// \~chinese 文件存取进度\~english File Access Progress -typedef struct _MV_CC_FILE_ACCESS_PROGRESS_T -{ - int64_t nCompleted; ///< \~chinese 已完成的长度\~english Completed Length - int64_t nTotal; ///< \~chinese 总长度\~english Total Length - - unsigned int nReserved[8]; ///< \~chinese 预留\~english Reserved -}MV_CC_FILE_ACCESS_PROGRESS; - - - -/// \~chinese 传输模式,可以为单播模式、组播模式等\~english Transmission type -typedef struct _MV_TRANSMISSION_TYPE_T -{ - MV_GIGE_TRANSMISSION_TYPE enTransmissionType; ///< \~chinese 传输模式\~english Transmission type - unsigned int nDestIp; ///< \~chinese 目标IP,组播模式下有意义\~english Destination IP - unsigned short nDestPort; ///< \~chinese 目标Port,组播模式下有意义\~english Destination port - - unsigned int nReserved[32]; ///< \~chinese 预留\~english Reserved -}MV_TRANSMISSION_TYPE; - -/// \~chinese 动作命令信息\~english Action Command -typedef struct _MV_ACTION_CMD_INFO_T -{ - unsigned int nDeviceKey; ///< \~chinese 设备密钥 - unsigned int nGroupKey; ///< \~chinese 组键 - unsigned int nGroupMask; ///< \~chinese 组掩码 - - unsigned int bActionTimeEnable; ///< \~chinese 只有设置成1时Action Time才有效,非1时无效 - int64_t nActionTime; ///< \~chinese 预定的时间,和主频有关 - - const char* pBroadcastAddress; ///< \~chinese 广播包地址 - unsigned int nTimeOut; ///< \~chinese 等待ACK的超时时间,如果为0表示不需要ACK - - unsigned int nReserved[16]; ///< \~chinese 预留\~english Reserved - -}MV_ACTION_CMD_INFO; - -/// \~chinese 动作命令返回信息\~english Action Command Result -typedef struct _MV_ACTION_CMD_RESULT_T -{ - unsigned char strDeviceAddress[12 + 3 + 1]; ///< IP address of the device - - //status code returned by the device - int nStatus;//1.0x0000:success. - //2.0x8001:Command is not supported by the device. - //3.0x8013:The device is not synchronized to a master clock to be used as time reference. - //4.0x8015:A device queue or packet data has overflowed. - //5.0x8016:The requested scheduled action command was requested at a time that is already past. - - unsigned int nReserved[4]; ///< \~chinese 预留\~english Reserved - -}MV_ACTION_CMD_RESULT; - -/// \~chinese 动作命令返回信息列表\~english Action Command Result List -typedef struct _MV_ACTION_CMD_RESULT_LIST_T -{ - unsigned int nNumResults; ///< \~chinese 返回值个数 - MV_ACTION_CMD_RESULT* pResults; - -}MV_ACTION_CMD_RESULT_LIST; - -// ch:单个节点基本属性 | en:Single Node Basic Attributes -typedef struct _MV_XML_NODE_FEATURE_ -{ - enum MV_XML_InterfaceType enType; ///< \~chinese 节点类型\~english Node Type - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Is visibility - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述,目前暂不支持\~english Node Description, NOT SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - - unsigned int nReserved[4]; -}MV_XML_NODE_FEATURE; - -/// \~chinese 节点列表\~english Node List -typedef struct _MV_XML_NODES_LIST_ -{ - unsigned int nNodeNum; ///< \~chinese 节点个数\~english Node Number - MV_XML_NODE_FEATURE stNodes[MV_MAX_XML_NODE_NUM_C]; -}MV_XML_NODES_LIST; - - - -typedef struct _MV_XML_FEATURE_Value_ -{ - enum MV_XML_InterfaceType enType; ///< \~chinese节点类型\~english Node Type - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese节点描述 目前暂不支持\~english Node Description, NOT SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - unsigned int nReserved[4]; -}MV_XML_FEATURE_Value; - -typedef struct _MV_XML_FEATURE_Base_ -{ - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode -}MV_XML_FEATURE_Base; - -typedef struct _MV_XML_FEATURE_Integer_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int64_t nValue; ///< \~chinese 当前值\~english Current Value - int64_t nMinValue; ///< \~chinese 最小值\~english Min Value - int64_t nMaxValue; ///< \~chinese 最大值\~english Max Value - int64_t nIncrement; ///< \~chinese 增量\~english Increment - - unsigned int nReserved[4]; - -}MV_XML_FEATURE_Integer; - -typedef struct _MV_XML_FEATURE_Boolean_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - bool bValue; ///< \~chinese 当前值\~english Current Value - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Boolean; - -typedef struct _MV_XML_FEATURE_Command_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Command; - -typedef struct _MV_XML_FEATURE_Float_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - double dfValue; ///< \~chinese 当前值\~english Current Value - double dfMinValue; ///< \~chinese 最小值\~english Min Value - double dfMaxValue; ///< \~chinese 最大值\~english Max Value - double dfIncrement; ///< \~chinese 增量\~english Increment - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Float; - -typedef struct _MV_XML_FEATURE_String_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - char strValue[MV_MAX_XML_STRVALUE_STRLEN_C]; ///< \~chinese 当前值\~english Current Value - - unsigned int nReserved[4]; -}MV_XML_FEATURE_String; - -typedef struct _MV_XML_FEATURE_Register_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int64_t nAddrValue; ///< \~chinese 当前值\~english Current Value - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Register; - -typedef struct _MV_XML_FEATURE_Category_ -{ - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述 目前暂不支持\~english Node Description, NOT SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Category; - -typedef struct _MV_XML_FEATURE_EnumEntry_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - int bIsImplemented; - int nParentsNum; - MV_XML_NODE_FEATURE stParentsList[MV_MAX_XML_PARENTS_NUM]; - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - int64_t nValue; ///< \~chinese 当前值\~english Current Value - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int nReserved[8]; - -}MV_XML_FEATURE_EnumEntry; - - -typedef struct _MV_XML_FEATURE_Enumeration_ -{ - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述 目前暂不支持\~english Node Description, NOT SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - - int nSymbolicNum; ///< \~chinese Symbolic数\~english Symbolic Number - char strCurrentSymbolic[MV_MAX_XML_SYMBOLIC_STRLEN_C]; ///< \~chinese 当前Symbolic索引\~english Current Symbolic Index - char strSymbolic[MV_MAX_XML_SYMBOLIC_NUM][MV_MAX_XML_SYMBOLIC_STRLEN_C]; - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int64_t nValue; ///< \~chinese 当前值\~english Current Value - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Enumeration; - - -typedef struct _MV_XML_FEATURE_Port_ -{ - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述 目前暂不支持\~english Node Description, NOT SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - - unsigned int nReserved[4]; -}MV_XML_FEATURE_Port; - -typedef struct _MV_XML_CAMERA_FEATURE_ -{ - enum MV_XML_InterfaceType enType; - union - { - MV_XML_FEATURE_Integer stIntegerFeature; - MV_XML_FEATURE_Float stFloatFeature; - MV_XML_FEATURE_Enumeration stEnumerationFeature; - MV_XML_FEATURE_String stStringFeature; - }SpecialFeature; - -}MV_XML_CAMERA_FEATURE; - -typedef struct _MVCC_ENUMVALUE_T -{ - unsigned int nCurValue; ///< \~chinese 当前值\~english Current Value - unsigned int nSupportedNum; ///< \~chinese 数据的有效数据个数\~english Number of valid data - unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; - - unsigned int nReserved[4]; -}MVCC_ENUMVALUE; - -typedef struct _MVCC_INTVALUE_T -{ - unsigned int nCurValue; ///< \~chinese 当前值\~english Current Value - unsigned int nMax; - unsigned int nMin; - unsigned int nInc; - - unsigned int nReserved[4]; -}MVCC_INTVALUE; - -typedef struct _MVCC_INTVALUE_EX_T -{ - int64_t nCurValue; ///< \~chinese 当前值\~english Current Value - int64_t nMax; - int64_t nMin; - int64_t nInc; - - unsigned int nReserved[16]; -}MVCC_INTVALUE_EX; - -typedef struct _MVCC_FLOATVALUE_T -{ - float fCurValue; ///< \~chinese 当前值\~english Current Value - float fMax; - float fMin; - - unsigned int nReserved[4]; -}MVCC_FLOATVALUE; - -typedef struct _MVCC_STRINGVALUE_T -{ - char chCurValue[256]; ///< \~chinese 当前值\~english Current Value - - int64_t nMaxLength; - unsigned int nReserved[2]; -}MVCC_STRINGVALUE; - -#endif /* _MV_CAMERA_PARAMS_H_ */ diff --git a/hnurm_camera/CameraCalibration/include/DataBuffer.hpp b/hnurm_camera/CameraCalibration/include/DataBuffer.hpp deleted file mode 100755 index e13f1f58dbd6ede2e433d892db38b184fb496aba..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/DataBuffer.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* kiko@idiospace.com 2020.01.20 */ - -#ifndef DataBuffer_HPP -#define DataBuffer_HPP - -#include -#include -#include -#include -#include -#include - -#include "easylogging++.h" - -using namespace std::chrono_literals; - -namespace hnurm -{ - template - class DataBuffer - { - public: - DataBuffer() = default; - - ~DataBuffer() = default; - - // 获取数据 - bool Get(DataType &data); - - // 更新数据 - bool Update(const DataType &data); - - private: - DataType data_buf; // 数据缓冲区 - std::timed_mutex mtx; // 互斥锁 - bool updated_flag = false; // 更新标志 - };// class DataBuffer - - template - bool DataBuffer::Get(DataType &data) - { - if (mtx.try_lock_for(2ms)) - { - if(!updated_flag) - { - mtx.unlock(); - return false; - } - LOG(WARNING) << "Success to lock in GET, UPDATED"; - data = data_buf; - updated_flag = false; - mtx.unlock(); - return true; - } - LOG(WARNING) << "Failed to lock in GET"; - return false; - } - - template - bool DataBuffer::Update(const DataType &data) - { - if (mtx.try_lock_for(2ms)) - { - LOG(WARNING) << "Success to lock in UPDATE"; - data_buf = data; - updated_flag = true; - mtx.unlock(); - return true; - } - LOG(WARNING) << "Failed to lock in UPDATE"; - return false; - } -}// namespace hnurm - - -#endif// DataBuffer_HPP diff --git a/hnurm_camera/CameraCalibration/include/DataType.hpp b/hnurm_camera/CameraCalibration/include/DataType.hpp deleted file mode 100755 index b04ebf81744435018b77ebce0739985f26c262e8..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/DataType.hpp +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef DATATYPE_H -#define DATATYPE_H - -#include -#include "easylogging++.h" - -namespace hnurm { - // 工作模式 - enum class WorkMode : int { - auto_shoot = 0, // 英雄、步兵 - auto_sbuff = 1, // 步兵 - auto_bbuff = 2, // 步兵 - }; - - // 自己的颜色 - enum class SelfColor : int { - color_none = 0, - red = 1, - blue = 2, - }; - - // 子弹速度 - enum class BulletSpeed : int { - bulle_speed_none = 0, - hero10 = 10, - hero16 = 16, - infantry15 = 15, - infantry18 = 18, - infantry30 = 30 // 炮塔拥有相同的子弹速度 - }; - - // 目标状态 - enum class TargetState : int { - lost_target = 0, - converging = 1, - fire = 2, - }; - - // 目标类型 - enum class TargetType : int { - none = 0, - hero = 1, - engineer = 2, - infantry3 = 3, - infantry4 = 4, - infantry5 = 5, - outpost = 6, - guard = 7, - base = 8, - }; - - /** - * @brief 相机输出,传递给detector进行识别 - */ - struct ImgInfo { - ImgInfo() = default; - explicit ImgInfo(cv::Mat &raw_img) - { - time_stamp = std::chrono::steady_clock::now(); - img = raw_img.clone(); - } - cv::Mat img; - std::chrono::steady_clock::time_point time_stamp; - }; - - /** - * @brief 由Processor输出的目标信息,传递给Compensator进行补偿计算 - */ - struct TargetInfo { - TargetInfo() = default; - - TargetState state; // 目标状态 - TargetType type; // 目标类型 - - float x{}, y{}, z{}; // 目标的坐标 - float vx{}, vy{}, vz{}; // 目标的速度 - float w_yaw{}, yaw{}; // 目标的角速度和期望的偏航角 - float radius_1{}, radius_2{}; // 目标的半径 - float dz{}; // 目标与玩家之间的距离 - }; - - /** - * @brief 由Compensator输出的补偿后的目标信息,传递给serial进行发送 - */ - struct VisionSendData : public el::Loggable { - VisionSendData() = default; - VisionSendData(TargetState state_, TargetType type_, float pitch_, float yaw_) - : state(state_) - , type(type_) - , pitch(pitch_) - , yaw(yaw_) - { - } - - TargetState state; // 目标状态 - TargetType type; // 目标类型 - - float pitch ; // 期望的俯仰角,以浮点数形式存储 - float yaw ; // 期望的偏航角,以浮点数形式存储 - - virtual void log(el::base::type::ostream_t &os) const { - os << "pitch: " << pitch << "yaw: " << yaw << "target state" << (int)state; - } - }; - - /** - * @brief 由serial接收到的数据,传递给Processor用于计算装甲板的位姿 - */ - struct VisionRecvData : public el::Loggable { - VisionRecvData() = default; - VisionRecvData(SelfColor self_color_, WorkMode mode_, BulletSpeed speed_, float pitch_, float yaw_, float roll_) - : self_color(self_color_) - , mode(mode_) - , speed(speed_) - , pitch(pitch_) - , yaw(yaw_) - , roll(roll_) - { - } - - SelfColor self_color; // 自己的颜色,以标志寄存器的形式存储,低4位为低8位,高4位为高8位 - WorkMode mode; // 工作模式,以标志寄存器的形式存储,高4位为低8位,低4位为高8位 - BulletSpeed speed; // 子弹速度,以标志寄存器的形式存储,高4位为高8位,低4位为低8位 - - float pitch; // 俯仰角 - float yaw; // 偏航角 - float roll; // 翻滚角 - - // 重载<<运算符 - virtual void log(el::base::type::ostream_t &os) const { - os << "self_color: " << static_cast(self_color) << " mode: " << static_cast(mode) << " speed: " << static_cast(speed) << " pitch: " << pitch << " yaw: " << yaw << " roll: " << roll; - } - void init(){ - this->self_color = SelfColor::red; - this->mode = WorkMode::auto_shoot; - this->speed = BulletSpeed::infantry18; - this->pitch = 0; - this->yaw = 0; - this->roll = 0; - } - }; - - enum class ArmorsNum { NORMAL_4 = 4, BALANCE_2 = 2, OUTPOST_3 = 3 }; - -};// namespace hnurm - -#endif// !DATATYPE_H diff --git a/hnurm_camera/CameraCalibration/include/MvCameraControl.h b/hnurm_camera/CameraCalibration/include/MvCameraControl.h deleted file mode 100755 index 711022deb2a8e1f05efbc130f33294a3357c42cc..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/MvCameraControl.h +++ /dev/null @@ -1,3189 +0,0 @@ - -#ifndef _MV_CAMERA_CTRL_H_ -#define _MV_CAMERA_CTRL_H_ - -#include "MvErrorDefine.h" -#include "CameraParams.h" - -/** -* @brief 动态库导入导出定义 -* @brief Import and export definition of the dynamic library -*/ -#ifndef MV_CAMCTRL_API - - #if (defined (_WIN32) || defined(WIN64)) - #if defined(MV_CAMCTRL_EXPORTS) - #define MV_CAMCTRL_API __declspec(dllexport) - #else - #define MV_CAMCTRL_API __declspec(dllimport) - #endif - #else - #ifndef __stdcall - #define __stdcall - #endif - - #if defined(MV_CAMCTRL_EXPORTS) - #define MV_CAMCTRL_API __attribute__((visibility("default"))) - #else - #define MV_CAMCTRL_API - #endif - #endif - -#endif - -#ifndef IN - #define IN -#endif - -#ifndef OUT - #define OUT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/************************************************************************/ -/* 相机的基本指令和操作 */ -/* Camera basic instructions and operations */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 获取SDK版本号 - * @return 始终返回4字节版本号 - | 主 | 次 | 修正 | 测试 | - | :---: | :---: | :---: | :---: | - | 8bits | 8bits | 8bits | 8bits | - * @remarks 比如返回值为0x01000001,即SDK版本号为V1.0.0.1。 - - * @~english - * @brief Get SDK Version - * @return Always return 4 Bytes of version number - | Main | Sub | Rev | Test | - | :---: | :---: | :---: | :---: | - | 8bits | 8bits | 8bits | 8bits | - * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. - ************************************************************************/ -MV_CAMCTRL_API unsigned int __stdcall MV_CC_GetSDKVersion(); - -/********************************************************************//** - * @~chinese - * @brief 获取支持的传输层 - * @return 支持的传输层编号 - - * @~english - * @brief Get supported Transport Layer - * @return Supported Transport Layer number - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_EnumerateTls(); - -/********************************************************************//** - * @~chinese - * @brief 枚举设备 - * @param nTLayerType [IN] 枚举传输层 - * @param pstDevList [OUT] 设备列表 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 设备列表的内存是在SDK内部分配的,多线程调用该接口时会进行设备列表内存的释放和申请.\n - 建议尽量避免多线程枚举操作。 - - * @~english - * @brief Enumerate Device - * @param nTLayerType [IN] Enumerate TLs - * @param pstDevList [OUT] Device List - * @return Success, return #MV_OK. Failure, return error code - * @remarks @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n - It is recommended to avoid multithreaded enumeration operations as much as possible. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_EnumDevices(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList); - -/********************************************************************//** - * @~chinese - * @brief 根据厂商名字枚举设备 - * @param nTLayerType [IN] 枚举传输层 - * @param pstDevList [OUT] 设备列表 - * @param pManufacturerName [IN] 厂商名字 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Enumerate device according to manufacture name - * @param nTLayerType [IN] Transmission layer of enumeration - * @param pstDevList [OUT] Device list - * @param pManufacturerName [IN] Manufacture Name - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* pManufacturerName); - -/********************************************************************//** - * @~chinese - * @brief 设备是否可达 - * @param pstDevInfo [IN] 设备信息结构体 - * @param nAccessMode [IN] 访问权限 - * @return 可达,返回true;不可达,返回false - * @remarks 读取设备CCP寄存器的值,判断当前状态是否具有某种访问权限。 \n - 如果设备不支持 #MV_ACCESS_ExclusiveWithSwitch、 #MV_ACCESS_ControlWithSwitch、 #MV_ACCESS_ControlSwitchEnableWithKey这三种模式,接口返回false。目前设备不支持这3种抢占模式,国际上主流的厂商的相机也都暂不支持这3种模式。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Is the device accessible - * @param pstDevInfo [IN] Device Information Structure - * @param nAccessMode [IN] Access Right - * @return Access, return true. Not access, return false - @remarks Read device CCP register value and determine current access permission.\n - Return false if the device does not support the modes #MV_ACCESS_ExclusiveWithSwitch, #MV_ACCESS_ControlWithSwitch, #MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers. \n - This API is not supported by CameraLink device. - ************************************************************************/ -MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode); - -/********************************************************************//** - * @~chinese - * @brief 设置SDK日志路径(如果日志服务MvLogServer已启用,则该接口无效,默认日志服务为开启状态) - * @param pSDKLogPath [IN] SDK日志路径 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 设置路径之后,可以指定路径存放日志。\n - v2.4.1版本新增日志服务,开启服务之后该接口无效。 - - * @~english - * @brief Set SDK log path - * @param pSDKLogPath [IN] SDK log path - * @return Access, return true. Not access, return false - * @remarks For version V2.4.1, added log service, this API is invalid when the service is enabled.And The logging service is enabled by default\n - This API is used to set the log file storing path. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetSDKLogPath(IN const char * pSDKLogPath); - -/********************************************************************//** - * @~chinese - * @brief 创建设备句柄 - * @param handle [OUT] 设备句柄 - * @param pstDevInfo [IN] 设备信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 根据输入的设备信息,创建库内部必须的资源和初始化内部模块。通过该接口创建句柄,调用SDK接口,会默认生成SDK日志文件,保存在当前可执行程序路径下的MvSdkLog文件夹,如果不需要生成日志文件,可以通过MV_CC_CreateHandleWithoutLog创建句柄。 - - * @~english - * @brief Create Device Handle - * @param handle [OUT] Device handle - * @param pstDevInfo [IN] Device Information Structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will be created by default. Creating handle through #MV_CC_CreateHandleWithoutLog will not generate log files. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_CreateHandle(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); - -/********************************************************************//** - * @~chinese - * @brief 创建设备句柄,不生成日志 - * @param handle [OUT] 设备句柄 - * @param pstDevInfo [IN] 设备信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 根据输入的设备信息,创建库内部必须的资源和初始化内部模块。通过该接口创建句柄,调用SDK接口,不会默认生成SDK日志文件,如果需要生成日志文件可以通过MV_CC_CreateHandle创建句柄,日志文件自动生成,保存在当前可执行程序路径下的MvSdkLog文件夹。 - - * @~english - * @brief Create Device Handle without log - * @param handle [OUT] Device handle - * @param pstDevInfo [IN] Device Information Structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleWithoutLog(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); - -/********************************************************************//** - * @~chinese - * @brief 销毁设备句柄 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Destroy Device Handle - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_DestroyHandle(IN void * handle); - -/********************************************************************//** - * @~chinese - * @brief 打开设备 - * @param handle [IN] 设备句柄 - * @param nAccessMode [IN] 访问权限 - * @param nSwitchoverKey [IN] 切换访问权限时的密钥 - * @return 成功,返回#MV_OK ;错误,返回错误码 - * @remarks 根据设置的设备参数,找到对应的设备,连接设备。\n - 调用接口时可不传入nAccessMode和nSwitchoverKey,此时默认设备访问模式为独占权限。目前设备暂不支持#MV_ACCESS_ExclusiveWithSwitch、 #MV_ACCESS_ControlWithSwitch、MV_ACCESS_ControlSwitchEnable、MV_ACCESS_ControlSwitchEnableWithKey这四种抢占模式。\n - 对于U3V设备,nAccessMode、nSwitchoverKey这两个参数无效。 - - * @~english - * @brief Open Device - * @param handle [IN] Device handle - * @param nAccessMode [IN] Access Right - * @param nSwitchoverKey [IN] Switch key of access right - * @return Success, return #MV_OK. Failure, return error code - * @remarks Find specific device and connect according to set device parameters. \n - When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access mode is exclusive. Currently the device does not support the following preemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.\n - For USB3Vision device, nAccessMode, nSwitchoverKey are invalid. - ************************************************************************/ -#ifndef __cplusplus -MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey); -#else -MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode = MV_ACCESS_Exclusive, IN unsigned short nSwitchoverKey = 0); -#endif - -/********************************************************************//** - * @~chinese - * @brief 关闭相机 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK ;错误,返回错误码 - * @remarks 通过MV_CC_OpenDevice连接设备后,可以通过该接口断开设备连接,释放资源 - - * @~english - * @brief Close Device - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_CloseDevice(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 判断相机是否处于连接状态 - * @param handle [IN] 设备句柄 - * @return 设备处于连接状态,返回true;没连接或失去连接,返回false - - * @~english - * @brief Is The Device Connected - * @param handle [IN] Device handle - * @return Connected, return true. Not Connected or DIsconnected, return false - ***********************************************************************/ -MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceConnected(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 注册图像数据回调 - * @param handle [IN] 设备句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过该接口可以设置图像数据回调函数,在MV_CC_CreateHandle之后即可调用。 \n - 图像数据采集有两种方式,两种方式不能复用: - - 方式一:调用MV_CC_RegisterImageCallBackEx设置图像数据回调函数,然后调用MV_CC_StartGrabbing开始采集,采集的图像数据在设置的回调函数中返回。 - - 方式二:调用MV_CC_StartGrabbing开始采集,然后在应用层循环调用MV_CC_GetOneFrameTimeout获取指定像素格式的帧数据,获取帧数据时上层应用程序需要根据帧率控制好调用该接口的频率。 - 该接口仅在windows版本和Linux版本下支持。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Register the image callback function - * @param handle [IN] Device handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.\n - There are two available image data acquisition modes, and cannot be used together: - - Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then call MV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function. - - Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate. - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackEx(void* handle, - void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), - void* pUser); - -/********************************************************************//** - * @~chinese - * @brief 注册图像数据回调,RGB - * @param handle [IN] 设备句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过该接口可以设置图像数据回调函数,在MV_CC_CreateHandle之后即可调用。 \n - 图像数据采集有两种方式,两种方式不能复用: - - 方式一:调用MV_CC_RegisterImageCallBackForRGB设置RGB24格式图像数据回调函数,然后调用MV_CC_StartGrabbing开始采集,采集的图像数据在设置的回调函数中返回。 - - 方式二:调用MV_CC_StartGrabbing开始采集,然后在应用层循环调用MV_CC_GetImageForRGB获取RGB24格式的帧数据,获取帧数据时上层应用程序需要根据帧率控制好调用该接口的频率。\n\n - 该接口仅在windows版本和Linux版本下支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief register image data callback, RGB - * @param handle [IN] Device handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n - There are two image acquisition modes, the two modes cannot be reused: - - Mode 1: Call #MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, - and then call #MV_CC_StartGrabbing to start acquisition, - the collected image data will be returned in the configured callback function. - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB - repeatedly in application layer to get frame data with RGB24 format. - When getting frame data, the upper application program should control the frequency - of calling this API according to frame rate. \n\n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForRGB(void* handle, - void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), - void* pUser); - -/********************************************************************//** - * @~chinese - * @brief 注册图像数据回调,BGR - * @param handle [IN] 设备句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回 #MV_OK ;错误,返回错误码 - * @remarks 通过该接口可以设置图像数据回调函数,在MV_CC_CreateHandle之后即可调用。\n - 图像数据采集有两种方式,两种方式不能复用:\n - - 方式一:调用 #MV_CC_RegisterImageCallBackForBGR 设置 #BGR24 图像数据回调函数,然后调用 #MV_CC_StartGrabbing 开始采集,采集的图像数据在设置的回调函数中返回。 - - 方式二:调用 #MV_CC_StartGrabbing 开始采集,然后在应用层循环调用 #MV_CC_GetImageForBGR 获取 #BGR24 格式的帧数据,获取帧数据时上层应用程序需要根据帧率控制好调用该接口的频率。 \n\n - 该接口仅在windows版本和Linux版本下支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief register image data callback, BGR - * @param handle [IN] Device handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n - There are two image acquisition modes, the two modes cannot be reused: \n - - Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.\n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForBGR(void* handle, - void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), - void* pUser); - -/********************************************************************//** - * @~chinese - * @brief 开始取流 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口不支持CameraLink设备。 - - * @~english - * @brief Start Grabbing - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_StartGrabbing(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 停止取流 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口不支持CameraLink设备。 - - * @~english - * @brief Stop Grabbing - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_StopGrabbing(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 获取一帧RGB数据,此函数为查询式获取,每次调用查询内部 - 缓存有无数据,有数据则获取数据,无数据返回错误码 - * @param handle [IN] 设备句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @param nMsec [IN] 等待超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 每次调用该接口,将查询内部缓存是否有数据,如果有数据则转换成RGB24格式返回,如果没有数据则返回错误码。因为图像转换成RGB24格式有耗时,所以当数据帧率过高时该接口可能会导致丢帧。\n - 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。 \n - 该接口不支持CameraLink设备。 \n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Get one frame of RGB data, this function is using query to get data - query whether the internal cache has data, get data if there has, return error code if no data - * @param handle [IN] Device handle - * @param pData [OUT] Image data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pFrameInfo [OUT] Image information structure - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n - There are two image acquisition modes, the two modes cannot be reused: \n - - Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo, int nMsec); - -/********************************************************************//** - * @~chinese - * @brief 获取一帧BGR数据,此函数为查询式获取,每次调用查询内部 - 缓存有无数据,有数据则获取数据,无数据返回错误码 - * @param handle [IN] 设备句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @param nMsec [IN] 等待超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 每次调用该接口,将查询内部缓存是否有数据,如果有数据则转换成BGR24格式返回,如果没有数据则返回错误码。因为图像转换成BGR24格式有耗时,所以当数据帧率过高时该接口可能会导致丢帧。 \n - 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。\n - 该接口不支持CameraLink设备。\n - 该接口仅在windows版本和Linux版本下支持。 - - - * @~english - * @brief Get one frame of BGR data, this function is using query to get data - query whether the internal cache has data, get data if there has, return error code if no data - * @param handle [IN] Device handle - * @param pData [OUT] Image data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pFrameInfo [OUT] Image information structure - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n - There are two image acquisition modes, the two modes cannot be reused: \n - - Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo, int nMsec); - -/********************************************************************//** - * @~chinese - * @brief 使用内部缓存获取一帧图片(与MV_CC_Display不能同时使用) - * @param handle [IN] 设备句柄 - * @param pFrame [OUT] 图像数据和图像信息 - * @param nMsec [IN] 等待超时时间,输入INFINITE时表示无限等待,直到收到一帧数据或者停止取流 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。该接口支持设置超时时间,SDK内部等待直到有数据时返回,可以增加取流平稳性,适合用于对平稳性要求较高的场合。 \n - 该接口与MV_CC_FreeImageBuffer配套使用,当处理完取到的数据后,需要用MV_CC_FreeImageBuffer接口将pFrame内的数据指针权限进行释放。 \n - 该接口与MV_CC_GetOneFrameTimeout相比,有着更高的效率。且其取流缓存的分配是由sdk内部自动分配的,而MV_CC_GetOneFrameTimeout接口是需要客户自行分配。\n - 该接口在调用MV_CC_Display后无法取流。 \n - 该接口对于U3V、GIGE设备均可支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Get a frame of an image using an internal cache - * @param handle [IN] Device handle - * @param pFrame [OUT] Image data and image information - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API supports setting timeout, and SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n - This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. \n - This interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. \n - This API cannot be called to stream after calling MV_CC_Display. \n - This API is not supported by CameraLink device. \n - This API is supported by both USB3 vision camera and GigE camera. \n - **********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetImageBuffer(IN void* handle, OUT MV_FRAME_OUT* pFrame, IN unsigned int nMsec); - -/********************************************************************//** - * @~chinese - * @brief 释放图像缓存(此接口用于释放不再使用的图像缓存,与MV_CC_GetImageBuffer配套使用) - * @param handle [IN] 设备句柄 - * @param pFrame [IN] 图像数据和图像数据 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口与MV_CC_GetImageBuffer配套使用,使用MV_CC_GetImageBuffer接口取到的图像数据pFrame,需要用 #MV_CC_FreeImageBuffer 接口进行权限释放。 \n - 该接口对于取流效率高于GetOneFrameTimeout接口,且GetImageBuffer在不进行Free的情况下,最大支持输出的节点数与 #MV_CC_SetImageNodeNum 接口所设置的节点数相等,默认节点数是1。\n - 该接口对于U3V、GIGE设备均可支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) - * @param handle [IN] Device handle - * @param pFrame [IN] Image data and image information - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to get image data pFrame, you should call #MV_CC_FreeImageBuffer to release the permission. \n - Compared with API MV_CC_GetOneFrameTimeout, this API has higher efficiency of image acquisition. The max. number of nodes can be outputted is same as the "nNum" of API #MV_CC_SetImageNodeNum, default value is 1. \n - This API is not supported by CameraLink device. \n - This API is supported by both USB3 vision camera and GigE camera. - **********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pFrame); - -/********************************************************************//** - * @~chinese - * @brief 采用超时机制获取一帧图片,SDK内部等待直到有数据时返回 - * @param handle [IN] 设备句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @param nMsec [IN] 等待超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。该接口支持设置超时时间,SDK内部等待直到有数据时返回,可以增加取流平稳性,适合用于对平稳性要求较高的场合。\n - 该接口对于U3V、GIGE设备均可支持。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned - * @param handle [IN] Device handle - * @param pData [OUT] Image data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pFrameInfo [OUT] Image information structure - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API supports setting timeout, SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n - Both the USB3Vision and GIGE camera can support this API. \n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameTimeout(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo, unsigned int nMsec); - -/********************************************************************//** - * @~chinese - * @brief 显示图像,注册显示窗口,内部自动显示(与MV_CC_GetImageBuffer不能同时使用) - * @param handle [IN] 句柄 - * @param hWnd [IN] 显示窗口句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Display one frame image, register display window, automatic display internally - * @param handle [IN] Handle - * @param hWnd [IN] Display Window Handle - * @return Success, return #MV_OK. Failure, return error code - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_Display(IN void* handle, void* hWnd); - -/********************************************************************//** - * @~chinese - * @brief 显示一帧图像 - * @param handle [IN] 设备句柄 - * @param pDisplayInfo [IN] 图像信息 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口对于U3V、GIGE设备均可支持。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Display one frame image - * @param handle [IN] Device handle - * @param pDisplayInfo [IN] Frame Info - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is valid for USB3Vision camera and GIGE camera. \n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pDisplayInfo); - -/********************************************************************//** - * @~chinese - * @brief 设置SDK内部图像缓存节点个数,大于等于1,在抓图前调用 - * @param handle [IN] 设备句柄 - * @param nNum [IN] 缓存节点个数,范围[1,30],默认为1 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 调用该接口可以设置SDK内部图像缓存节点个数,在调用MV_CC_StartGrabbing开始抓图前调用。\n - 增加图像缓存节点个数会增加SDK使用的内存,但是可以有效避免某些性能差的ARM板出现的跳帧现象。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture - * @param handle [IN] Device handle - * @param nNum [IN] Image Node Number, range[1,30], default 1 - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this interface to set the number of SDK internal image buffer nodes. - The interface should be called before calling MV_CC_StartGrabbing for capturing. \n - Increasing the number of image cache nodes will increase the memory used by the SDK, - but it can effectively avoid frame skipping on some ARM boards with poor performance. \n - This API is not supported by CameraLink device. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetImageNodeNum(IN void* handle, unsigned int nNum); - -/********************************************************************//** - * @~chinese - * @brief 获取设备信息,取流之前调用 - * @param handle [IN] 设备句柄 - * @param pstDevInfo [IN][OUT] 返回给调用者有关相机设备信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 支持用户在打开设备后获取设备信息。\n - 若该设备是GigE相机,则调用该接口存在阻塞风险,因此不建议在取流过程中调用该接口。 - - * @~english - * @brief Get device information - * @param handle [IN] Device handle - * @param pstDevInfo [IN][OUT] Structure pointer of device information - * @return Success, return #MV_OK. Failure, return error code - * @remarks The API support users to access device information after opening the device. \n - If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not recommended to call the interface during the fetching process. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo); - -/********************************************************************//** - * @~chinese - * @brief 获取各种类型的信息 - * @param handle [IN] 设备句柄 - * @param pstInfo [IN][OUT] 返回给调用者有关相机各种类型的信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 接口里面输入需要获取的信息类型(指定MV_ALL_MATCH_INFO结构体中的nType类型),获取对应的信息(在MV_ALL_MATCH_INFO结构体中pInfo里返回)。 \n - 该接口的调用前置条件取决于所获取的信息类型,获取GigE设备的MV_MATCH_TYPE_NET_DETECT信息需在开启抓图之后调用,获取U3V设备的MV_MATCH_TYPE_USB_DETECT信息需在打开设备之后调用。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Get various type of information - * @param handle [IN] Device handle - * @param pstInfo [IN][OUT] Structure pointer of various type of information - * @return Success, return #MV_OK. Failure, return error code - * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO). \n - The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. \n - This API is not supported by CameraLink device. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo); - -/************************************************************************/ -/* 设置和获取相机参数的万能接口 */ -/* General interface for getting and setting camera parameters */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 获取Integer属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param pIntValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表, - * 表格里面数据类型为“IInteger”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to get width - * @param pIntValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to get the value of camera node with integer type after connecting the device. - * For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list - * can be obtained via this API. strKey corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE *pIntValue); - -/********************************************************************//** - * @~chinese - * @brief 获取Integer属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param pIntValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表, - * 表格里面数据类型为“IInteger”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to get width - * @param pIntValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to get the value of camera node with integer type after connecting the device. - * For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list - * can be obtained via this API. strKey corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE_EX *pIntValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Integer型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param nValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IInteger”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to set width - * @param nValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to set the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Integer型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param nValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IInteger”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to set width - * @param nValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to set the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取Enum属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取像素格式信息则为"PixelFormat" - * @param pEnumValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取Enum类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IEnumeration”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Enum value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel format - * @param pEnumValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetEnumValue(IN void* handle,IN const char* strKey,OUT MVCC_ENUMVALUE *pEnumValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Enum型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取像素格式信息则为"PixelFormat" - * @param nValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置Enum类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IEnumeration”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Enum value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format - * @param nValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Enum型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取像素格式信息则为"PixelFormat" - * @param sValue [IN] 想要设置的相机的属性字符串 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置Enum类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IEnumeration”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Enum value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format - * @param sValue [IN] Feature String to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API after connecting the device. All the values of nodes with IEnumeration type can be set via this API. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValueByString(IN void* handle,IN const char* strKey,IN const char* sValue); - -/********************************************************************//** - * @~chinese - * @brief 获取Float属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param pFloatValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取float类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IFloat”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Float value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param pFloatValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be obtained through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetFloatValue(IN void* handle,IN const char* strKey,OUT MVCC_FLOATVALUE *pFloatValue); - -/********************************************************************//** - * @~chinese - * @brief 设置float型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param fValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置float类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IFloat”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set float value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param fValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be set through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetFloatValue(IN void* handle,IN const char* strKey,IN float fValue); - -/********************************************************************//** - * @~chinese - * @brief 获取Boolean属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param pBoolValue [IN][OUT] 返回给调用者有关相机属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取bool类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IBoolean”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Boolean value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param pBoolValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be obtained through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBoolValue(IN void* handle,IN const char* strKey,OUT bool *pBoolValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Boolean型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param bValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置bool类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IBoolean”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Boolean value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param bValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be set through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBoolValue(IN void* handle,IN const char* strKey,IN bool bValue); - -/********************************************************************//** - * @~chinese - * @brief 获取String属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param pStringValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取string类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IString”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get String value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param pStringValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be obtained through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetStringValue(IN void* handle,IN const char* strKey,OUT MVCC_STRINGVALUE *pStringValue); - -/********************************************************************//** - * @~chinese - * @brief 设置String型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param sValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置string类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IString”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set String value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param sValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be set through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetStringValue(IN void* handle,IN const char* strKey,IN const char * sValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Command型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以设置指定的Command类型节点。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“ICommand”的节点都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Send Command - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified Command nodes. For value of strKey, see MvCameraNode. The node values of ICommand can be set through this interface, strKey value corresponds to the Name column. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetCommandValue(IN void* handle,IN const char* strKey); - -/********************************************************************//** - * @~chinese - * @brief 清除GenICam节点缓存 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Invalidate GenICam Nodes - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_InvalidateNodes(IN void* handle); - - -/************************************************************************/ -/* 设备升级 和 寄存器读写 和异常、事件回调 */ -/* Device upgrade, register read and write and exception callback */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 设备本地升级 - * @param handle [IN] 设备句柄 - * @param pFilePathName [IN] 文件名 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口可以将升级固件文件发送给设备进行升级。该接口需要等待升级固件文件成功传给设备端之后再返回,响应时间可能较长。 - - * @~english - * @brief Device Local Upgrade - * @param handle [IN] Device handle - * @param pFilePathName [IN] File name - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_LocalUpgrade(IN void* handle, const void *pFilePathName); - -/********************************************************************//** - * @~chinese - * @brief 获取升级进度 - * @param handle [IN] 设备句柄 - * @param pnProcess [OUT] 进度接收地址 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 获取升级进度百分值。 - - * @~english - * @brief Get Upgrade Progress - * @param handle [IN] Device handle - * @param pnProcess [OUT] Progress receiving address - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to send the upgrade firmware to the device for upgrade. This API will wait for return until the upgrade firmware is sent to the device, this response may take a long time. \n - For CameraLink device, it keeps sending upgrade firmware continuously. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetUpgradeProcess(IN void* handle, unsigned int* pnProcess); - -/********************************************************************//** - * @~chinese - * @brief 读内存 - * @param handle [IN] 设备句柄 - * @param pBuffer [IN][OUT] 作为返回值使用,保存读到的内存值(内存值是按照大端模式存储的) - * @param nAddress [IN] 待读取的内存地址,该地址可以从设备的Camera.xml文件中获取,形如xxx_RegAddr的xml节点值 - * @param nLength [IN] 待读取的内存长度 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 访问设备,读取某段寄存器的数据。 - - * @~english - * @brief Read Memory - * @param handle [IN] Device Handle - * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( Memory value is stored in accordance with the big end model) - * @param nAddress [IN] Memory address to be read, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr - * @param nLength [IN] Length of the memory to be read - * @return Success, return #MV_OK. Failure, return error code - * @remarks Access device, read the data from certain register. -*************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_ReadMemory(IN void* handle , void *pBuffer, int64_t nAddress, int64_t nLength); - -/********************************************************************//** - * @~chinese - * @brief 写内存 - * @param handle [IN] 设备句柄 - * @param pBuffer [IN] 待写入的内存值(注意内存值要按照大端模式存储) - * @param nAddress [IN] 待写入的内存地址,该地址可以从设备的Camera.xml文件中获取,形如xxx_RegAddr的xml节点值 - * @param nLength [IN] 待写入的内存长度 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 访问设备,把一段数据写入某段寄存器。 - - * @~english - * @brief Write Memory - * @param handle [IN] Device Handle - * @param pBuffer [IN] Memory value to be written ( Note the memory value to be stored in accordance with the big end model) - * @param nAddress [IN] Memory address to be written, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr - * @param nLength [IN] Length of the memory to be written - * @return Success, return #MV_OK. Failure, return error code - * @remarks Access device, write a piece of data into a certain segment of register. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_WriteMemory(IN void* handle , const void *pBuffer, int64_t nAddress, int64_t nLength); - -/********************************************************************//** - * @~chinese - * @brief 注册异常消息回调,在打开设备之后调用 - * @param handle [IN] 设备句柄 - * @param cbException [IN] 异常回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口需要在MV_CC_OpenDevice打开设备之后调用。设备异常断开连接后可以在回调里面获取到异常消息,GigE设备掉线之后需要先调用MV_CC_CloseDevice接口关闭设备,再调用MV_CC_OpenDevice接口重新打开设备。 - - * @~english - * @brief Register Exception Message CallBack, call after open device - * @param handle [IN] Device handle - * @param cbException [IN] Exception Message CallBack Function Pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterExceptionCallBack(IN void* handle, - void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), void* pUser); - -/********************************************************************//** - * @~chinese - * @brief 注册全部事件回调,在打开设备之后调用 - * @param handle [IN] 设备句柄 - * @param cbEvent [IN] 事件回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口设置事件回调,可以在回调函数里面获取采集、曝光等事件信息。 \n - 该接口不支持CameraLink设备。\n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Register event callback, which is called after the device is opened - * @param handle [IN] Device handle - * @param cbEvent [IN] Event CallBack Function Pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n - This API is not supported by CameraLink device. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterAllEventCallBack(void* handle, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); - -/********************************************************************//** - * @~chinese - * @brief 注册单个事件回调,在打开设备之后调用 - * @param handle [IN] 设备句柄 - * @param pEventName [IN] 事件名称 - * @param cbEvent [IN] 事件回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口设置事件回调,可以在回调函数里面获取采集、曝光等事件信息。\n - 该接口不支持CameraLink设备,仅支持"设备掉线"这一种事件。 - - * @~english - * @brief Register single event callback, which is called after the device is opened - * @param handle [IN] Device handle - * @param pEventName [IN] Event name - * @param cbEvent [IN] Event CallBack Function Pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n - This API is not supported by CameraLink device . -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBackEx(void* handle, const char* pEventName, - void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); - - -/************************************************************************/ -/* GigEVision 设备独有的接口 */ -/* GigEVision device specific interface */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 强制IP - * @param handle [IN] 设备句柄 - * @param nIP [IN] 设置的IP - * @param nSubNetMask [IN] 子网掩码 - * @param nDefaultGateWay [IN] 默认网关 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 强制设置相机网络参数(包括IP、子网掩码、默认网关),强制设置之后将需要重新创建设备句柄,仅GigEVision相机支持。\n - 如果设备为DHCP的状态,调用该接口强制设置相机网络参数之后设备将会重启。 - - * @~english - * @brief Force IP - * @param handle [IN] Device handle - * @param nIP [IN] IP to set - * @param nSubNetMask [IN] Subnet mask - * @param nDefaultGateWay [IN] Default gateway - * @return Success, return #MV_OK. Failure, return error code - * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After forced setting, device handle should be created again. This function is only supported by GigEVision camera.\n - If device is in DHCP status, after calling this API to force setting camera network parameter, the device will restart. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIpEx(IN void* handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay); - -/********************************************************************//** - * @~chinese - * @brief 配置IP方式 - * @param handle [IN] 设备句柄 - * @param nType [IN] IP类型,见MV_IP_CFG_x - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 发送命令设置相机的IP方式,如DHCP、LLA等,仅GigEVision相机支持。 - - * @~english - * @brief IP configuration method - * @param handle [IN] Device handle - * @param nType [IN] IP type, refer to MV_IP_CFG_x - * @return Success, return #MV_OK. Failure, return error code - * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetIpConfig(IN void* handle, unsigned int nType); - -/********************************************************************//** - * @~chinese - * @brief 设置仅使用某种模式,type: MV_NET_TRANS_x,不设置时,默认优先使用driver - * @param handle [IN] 设备句柄 - * @param nType [IN] 网络传输模式,见MV_NET_TRANS_x - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口可以设置SDK内部优先使用的网络模式,默认优先使用驱动模式,仅GigEVision相机支持。 - - * @~english - * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default - * @param handle [IN] Device handle - * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x - * @return Success, return #MV_OK. Failure, return error code - * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by GigEVision camera. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetNetTransMode(IN void* handle, unsigned int nType); - -/********************************************************************//** - * @~chinese - * @brief 获取网络传输信息 - * @param handle [IN] 设备句柄 - * @param pstInfo [OUT] 信息结构体 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口可以获取网络传输相关信息,包括已接收数据大小、丢帧数量等,在MV_CC_StartGrabbing开启采集之后调用。仅GigEVision相机支持。 - - * @~english - * @brief Get net transmission information - * @param handle [IN] Device handle - * @param pstInfo [OUT] Information Structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Get network transmission information through this API, including received data size, number of lost frames. Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by GigEVision Camera. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetNetTransInfo(IN void* handle, MV_NETTRANS_INFO* pstInfo); - -/********************************************************************//** - * @~chinese - * @brief 设置GVSP取流超时时间 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 超时时间,默认300ms,范围:>10ms - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 连接设备之后,取流动作发生前,调用该接口可以设置GVSP取流超时时间。GVSP取流超时设置过短可能造成图像异常,设置过长可能造成取流时间变长。 - - * @~english - * @brief Set GVSP streaming timeout - * @param handle [IN] Device handle - * @param nMillisec [IN] Timeout, default 300ms, range: >10ms - * @return Success, return MV_OK. Failure, return error code - * @remarks After the device is connected, and just before start streaming, - * call this interface to set GVSP streaming timeout value. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvspTimeout(void* handle, unsigned int nMillisec); - -/********************************************************************//** - * @~chinese - * @brief 获取GVSP取流超时时间 - * @param handle [IN] 设备句柄 - * @param pnMillisec [IN] 超时时间指针,以毫秒位单位 - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 该接口用于获取当前的GVSP取流超时时间 - - * @~english - * @brief Get GVSP streaming timeout - * @param handle [IN] Device handle - * @param pnMillisec [IN] Timeout, ms as unit - * @return Success, return MV_OK. Failure, return error code - * @remarks This interface is used to get the current GVSP streaming timeout. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvspTimeout(IN void* handle, unsigned int* pnMillisec); - -/********************************************************************//** - * @~chinese - * @brief 设置GVCP命令超时时间 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 超时时间,以毫秒位单位,范围:0-1000000 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 连接设备之后调用该接口可以设置GVCP命令超时时间。 - - * @~english - * @brief Set GVCP cammand timeout - * @param handle [IN] Device handle - * @param nMillisec [IN] Timeout, ms as unit, range: 0-1000000 - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set GVCP command timeout time. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvcpTimeout(void* handle, unsigned int nMillisec); - -/********************************************************************//** - * @~chinese - * @brief 获取最佳的packet size,该接口目前只支持GigE相机 - * @param handle [IN] 设备句柄 - * @return 最佳packetsize - * @remarks 获取最佳的packet size,对应GigEVision设备是SCPS,对应U3V设备是每次从驱动读取的包大小,该大小即网络上传输一个包的大小。该接口需要在MV_CC_OpenDevice之后、MV_CC_StartGrabbing之前调用。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Get the optimal Packet Size, Only support GigE Camera - * @param handle [IN] Device handle - * @return Optimal packetsize - * @remarks To get optimized packet size, for GigEVision device is SCPS, for USB3Vision device is the size of packet read from drive each time, and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. \n - This API is not supported by CameraLink device. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetOptimalPacketSize(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 设置是否打开重发包支持,及重发包设置 - * @param handle [IN] 设备句柄 - * @param bEnable [IN] 是否支持重发包 - * @param nMaxResendPercent [IN] 最大重发比 - * @param nResendTimeout [IN] 重发超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 连接设备之后调用该接口可以设置重发包属性,仅GigEVision相机支持。 \n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Set whethe to enable resend, and set resend - * @param handle [IN] Device handle - * @param bEnable [IN] enable resend - * @param nMaxResendPercent [IN] Max resend persent - * @param nResendTimeout [IN] Resend timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera. - ************************************************************************/ -#ifndef __cplusplus -MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent, unsigned int nResendTimeout); -#else -MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent = 10, unsigned int nResendTimeout = 50); -#endif - - -/********************************************************************//** - * @~chinese - * @brief 设置重传命令最大尝试次数 - * @param handle [IN] 设备句柄 - * @param nRetryTimes [IN] 重传命令最大尝试次数,默认20 - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 该接口必须在MV_CC_StartGrabbing之前调用,否则返回错误码MV_E_CALLORDER。 - - * @~english - * @brief set the max resend retry times - * @param handle [IN] Device handle - * @param nRetryTimes [IN] the max times to retry resending lost packets,default 20 - * @return Success, return MV_OK. Failure, return error code - * @remarks This interface must be called before MV_CC_StartGrabbing. Otherwise return MV_E_CALLORDER. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendMaxRetryTimes(void* handle, unsigned int nRetryTimes); - -/********************************************************************//** - * @~chinese - * @brief 获取重传命令最大尝试次数 - * @param handle [IN] 设备句柄 - * @param pnRetryTimes [IN] 重传命令最大尝试次数 - * @return 成功,返回MV_OK;错误,返回错误码 - - * @~english - * @brief get the max resend retry times - * @param handle [IN] Device handle - * @param pnRetryTimes [OUT] the max times to retry resending lost packets - * @return Success, return MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendMaxRetryTimes(void* handle, unsigned int* pnRetryTimes); - -/********************************************************************//** - * @~chinese - * @brief 设置同一重传包多次请求之间的时间间隔 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 同一重传包多次请求之间的时间间隔,默认10ms - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 该接口必须在MV_CC_StartGrabbing之前调用,否则返回错误码MV_E_CALLORDER。 - - * @~english - * @brief set time interval between same resend requests - * @param handle [IN] Device handle - * @param nMillisec [OUT] the time interval between same resend requests, default 10ms - * @return Success, return MV_OK. Failure, return error code - * @remarks This interface must be called before MV_CC_StartGrabbing. Otherwise return MV_E_CALLORDER. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendTimeInterval(void* handle, unsigned int nMillisec); - -/********************************************************************//** - * @~chinese - * @brief 获取同一重传包多次请求之间的时间间隔 - * @param handle [IN] 设备句柄 - * @param pnMillisec [IN] 同一重传包多次请求之间的时间间隔 - * @return 成功,返回MV_OK;错误,返回错误码 - - * @~english - * @brief get time interval between same resend requests - * @param handle [IN] Device handle - * @param pnMillisec [OUT] the time interval between same resend requests - * @return Success, return MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendTimeInterval(void* handle, unsigned int* pnMillisec); - - -/********************************************************************//** - * @~chinese - * @brief 设置传输模式,可以为单播模式、组播模式等 - * @param handle [IN] 设备句柄 - * @param pstTransmissionType [IN] 传输模式结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过该接口可以设置传输模式为单播、组播等模式,仅GigEVision相机支持。 - - * @~english - * @brief Set transmission type,Unicast or Multicast - * @param handle [IN] Device handle - * @param pstTransmissionType [IN] Struct of transmission type - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is only valid for GigEVision camera. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetTransmissionType(void* handle, MV_TRANSMISSION_TYPE * pstTransmissionType); - -/********************************************************************//** - * @~chinese - * @brief 发出动作命令 - * @param pstActionCmdInfo [IN] 动作命令信息 - * @param pstActionCmdResults [OUT] 动作命令返回信息列表 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 仅GigEVision相机支持。 - - * @~english - * @brief Issue Action Command - * @param pstActionCmdInfo [IN] Action Command - * @param pstActionCmdResults [OUT] Action Command Result List - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by GigEVision camera. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults); - -/************************************************************************/ -/* XML解析树的生成 */ -/* XML parse tree generation */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 获取相机属性树XML - * @param handle [IN] 设备句柄 - * @param pData [OUT] XML数据接收缓存 - * @param nDataSize [IN] 接收缓存大小 - * @param pnDataLen [OUT] 实际数据大小 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 当pData为NULL或nDataSize比实际的xml文件小时,不拷贝数据,由pnDataLen返回xml文件大小;\n - 当pData为有效缓存地址,且缓存足够大时,拷贝完整数据保存在该缓存里面,并由pnDataLen返回xml文件实际大小。 - - * @~english - * @brief Get camera feature tree XML - * @param handle [IN] Device handle - * @param pData [OUT] XML data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pnDataLen [OUT] Actual data length - * @return Success, return #MV_OK. Failure, return error code - * @remarks * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, returned by pnDataLen XML file size.\n - When pData is a valid cache address and the cache is large enough, copy the full data into the cache, and pnDataLen returns the actual size of the XML file. - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, OUT unsigned int* pnDataLen); - -/************************************************************************/ -/* 附加接口 */ -/* Additional interface */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 保存图片,支持Bmp和Jpeg.编码质量在50-99之前 - * @param handle [IN] 设备句柄 - * @param pSaveParam [IN][OUT] 保存图片参数结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过将接口可以将从设备采集到的原始图像数据转换成JPEG或者BMP等格式并存放在指定内存中,然后用户可以将转换之后的数据直接保存成图片文件。该接口调用无接口顺序要求,有图像源数据就可以进行转换,可以先调用MV_CC_GetOneFrameTimeout或者MV_CC_RegisterImageCallBackEx设置回调函数,获取一帧图像数据,然后再通过该接口转换格式。 \n - MV_CC_SaveImageEx2比MV_CC_SaveImageEx增加参数handle,为了保证与其他接口的统一。\n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Save image, support Bmp and Jpeg. Encoding quality(50-99] - * @param handle [IN] Device handle - * @param pSaveParam [IN][OUT] Save image parameters structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Once there is image data, you can call this API to convert the data. \n - You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. \n - Comparing with the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. - - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx2(IN void* handle, MV_SAVE_IMAGE_PARAM_EX* pSaveParam); - -/********************************************************************//** - * @~chinese - * @brief 像素格式转换 - * @param handle [IN] 设备句柄 - * @param pstCvtParam [IN][OUT] 像素格式转换参数结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过将接口可以将从设备采集到的原始图像数据转换成用户所需的像素格式并存放在指定内存中。该接口调用无接口顺序要求,有图像源数据就可以进行转换,可以先调用MV_CC_GetOneFrameTimeout或者MV_CC_RegisterImageCallBack设置回调函数,获取一帧图像数据,然后再通过该接口转换格式。如果相机当前采集图像是JPEG压缩的格式,则不支持调用该接口进行显示。 \n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Pixel format conversion - * @param handle [IN] Device handle - * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. There is no order requirement to call this API, the transformation will execute when there is image data. First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, then call this API to transform the format. \n - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_ConvertPixelType(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam); - -/********************************************************************//** - * @~chinese - * @brief 插值算法类型设置 - * @param handle [IN] 设备句柄 - * @param BayerCvtQuality [IN] Bayer的插值方法 0-最近邻 1-双线性 2-Hamilton - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 设置内部图像转换接口的贝尔插值质量参数,MV_CC_ConvertPixelType、MV_CC_SaveImageEx2接口内部使用的插值算法是该接口所设定的。 - - * @~english - * @brief Interpolation algorithm type setting - * @param handle [IN] Device handle - * @param BayerCvtQuality [IN] Bayer interpolation method 0-nearest neighbour 1-bilinearity 2-Hamilton - * @return Success, return #MV_OK. Failure, return error code - * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, and the interpolation algorithm used in the MV CC ConvertPixelType and MV CC SaveImageEx2 interfaces is set by this interface. - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int BayerCvtQuality); - -/********************************************************************//** - * @~chinese - * @brief 保存相机属性 - * @param handle [IN] 设备句柄 - * @param pFileName [IN] 属性文件名 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Save camera feature - * @param handle [IN] Device handle - * @param pFileName [IN] File name - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_FeatureSave(IN void* handle, IN const char* pFileName); - -/********************************************************************//** - * @~chinese - * @brief 导入相机属性 - * @param handle [IN] 设备句柄 - * @param pFileName [IN] 属性文件名 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Load camera feature - * @param handle [IN] Device handle - * @param pFileName [IN] File name - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_FeatureLoad(IN void* handle, IN const char* pFileName); - -/********************************************************************//** - * @~chinese - * @brief 从相机读取文件 - * @param handle [IN] 设备句柄 - * @param pstFileAccess [IN] 文件存取结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Read the file from the camera - * @param handle [IN] Device handle - * @param pstFileAccess [IN] File access structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_FileAccessRead(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); - -/********************************************************************//** - * @~chinese - * @brief 将文件写入相机 - * @param handle [IN] 设备句柄 - * @param pstFileAccess [IN] 文件存取结构体 - * @return 成功,返回#MV_OK ;错误,返回错误码 - - * @~english - * @brief Write the file to camera - * @param handle [IN] Device handle - * @param pstFileAccess [IN] File access structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_FileAccessWrite(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); - -/********************************************************************//** - * @~chinese - * @brief 获取文件存取的进度 - * @param handle [IN] 设备句柄 - * @param pstFileAccessProgress [IN] 进度内容 - * @return 成功,返回#MV_OK ;错误,返回错误码 (当前文件存取的状态) - - * @~english - * @brief Get File Access Progress - * @param handle [IN] Device handle - * @param pstFileAccessProgress [IN] File access Progress - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetFileAccessProgress(IN void* handle, OUT MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress); - -/********************************************************************//** - * @~chinese - * @brief 开始录像 - * @param handle [IN] 设备句柄 - * @param pstRecordParam [IN] 录像参数结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Start Record - * @param handle [IN] Device handle - * @param pstRecordParam [IN] Record param structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam); - -/********************************************************************//** - * @~chinese - * @brief 输入录像数据 - * @param handle [IN] 设备句柄 - * @param pstInputFrameInfo [IN] 录像数据结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Input RAW data to Record - * @param handle [IN] Device handle - * @param pstInputFrameInfo [IN] Record data structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo); - -/********************************************************************//** - * @~chinese - * @brief 停止录像 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Stop Record - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_StopRecord(IN void* handle); - - - -/************************************************************************/ -/* 不建议使用的接口 */ -/* Interfaces not recommended */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 获取图像基本信息 - * @param handle [IN] 相机句柄 - * @param pstInfo [IN][OUT] 返回给调用者有关相机图像基本信息结构体指针 - * @return 成功,返回 #MV_OK ,失败,返回错误码 - * @remarks 参考 CameraParams.h 中的 #MV_IMAGE_BASIC_INFO 定义 - - * @~english - * @brief Get basic information of image - * @param handle [IN] Handle - * @param pstInfo [IN][OUT] Structure pointer of image basic information - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to the definition of #MV_IMAGE_BASIC_INFO in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetImageInfo(IN void* handle, IN OUT MV_IMAGE_BASIC_INFO* pstInfo); - -/********************************************************************//** - * @~chinese - * @brief 获取GenICam代理 - * @param handle [IN] 句柄地址 - * @return GenICam代理类指针 ,正常返回值非NULL;异常返回NULL - - * @~english - * @brief Get GenICam proxy - * @param handle [IN] Handle address - * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL - ************************************************************************/ -MV_CAMCTRL_API void* __stdcall MV_CC_GetTlProxy(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 获取根节点 - * @param handle [IN] 句柄 - * @param pstNode [OUT] 根节点信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get root node - * @param handle [IN] Handle - * @param pstNode [OUT] Root node information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_XML_GetRootNode(IN void* handle, IN OUT MV_XML_NODE_FEATURE* pstNode); - -/********************************************************************//** - * @~chinese - * @brief 从xml中获取指定节点的所有子节点,根节点为Root - * @param handle [IN] 句柄 - * @param pstNode [IN] 根节点信息结构体 - * @param pstNodesList [OUT] 节点列表结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get all children node of specific node from xml, root node is Root - * @param handle [IN] Handle - * @param pstNode [IN] Root node information structure - * @param pstNodesList [OUT] Node information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_XML_GetChildren(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT MV_XML_NODES_LIST* pstNodesList); - -/********************************************************************//** - * @~chinese - * @brief 获得当前节点的属性 - * @param handle [IN] 句柄 - * @param pstNode [IN] 根节点信息结构体 - * @param pstFeature [OUT] 当前节点属性结构体, - pstFeature 具体结构体内容参考 MV_XML_FEATURE_x - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get current node feature - * @param handle [IN] Handle - * @param pstNode [IN] Root node information structure - * @param pstFeature [OUT] Current node feature structure - Details of pstFeature refer to MV_XML_FEATURE_x - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_XML_GetNodeFeature(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT void* pstFeature); - -/********************************************************************//** - * @~chinese - * @brief 更新节点 - * @param handle [IN] 句柄 - * @param enType [IN] 节点类型 - * @param pstFeature [OUT] 当前节点属性结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Update node - * @param handle [IN] Handle - * @param enType [IN] Node type - * @param pstFeature [OUT] Current node feature structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_XML_UpdateNodeFeature(IN void* handle, IN enum MV_XML_InterfaceType enType, IN void* pstFeature); - -// 有节点需要更新时的回调函数 -// 当调用MV_XML_UpdateNodeFeature接口更新节点属性时,注册的回调函数cbUpdate会在pstNodesList中返回与之相关联的节点 -/********************************************************************//** - * @~chinese - * @fn MV_XML_RegisterUpdateCallBack - * @brief 注册更新回调 - * @param handle [IN] 句柄 - * @param cbUpdate [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Register update callback - * @param handle [IN] Handle - * @param cbUpdate [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_XML_RegisterUpdateCallBack(IN void* handle, - IN void(__stdcall* cbUpdate)(enum MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser), - IN void* pUser); - - -/************************************************************************/ -/* 弃用的接口 */ -/* Abandoned interface */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 获取一帧图像,此函数为查询式获取,每次调用查询内部缓存有 - 无数据,有数据则范围数据,无数据返回错误码 - (该接口已弃用,建议改用 MV_CC_GetOneFrameTimeOut接口) - * @param handle [IN] 句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get one frame data, this function is using query to get data, - query whether the internal cache has data, return data if there has, return error code if no data - (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) - * @param handle [IN] Handle - * @param pData [OUT] Recevied image data pointer - * @param nDataSize [IN] Recevied buffer size - * @param pFrameInfo [OUT] Image information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrame(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO* pFrameInfo); - -/********************************************************************//** - * @~chinese - * @brief 获取一帧trunck数据,此函数为查询式获取,每次调用查询内部 - 缓存有无数据,有数据则范围数据,无数据返回错误码 - (该接口已弃用,建议改用 MV_CC_GetOneFrameTimeOut接口) - * @param handle [IN] 句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get one frame of trunck data, this function is using query to get data, - query whether the internal cache has data, return data if there has, return error code if no data - (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) - * @param handle [IN] Handle - * @param pData [OUT] Recevied image data pointer - * @param nDataSize [IN] Recevied buffer size - * @param pFrameInfo [OUT] Image information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameEx(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo); - -/********************************************************************//** - * @~chinese - * @brief 注册图像数据回调(该接口已弃用,建议改用 MV_CC_RegisterImageCallBackEx接口) - * @param handle [IN] 句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Register image data callback (This interface is abandoned, it is recommended to use the MV_CC_RegisterImageCallBackEx) - * @param handle [IN] Handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBack(void* handle, - void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser), - void* pUser); - -/********************************************************************//** - * @~chinese - * @brief 保存图片(该接口已弃用,建议改用 MV_CC_SaveImageEx2接口) - * @param pSaveParam [IN][OUT] 保存图片参数结构体 - - pData; // [IN] 输入数据缓存 - - nDataLen; // [IN] 输入数据大小 - - enPixelType; // [IN] 输入数据的像素格式 - - nWidth; // [IN] 图像宽 - - nHeight; // [IN] 图像高 - - pImageBuffer; // [OUT] 输出图片缓存 - - nImageLen; // [OUT] 输出图片大小 - - nBufferSize; // [IN] 提供的输出缓冲区大小 - - enImageType; // [IN] 输出图片格式 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Save image (This interface is abandoned, it is recommended to use the MV_CC_SaveImageEx2) - * @param pSaveParam [IN][OUT] Save image parameters structure - - pData; // [IN] Input data buffer - - nDataLen; // [IN] Input data size - - enPixelType; // [IN] Input data pixel format - - nWidth; // [IN] Width - - nHeight; // [IN] Height - - pImageBuffer; // [OUT] Output image buffer - - nImageLen; // [OUT] Output image size - - nBufferSize; // [IN] Provided output buffer size - - enImageType; // [IN] Output image type - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM* pSaveParam); - -/********************************************************************//** - * @~chinese - * @brief 保存图片,支持Bmp和Jpeg.编码质量在50-99之前 (该接口已弃用,建议改用 MV_CC_SaveImageEx2接口) - * @param pSaveParam [IN][OUT] 保存图片参数结构体 - pData; // [IN] 输入数据缓存 - nDataLen; // [IN] 输入数据大小 - enPixelType; // [IN] 输入数据的像素格式 - nWidth; // [IN] 图像宽 - nHeight; // [IN] 图像高 - pImageBuffer; // [OUT] 输出图片缓存 - nImageLen; // [OUT] 输出图片大小 - nBufferSize; // [IN] 提供的输出缓冲区大小 - enImageType; // [IN] 输出图片格式 - nJpgQuality; // [IN] 编码质量, (50-99] - nReserved[4]; - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] - * @param pSaveParam [IN][OUT] Save image parameters structure - pData; // [IN] Input data buffer - nDataLen; // [IN] Input data size - enPixelType; // [IN] Pixel format of input data - nWidth; // [IN] Image width - nHeight; // [IN] Image height - pImageBuffer; // [OUT] Output image buffer - nImageLen; // [OUT] Output image size - nBufferSize; // [IN] Output buffer size provided - enImageType; // [IN] Output image format - nJpgQuality; // [IN] Encoding quality, (50-99] - nReserved[4]; - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX* pSaveParam); - -/********************************************************************//** - * @~chinese - * @brief 强制IP(该接口已弃用,建议改用 MV_GIGE_ForceIpEx接口) - * @param handle [IN] 设备句柄 - * @param nIP [IN] 设置的IP - * @return 见返回错误码 - * @remarks - - * @~english - * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) - * @param handle [IN] Handle - * @param nIP [IN] IP to set - * @return Refer to error code - * @remarks -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIp(IN void* handle, unsigned int nIP); - -/********************************************************************//** - * @~chinese - * @brief 注册事件回调(该接口已弃用,建议改用 MV_CC_RegisterEventCallBackEx接口) - * @param handle [IN] 设备句柄 - * @param cbEvent [IN] 事件回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 见返回错误码 - * @remarks - - * @~english - * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the MV_CC_RegisterEventCallBackEx interface) - * @param handle [IN] Handle - * @param cbEvent [IN] event callback pointer - * @param pUser [IN] User defined value - * @return Refer to error code - * @remarks -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBack(void* handle, - void(__stdcall* cbEvent)(unsigned int nExternalEventId, void* pUser), - void* pUser); - - -/************************************************************************/ -/* 相机参数获取和设置,此模块的所有接口,将逐步废弃,建议用万能接口代替 */ -/* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 获取图像宽度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机宽度的信息结构体指针 - * 返回的pstValue结构体的意义 - * - unsigned int nCurValue; // 代表相机当前的宽度值 - * - unsigned int nMax; // 表示相机允许的最大可设置的宽度值 - * - unsigned int nMin; // 表示相机允许的最小可设置的宽度值 - * - unsigned int nInc; // 表示相机设置的宽度增量必须是nInc的倍数,否则无效 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他整型结构体参数的接口可参照此接口 - - * @~english - * @brief Get image width - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Returns the information structure pointer about the camera's width for the caller - * The meaning of returns pstValue structure - * - unsigned int nCurValue; // Represents the current width value of the camera - * - unsigned int nMax; // Indicates the maximum settable width value allowed by the camera - * - unsigned int nMin; // Indicates the minimum settable width value allowed by the camera - * - unsigned int nInc; // Indicates that the width increment set by the camera must be a multiple of nInc, otherwise it is invalid - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Other Integer structure parameters interface can refer to this interface - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置图像宽度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的相机宽度的值,注意此宽度值必须是MV_CC_GetWidth接口返回的pstValue中的nInc的倍数才能设置成功 - * @return 成功,返回#MV_OK,并且相机宽度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image width - * @param handle [IN] Camera Handle - * @param nValue [IN] To set the value of the camera width, note that the width value must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface - * @return Success, return #MV_OK, and the camera width will change to the corresponding value. Failure, return error code - * @remarks -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取图像高度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机高度的信息结构体指针 - * @return 成功,返回#MV_OK,并将高度信息返回到结构体中,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get image height - * @param handle [IN] Camera handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera height to user - * @return Success, return #MV_OK, and return height information to the structure. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置图像高度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的相机宽度的值,注意此宽度值必须是MV_CC_GetWidth接口返回的pstValue中的nInc的倍数才能设置成功 - * @return 成功,返回#MV_OK,并且相机高度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image height - * @param handle [IN] Camera Handle - * @param nValue [IN] Camera height value to set, note that this value must be times of nInc of pstValue returned by MV_CC_GetWidth - * @return Success, return #MV_OK, and the camera height will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取图像X偏移 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机X偏移的信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get image X offset - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera X offset to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置图像AOI偏移 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的相机AOI的值 - * @return 成功,返回#MV_OK,并且相机AOI偏移将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image X offset - * @param handle [IN] Camera Handle - * @param nValue [IN] Camera X offset value to set - * @return Success, return #MV_OK, and the camera X offset will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取图像Y偏移 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机Y偏移的信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get image Y offset - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera Y offset to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置图像AOI偏移 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的相机AOI的值 - * @return 成功,返回#MV_OK,并且相机AOI偏移将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image Y offset - * @param handle [IN] Camera Handle - * @param nValue [IN] Camera Y offset value to set - * @return Success, return #MV_OK, and the camera Y offset will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取曝光下限 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机曝光值下限结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get exposure lower limit - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera exposure lower to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置曝光值下限 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的曝光值下限 - * @return 成功,返回#MV_OK,并且相机曝光下限将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set exposure lower limit - * @param handle [IN] Camera Handle - * @param nValue [IN] Exposure lower to set - * @return Success, return #MV_OK, and the camera exposure time lower limit value will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取曝光上限 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机曝光值上限结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get exposure upper limit - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera exposure upper to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置曝光值上限 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的曝光值上限 - * @return 成功,返回#MV_OK,并且相机曝光上限将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set exposure upper limit - * @param handle [IN] Camera Handle - * @param nValue [IN] Exposure upper to set - * @return Success, return #MV_OK, and the camera exposure time upper limit value will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取亮度值 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机亮度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get brightness - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera brightness to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置亮度值 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的亮度值 - * @return 成功,返回#MV_OK,并且相机亮度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set brightness - * @param handle [IN] Camera Handle - * @param nValue [IN] Brightness upper to set - * @return Success, return #MV_OK, and the camera brightness value will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取帧率 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机帧率的信息结构体指针 - * 返回的pstValue结构体的意义 - * - float fCurValue; // 表示相机当前的帧率 - * - float fMax; // 表示相机允许设置的最大帧率 - * - float fMin; // 表示相机允许设置的最小帧率 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他浮点型结构体参数的接口可参照此接口 - - * @~english - * @brief Get Frame Rate - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera frame rate to user - * The meaning of returns pstValue structure - * - float fCurValue; // Indicates the current frame rate of the camera - * - float fMax; // Indicates the maximum frame rate allowed by the camera - * - float fMin; // Indicates the minimum frame rate allowed by the camera - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Other interface of Float structure parameters can refer to this interface - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置帧率 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机帧率 - * @return 成功,返回#MV_OK,并且相机帧率将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set frame rate - * @param handle [IN] Camera Handle - * @param fValue [IN] Camera frame rate to set - * @return Success, return #MV_OK, and camera frame rate will be changed to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); - -/********************************************************************//** - * @~chinese - * @brief 获取增益 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机增益的信息结构体指针 - * 返回的pstValue结构体的意义 - * - float fCurValue; // 表示相机当前的帧率 - * - float fMax; // 表示相机允许设置的最大帧率 - * - float fMin; // 表示相机允许设置的最小帧率 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他浮点型结构体参数的接口可参照此接口 - - * @~english - * @brief Get Gain - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to gain to user - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * - float fCurValue; // Camera current gain - * - float fMax; // The maximum gain camera allowed - * - float fMin; // The minimum gain camera allowed - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Other interface of Float structure parameters can refer to this interface - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置帧率 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机帧率 - * @return 成功,返回#MV_OK,并且相机帧率将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Gain - * @param handle [IN] Camera Handle - * @param fValue [IN] Gain value to set - * @return Success, return #MV_OK, and the camera gain value will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); - -/********************************************************************//** - * @~chinese - * @brief 获取曝光时间 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机曝光时间的信息结构体指针 - * 返回的pstValue结构体的意义 - * - float fCurValue; // 表示相机当前的帧率 - * - float fMax; // 表示相机允许设置的最大帧率 - * - float fMin; // 表示相机允许设置的最小帧率 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他浮点型结构体参数的接口可参照此接口 - - * @~english - * @brief Get exposure time - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to exposure time to user - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * - float fCurValue; // Camera current exposure time - * - float fMax; // The maximum exposure time camera allowed - * - float fMin; // The minimum exposure time camera allowed - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Other interface of Float structure parameters can refer to this interface - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置曝光时间 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机帧率 - * @return 成功,返回#MV_OK,并且相机帧率将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set exposure time - * @param handle [IN] Camera Handle - * @param fValue [IN] Exposure time to set - * @return Success, return #MV_OK, and the camera exposure time value will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); - -/********************************************************************//** - * @~chinese - * @brief 获取像素格式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关像素格式的信息结构体指针 \n - * 返回的pstValue结构体的意义 - * - unsigned int nCurValue; // 相机当前的像素格式,是枚举类型,比如说PixelType_Gvsp_Mono8, 这里获得的是其整型值,具体数值参照PixelType.h的MvGvspPixelType枚举类型 - * - unsigned int nSupportedNum; // 相机支持的像素格式的个数 - * - unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // 相机所有支持的像素格式对应的整型值列表,后面要设置像素格式时,参数必须是这个数组中的一种,否则无效 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他枚举类型参数接口可参照此接口,有关相应参数的枚举类型对应的整型值请查找PixelType.h 和 CameraParams.h中相应的定义 - - * @~english - * @brief Get Pixel Format - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Returns the information structure pointer about pixel format for the caller \n - * The meaning of returns pstValue structure - * - unsigned int nCurValue; // The current pixel format of the camera, is the enumeration type, such as #PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to MvGvspPixelType enumeration type in PixelType.h - * - unsigned int nSupportedNum; // Number of pixel formats supported by the camera - * - unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this list, otherwise invalid - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Other interface of Enumeration structure parameters can refer to this interface, look for the corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置像素格式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的像素格式对应的整型值,调用此接口时可以直接填写枚举值,如#MV_CC_SetPixelFormat(m_handle, #PixelType_Gvsp_RGB8_Packed); - * @return 成功,返回#MV_OK,并且相机像素格式将会更改为相应值,失败,返回错误码 - * @remarks 要设置的枚举类型必须是Get接口返回的nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]中的一种,否则会失败 - - * @~english - * @brief Set Pixel Format - * @param handle [IN] Camera Handle - * @param nValue [IN] The corresponding integer value for pixel format to be set, when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); - * @return Success, return #MV_OK, and the camera pixel format will change to the corresponding value. Failure, return error code - * @remarks Other interface of Enumeration structure parameters can refer to this interface, the enumeration type to be set must be one of the nSupportValue [#MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it will fail - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取采集模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关采集模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的#MV_CAM_ACQUISITION_MODE 定义 - - * @~english - * @brief Get acquisition mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of acquisition mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_ACQUISITION_MODE in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置像素格式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的采集模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机采集模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set acquisition mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to acquisition mode - * @return Success, return #MV_OK, and the camera acquisition mode will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取增益模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关增益模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_GAIN_MODE 定义 - - * @~english - * @brief Get gain mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of gain mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_GAIN_MODE in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置增益模式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的增益模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机增益模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set gain mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to gain mode - * @return Success, return #MV_OK, and the camera gain mode will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取自动曝光模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关自动曝光模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的#MV_CAM_EXPOSURE_AUTO_MODE 定义 - - * @~english - * @brief Get auto exposure mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of auto exposure mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_EXPOSURE_AUTO_MODE in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置自动曝光模式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的自动曝光模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机自动曝光模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set auto exposure mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to auto exposure mode - * @return Success, return #MV_OK, and the camera auto exposure mode will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取触发模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关触发模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的#MV_CAM_TRIGGER_MODE 定义 - - * @~english - * @brief Get trigger mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of trigger mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_TRIGGER_MODE in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置触发模式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的触发模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机触发模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set trigger mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to trigger mode - * @return Success, return #MV_OK, and the camera trigger mode will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取触发延时 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机触发延时的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetFrameRate - - * @~english - * @brief Get tigger delay - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of trigger delay - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to MV_CC_GetFrameRate - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置触发延时 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机触发延时 - * @return 成功,返回#MV_OK,并且相机触发延时将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set tigger delay - * @param handle [IN] Handle - * @param fValue [IN] Trigger delay to set - * @return Success, return #MV_OK, and the camera trigger delay will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); - -/********************************************************************//** - * @~chinese - * @brief 获取触发源 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关触发源的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_TRIGGER_SOURCE 定义 - - * @~english - * @brief Get trigger source - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of trigger source - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置触发源 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的触发源对应的整型值 - * @return 成功,返回#MV_OK,并且相机触发源将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set trigger source - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to trigger source - * @return Success, return #MV_OK, and the camera trigger source will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 软触发一次(接口仅在已选择的触发源为软件触发时有效) - * @param handle [IN] 相机句柄 - * @return 成功,返回#MV_OK, 失败,返回错误码 - * @remarks - - * @~english - * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) - * @param handle [IN] Handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); - -/********************************************************************//** - * @~chinese - * @brief 获取Gamma类型 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关Gamma类型的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_GAMMA_SELECTOR 定义 - - * @~english - * @brief Get Gamma mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of gamma mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Gamma类型 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的Gamma类型对应的整型值 - * @return 成功,返回#MV_OK,并且相机Gamma类型将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Gamma mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to gamma mode - * @return Success, return #MV_OK, and the camera gamma mode will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取Gamma值 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机Gamma值的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetExposureTime - - * @~english - * @brief Get Gamma value - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of gamma value - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to MV_CC_GetFrameRate - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置Gamma值 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机Gamma值 - * @return 成功,返回#MV_OK,并且相机Gamma值将会更改为相应值,失败,返回错误码 - - * @~english - * @brief Set Gamma value - * @param handle [IN] Handle - * @param fValue [IN] Gamma value to set - * @return Success, return #MV_OK, and the camera gamma value will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); - -/********************************************************************//** - * @~chinese - * @brief 获取锐度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机锐度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get sharpness - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of sharpness - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置锐度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的锐度 - * @return 成功,返回#MV_OK,并且相机锐度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set sharpness - * @param handle [IN] Handle - * @param nValue [IN] Sharpness to set - * @return Success, return #MV_OK, and the camera sharpness will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取灰度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机灰度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get Hue - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of Hue - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置灰度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的灰度 - * @return 成功,返回#MV_OK,并且相机灰度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Hue - * @param handle [IN] Handle - * @param nValue [IN] Hue to set - * @return Success, return #MV_OK, and the camera Hue will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取饱和度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机饱和度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get Saturation - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of Saturation - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置饱和度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的饱和度 - * @return 成功,返回#MV_OK,并且相机饱和度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Saturation - * @param handle [IN] Handle - * @param nValue [IN] Saturation to set - * @return Success, return #MV_OK, and the camera Saturation will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取自动白平衡 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关自动白平衡的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_BALANCEWHITE_AUTO 定义 - - - * @~english - * @brief Get Auto white balance - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of auto white balance - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error code - * @remarks Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParams.h - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置自动白平衡 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的自动白平衡对应的整型值 - * @return 成功,返回#MV_OK,并且相机自动白平衡将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Auto white balance - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to auto white balance - * @return Success, return #MV_OK, and the camera auto white balance will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取白平衡 红 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机白平衡 红结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get white balance red - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of white balance red - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置白平衡 红 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的白平衡 红 - * @return 成功,返回#MV_OK,并且相机白平衡 红将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set white balance red - * @param handle [IN] Handle - * @param nValue [IN] White balance red to set - * @return Success, return #MV_OK, and the camera white balance red will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取白平衡 绿 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机白平衡 绿结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get white balance green - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of white balance green - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置白平衡 绿 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的白平衡 绿 - * @return 成功,返回#MV_OK,并且相机白平衡 绿将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set white balance green - * @param handle [IN] Handle - * @param nValue [IN] White balance green to set - * @return Success, return #MV_OK, and the camera white balance green will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取白平衡 蓝 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机白平衡 蓝结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get white balance blue - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of white balance blue - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置白平衡 蓝 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的白平衡 蓝 - * @return 成功,返回#MV_OK,并且相机白平衡 蓝将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set white balance blue - * @param handle [IN] Handle - * @param nValue [IN] White balance blue to set - * @return Success, return #MV_OK, and the camera white balance blue will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取水印信息内包含的信息类型 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机水印信息内包含的信息类型结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get information type included by frame stamp - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of information type included by frame stamp - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置水印信息内包含的信息类型 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的水印信息内包含的信息类型 - * @return 成功,返回#MV_OK,并且相机水印信息内包含的信息类型会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set information type included by frame stamp - * @param handle [IN] Handle - * @param nValue [IN] Information type included by frame stamp to set - * @return Success, return #MV_OK, and the camera information type included by frame stamp will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取设备自定义名字 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机名字结构体指针 - * @return 成功,返回#MV_OK,并且获取到相机的自定义名字,失败,返回错误码 - * @remarks - - * @~english - * @brief Get device user defined name - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of device name - * @return Success, return #MV_OK, and get the camera user defined name. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置设备自定义名字 - * @param handle [IN] 相机句柄 - * @param chValue [IN] 设备名字 - * @return 成功,返回#MV_OK,并且设置设备自定义名字,失败,返回错误码 - * @remarks - - * @~english - * @brief Set device user defined name - * @param handle [IN] Handle - * @param chValue [IN] Device name - * @return Success, return #MV_OK, and set the camera user defined name. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); - -/********************************************************************//** - * @~chinese - * @brief 获取一次触发的帧数 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机一次触发的帧数结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get frame number trigger by once - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of frame number trigger by once - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置一次触发的帧数 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的一次触发的帧数 - * @return 成功,返回#MV_OK,并且相机一次触发的帧数会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set frame number trigger by once - * @param handle [IN] Handle - * @param nValue [IN] Frame number trigger by once to set - * @return Success, return #MV_OK, and the camera frame number trigger by once will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取行频 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机行频结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get line rate - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of line rate - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置行频 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的行频 - * @return 成功,返回#MV_OK,并且相机行频会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set line rate - * @param handle [IN] Handle - * @param nValue [IN] Line rate to set - * @return Success, return #MV_OK, and the camera line rate will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取心跳信息 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机心跳信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get heartbeat information - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of heartbeat information - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置心跳信息 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的心跳信息 - * @return 成功,返回#MV_OK,并且相机心跳信息会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set heartbeat information - * @param handle [IN] Handle - * @param nValue [IN] Heartbeat information to set - * @return Success, return #MV_OK, and the camera heartbeat information will change to the corresponding value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取网络包大小 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机网络包大小结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get network packet size - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of network packet size - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置网络包大小 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的网络包大小 - * @return 成功,返回#MV_OK,并且相机网络包大小会更改为相应值,失败,返回错误码 - - * @~english - * @brief Set network packet size - * @param handle [IN] Handle - * @param nValue [IN] Packet size to set - * @return Success, return #MV_OK, and change packet size to setting value. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取网络包发送间隔 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机网络包发送间隔结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get network packet sending delay - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of network packet sending delay - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); - -/********************************************************************//** - * @~chinese - * @brief 设置网络包发送间隔 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的网络包发送间隔 - * @return 成功,返回#MV_OK,并且相机网络包发送间隔会更改为相应值,失败,返回错误码 - - * @~english - * @brief Set network packet sending delay - * @param handle [IN] Handle - * @param nValue [IN] Packet delay to set - * @return Success, return #MV_OK, and change packet delay to setting value. Failure, return error code - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); - -/********************************************************************//** - * @~chinese - * @brief 获取接收端IP地址,0xa9fe0102 表示 169.254.1.2 - * @param handle [IN] 相机句柄 - * @param pnIP [IN][OUT] 返回给调用者接收端IP地址 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - - * @~english - * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 - * @param handle [IN] Handle - * @param pnIP [IN][OUT] Receiver IP address - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); - -/********************************************************************//** - * @~chinese - * @brief 设置接收端IP地址 - * @param handle [IN] 相机句柄 - * unsigned int nIP [IN] 想要设置的接收端IP地址 - * @return 成功,返回#MV_OK,并且相机接收端IP地址会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set receiver IP address - * @param handle [IN] Handel - * unsigned int nIP [IN] Receiver IP address to set - * @return Success, return #MV_OK, and change receiver IP address to setting value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); - -/********************************************************************//** - * @~chinese - * @brief 获取发送端的端口号 - * @param handle [IN] 相机句柄 - * @param pnPort [IN][OUT] 返回给调用者发送端的端口号 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - - * @~english - * @brief Get transmitter port number - * @param handle [IN] Handle - * @param pnPort [IN][OUT] Transmitter port number - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); - -/********************************************************************//** - * @~chinese - * @brief 设置发送端的端口号 - * @param handle [IN] 相机句柄 - * @param nPort [IN] 想要设置的发送端的端口号 - * @return 成功,返回#MV_OK,并且相机发送端的端口号会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set transmitter port number - * @param handle [IN] Handle - * @param nPort [IN] Transmitter port number to set - * @return Success, return #MV_OK, and change transmitter port number to setting value. Failure, return error code - * @remarks - ************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); - - -/************************************************************************/ -/* CameraLink 设备独有的接口,Linux 平台不支持 */ -/* APIs only support CameraLink device, not supported on Linux */ -/************************************************************************/ -/********************************************************************//** - * @~chinese - * @brief 设置设备波特率 - * @param handle [IN] 设备句柄 - * @param nBaudrate [IN] 设置的波特率值,数值参考CameraParams.h中宏定义,如#define MV_CAML_BAUDRATE_9600 0x00000001 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口接口支持在设备未连接时调用。 - - * @~english - * @brief Set device bauderate using one of the CL_BAUDRATE_XXXX value - * @param handle [IN] Device handle - * @param nBaudrate [IN] baud rate to set. Refer to the CameraParams.h for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by CameraLink device.\n - This API supports calls when devices are not connected. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate); - -/********************************************************************//** - * @~chinese - * @brief 获取设备波特率 - * @param handle [IN] 设备句柄 - * @param pnCurrentBaudrate [OUT] 波特率信息指针,数值参考CameraParams.h中宏定义,如#define MV_CAML_BAUDRATE_9600 0x00000001 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口接口支持在设备未连接时调用。 - - * @~english - * @brief Returns the current device bauderate, using one of the CL_BAUDRATE_XXXX value - * @param handle [IN] Device handle - * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the CameraParams.h for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by CameraLink device.\n - This API supports calls when devices are not connected. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBauderate(IN void* handle, unsigned int* pnCurrentBaudrate); - -/********************************************************************//** - * @~chinese - * @brief 获取设备与主机间连接支持的波特率 - * @param handle [IN] 设备句柄 - * @param pnBaudrateAblity [OUT] 支持的波特率信息的指针。所支持波特率的或运算结果,单个数值参考CameraParams.h中宏定义,如#define MV_CAML_BAUDRATE_9600 0x00000001 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口接口支持在设备未连接时调用。 - - * @~english - * @brief Returns supported bauderates of the combined device and host interface - * @param handle [IN] Device handle - * @param pnBaudrateAblity [OUT] Return pointer of the supported bauderates to user. 'OR' operation results of the supported bauderates. Refer to the CameraParams.h for single value definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by CameraLink device.\n - This API supports calls when devices are not connected. -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBauderates(IN void* handle, unsigned int* pnBaudrateAblity); - -/********************************************************************//** - * @~chinese - * @brief 设置串口操作等待时长 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 串口操作的等待时长, ms - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - - * @~english - * @brief Sets the timeout for operations on the serial port - * @param handle [IN] Device handle - * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. - * @return Success, return #MV_OK. Failure, return error code - * @return Success, return MV_OK. Failure, return error code -************************************************************************/ -MV_CAMCTRL_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void* handle, unsigned int nMillisec); - -#ifdef __cplusplus -} -#endif - -#endif //_MV_CAMERA_CTRL_H_ diff --git a/hnurm_camera/CameraCalibration/include/MvErrorDefine.h b/hnurm_camera/CameraCalibration/include/MvErrorDefine.h deleted file mode 100755 index 523b4963a36fc4bdd3d1e275289dd967df203234..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/MvErrorDefine.h +++ /dev/null @@ -1,104 +0,0 @@ - -#ifndef _MV_ERROR_DEFINE_H_ -#define _MV_ERROR_DEFINE_H_ - -/********************************************************************/ -/// \~chinese -/// \name 正确码定义 -/// @{ -/// \~english -/// \name Definition of correct code -/// @{ -#define MV_OK 0x00000000 ///< \~chinese 成功,无错误 \~english Successed, no error -/// @} - -/********************************************************************/ -/// \~chinese -/// \name 通用错误码定义:范围0x80000000-0x800000FF -/// @{ -/// \~english -/// \name Definition of General error code -/// @{ -#define MV_E_HANDLE 0x80000000 ///< \~chinese 错误或无效的句柄 \~english Error or invalid handle -#define MV_E_SUPPORT 0x80000001 ///< \~chinese 不支持的功能 \~english Not supported function -#define MV_E_BUFOVER 0x80000002 ///< \~chinese 缓存已满 \~english Buffer overflow -#define MV_E_CALLORDER 0x80000003 ///< \~chinese 函数调用顺序错误 \~english Function calling order error -#define MV_E_PARAMETER 0x80000004 ///< \~chinese 错误的参数 \~english Incorrect parameter -#define MV_E_RESOURCE 0x80000006 ///< \~chinese 资源申请失败 \~english Applying resource failed -#define MV_E_NODATA 0x80000007 ///< \~chinese 无数据 \~english No data -#define MV_E_PRECONDITION 0x80000008 ///< \~chinese 前置条件有误,或运行环境已发生变化 \~english Precondition error, or running environment changed -#define MV_E_VERSION 0x80000009 ///< \~chinese 版本不匹配 \~english Version mismatches -#define MV_E_NOENOUGH_BUF 0x8000000A ///< \~chinese 传入的内存空间不足 \~english Insufficient memory -#define MV_E_ABNORMAL_IMAGE 0x8000000B ///< \~chinese 异常图像,可能是丢包导致图像不完整 \~english Abnormal image, maybe incomplete image because of lost packet -#define MV_E_LOAD_LIBRARY 0x8000000C ///< \~chinese 动态导入DLL失败 \~english Load library failed -#define MV_E_NOOUTBUF 0x8000000D ///< \~chinese 没有可输出的缓存 \~english No Avaliable Buffer -#define MV_E_UNKNOW 0x800000FF ///< \~chinese 未知的错误 \~english Unknown error -/// @} - -/********************************************************************/ -/// \~chinese -/// \name GenICam系列错误:范围0x80000100-0x800001FF -/// @{ -/// \~english -/// \name GenICam Series Error Codes: Range from 0x80000100 to 0x800001FF -/// @{ -#define MV_E_GC_GENERIC 0x80000100 ///< \~chinese 通用错误 \~english General error -#define MV_E_GC_ARGUMENT 0x80000101 ///< \~chinese 参数非法 \~english Illegal parameters -#define MV_E_GC_RANGE 0x80000102 ///< \~chinese 值超出范围 \~english The value is out of range -#define MV_E_GC_PROPERTY 0x80000103 ///< \~chinese 属性 \~english Property -#define MV_E_GC_RUNTIME 0x80000104 ///< \~chinese 运行环境有问题 \~english Running environment error -#define MV_E_GC_LOGICAL 0x80000105 ///< \~chinese 逻辑错误 \~english Logical error -#define MV_E_GC_ACCESS 0x80000106 ///< \~chinese 节点访问条件有误 \~english Node accessing condition error -#define MV_E_GC_TIMEOUT 0x80000107 ///< \~chinese 超时 \~english Timeout -#define MV_E_GC_DYNAMICCAST 0x80000108 ///< \~chinese 转换异常 \~english Transformation exception -#define MV_E_GC_UNKNOW 0x800001FF ///< \~chinese GenICam未知错误 \~english GenICam unknown error -/// @} - -/********************************************************************/ -/// \~chinese -/// \name GigE_STATUS对应的错误码:范围0x80000200-0x800002FF -/// @{ -/// \~english -/// \name GigE_STATUS Error Codes: Range from 0x80000200 to 0x800002FF -/// @{ -#define MV_E_NOT_IMPLEMENTED 0x80000200 ///< \~chinese 命令不被设备支持 \~english The command is not supported by device -#define MV_E_INVALID_ADDRESS 0x80000201 ///< \~chinese 访问的目标地址不存在 \~english The target address being accessed does not exist -#define MV_E_WRITE_PROTECT 0x80000202 ///< \~chinese 目标地址不可写 \~english The target address is not writable -#define MV_E_ACCESS_DENIED 0x80000203 ///< \~chinese 设备无访问权限 \~english No permission -#define MV_E_BUSY 0x80000204 ///< \~chinese 设备忙,或网络断开 \~english Device is busy, or network disconnected -#define MV_E_PACKET 0x80000205 ///< \~chinese 网络包数据错误 \~english Network data packet error -#define MV_E_NETER 0x80000206 ///< \~chinese 网络相关错误 \~english Network error -#define MV_E_IP_CONFLICT 0x80000221 ///< \~chinese 设备IP冲突 \~english Device IP conflict -/// @} - -/********************************************************************/ -/// \~chinese -/// \name USB_STATUS对应的错误码:范围0x80000300-0x800003FF -/// @{ -/// \~english -/// \name USB_STATUS Error Codes: Range from 0x80000300 to 0x800003FF -/// @{ -#define MV_E_USB_READ 0x80000300 ///< \~chinese 读usb出错 \~english Reading USB error -#define MV_E_USB_WRITE 0x80000301 ///< \~chinese 写usb出错 \~english Writing USB error -#define MV_E_USB_DEVICE 0x80000302 ///< \~chinese 设备异常 \~english Device exception -#define MV_E_USB_GENICAM 0x80000303 ///< \~chinese GenICam相关错误 \~english GenICam error -#define MV_E_USB_BANDWIDTH 0x80000304 ///< \~chinese 带宽不足 该错误码新增 \~english Insufficient bandwidth, this error code is newly added -#define MV_E_USB_DRIVER 0x80000305 ///< \~chinese 驱动不匹配或者未装驱动 \~english Driver mismatch or unmounted drive -#define MV_E_USB_UNKNOW 0x800003FF ///< \~chinese USB未知的错误 \~english USB unknown error -/// @} - -/********************************************************************/ -/// \~chinese -/// \name 升级时对应的错误码:范围0x80000400-0x800004FF -/// @{ -/// \~english -/// \name Upgrade Error Codes: Range from 0x80000400 to 0x800004FF -/// @{ -#define MV_E_UPG_FILE_MISMATCH 0x80000400 ///< \~chinese 升级固件不匹配 \~english Firmware mismatches -#define MV_E_UPG_LANGUSGE_MISMATCH 0x80000401 ///< \~chinese 升级固件语言不匹配 \~english Firmware language mismatches -#define MV_E_UPG_CONFLICT 0x80000402 ///< \~chinese 升级冲突(设备已经在升级了再次请求升级即返回此错误) \~english Upgrading conflicted (repeated upgrading requests during device upgrade) -#define MV_E_UPG_INNER_ERR 0x80000403 ///< \~chinese 升级时相机内部出现错误 \~english Camera internal error during upgrade -#define MV_E_UPG_UNKNOW 0x800004FF ///< \~chinese 升级时未知错误 \~english Unknown error during upgrade -/// @} - -#endif //_MV_ERROR_DEFINE_H_ diff --git a/hnurm_camera/CameraCalibration/include/PixelType.h b/hnurm_camera/CameraCalibration/include/PixelType.h deleted file mode 100755 index 29c5e017473cc34b681eea579408abd0de6dc508..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/PixelType.h +++ /dev/null @@ -1,159 +0,0 @@ - -#ifndef _MV_PIXEL_TYPE_H_ -#define _MV_PIXEL_TYPE_H_ - -//#include "Base/GCTypes.h" - - -/************************************************************************/ -/* GigE Vision (2.0.03) PIXEL FORMATS */ -/************************************************************************/ - -// Indicate if pixel is monochrome or RGB -#define MV_GVSP_PIX_MONO 0x01000000 -#define MV_GVSP_PIX_RGB 0x02000000 // deprecated in version 1.1 -#define MV_GVSP_PIX_COLOR 0x02000000 -#define MV_GVSP_PIX_CUSTOM 0x80000000 -#define MV_GVSP_PIX_COLOR_MASK 0xFF000000 - -// Indicate effective number of bits occupied by the pixel (including padding). -// This can be used to compute amount of memory required to store an image. -#define MV_PIXEL_BIT_COUNT(n) ((n) << 16) - -#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_MASK 0x00FF0000 -#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_SHIFT 16 - -// Pixel ID: lower 16-bit of the pixel formats -#define MV_GVSP_PIX_ID_MASK 0x0000FFFF -#define MV_GVSP_PIX_COUNT 0x46 // next Pixel ID available - - -enum MvGvspPixelType -{ - // Undefined pixel type -#ifdef WIN32 - PixelType_Gvsp_Undefined = 0xFFFFFFFF, -#else - PixelType_Gvsp_Undefined = -1, -#endif - // Mono buffer format defines - PixelType_Gvsp_Mono1p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(1) | 0x0037), - PixelType_Gvsp_Mono2p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(2) | 0x0038), - PixelType_Gvsp_Mono4p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(4) | 0x0039), - PixelType_Gvsp_Mono8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), - PixelType_Gvsp_Mono8_Signed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0002), - PixelType_Gvsp_Mono10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), - PixelType_Gvsp_Mono10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), - PixelType_Gvsp_Mono12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), - PixelType_Gvsp_Mono12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), - PixelType_Gvsp_Mono14 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0025), - PixelType_Gvsp_Mono16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), - - // Bayer buffer format defines - PixelType_Gvsp_BayerGR8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), - PixelType_Gvsp_BayerRG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), - PixelType_Gvsp_BayerGB8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), - PixelType_Gvsp_BayerBG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), - PixelType_Gvsp_BayerGR10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), - PixelType_Gvsp_BayerRG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), - PixelType_Gvsp_BayerGB10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), - PixelType_Gvsp_BayerBG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), - PixelType_Gvsp_BayerGR12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), - PixelType_Gvsp_BayerRG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), - PixelType_Gvsp_BayerGB12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), - PixelType_Gvsp_BayerBG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), - PixelType_Gvsp_BayerGR10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), - PixelType_Gvsp_BayerRG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), - PixelType_Gvsp_BayerGB10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), - PixelType_Gvsp_BayerBG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), - PixelType_Gvsp_BayerGR12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), - PixelType_Gvsp_BayerRG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), - PixelType_Gvsp_BayerGB12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), - PixelType_Gvsp_BayerBG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), - PixelType_Gvsp_BayerGR16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002E), - PixelType_Gvsp_BayerRG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002F), - PixelType_Gvsp_BayerGB16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0030), - PixelType_Gvsp_BayerBG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0031), - - // RGB Packed buffer format defines - PixelType_Gvsp_RGB8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), - PixelType_Gvsp_BGR8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), - PixelType_Gvsp_RGBA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), - PixelType_Gvsp_BGRA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), - PixelType_Gvsp_RGB10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0018), - PixelType_Gvsp_BGR10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0019), - PixelType_Gvsp_RGB12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001A), - PixelType_Gvsp_BGR12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001B), - PixelType_Gvsp_RGB16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033), - PixelType_Gvsp_RGB10V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001C), - PixelType_Gvsp_RGB10V2_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001D), - PixelType_Gvsp_RGB12V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(36) | 0X0034), - PixelType_Gvsp_RGB565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0035), - PixelType_Gvsp_BGR565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0X0036), - - // YUV Packed buffer format defines - PixelType_Gvsp_YUV411_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x001E), - PixelType_Gvsp_YUV422_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), - PixelType_Gvsp_YUV422_YUYV_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), - PixelType_Gvsp_YUV444_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0020), - PixelType_Gvsp_YCBCR8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003A), - PixelType_Gvsp_YCBCR422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003B), - PixelType_Gvsp_YCBCR422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0043), - PixelType_Gvsp_YCBCR411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003C), - PixelType_Gvsp_YCBCR601_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003D), - PixelType_Gvsp_YCBCR601_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003E), - PixelType_Gvsp_YCBCR601_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0044), - PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003F), - PixelType_Gvsp_YCBCR709_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0040), - PixelType_Gvsp_YCBCR709_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0041), - PixelType_Gvsp_YCBCR709_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0045), - PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x0042), - - // RGB Planar buffer format defines - PixelType_Gvsp_RGB8_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0021), - PixelType_Gvsp_RGB10_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0022), - PixelType_Gvsp_RGB12_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0023), - PixelType_Gvsp_RGB16_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0024), - - // 自定义的图片格式 - PixelType_Gvsp_Jpeg = (MV_GVSP_PIX_CUSTOM | MV_PIXEL_BIT_COUNT(24) | 0x0001), - - PixelType_Gvsp_Coord3D_ABC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C0),//0x026000C0 - PixelType_Gvsp_Coord3D_ABC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C1),//0x026000C1 - - // 该值被废弃,请参考PixelType_Gvsp_Coord3D_AC32f_64; the value is discarded - PixelType_Gvsp_Coord3D_AC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(40) | 0x00C2), - // 该值被废弃; the value is discarded (已放入Chunkdata) - PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(28) | 0x0001), - - PixelType_Gvsp_Coord3D_ABC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x3001),//0x82603001 - PixelType_Gvsp_Coord3D_AB32f = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3002),//0x82403002 - PixelType_Gvsp_Coord3D_AB32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3003),//0x82403003 - PixelType_Gvsp_Coord3D_AC32f_64 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C2),//0x024000C2 - PixelType_Gvsp_Coord3D_AC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C3),//0x024000C3 - PixelType_Gvsp_Coord3D_AC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3004),//0x82403004 - PixelType_Gvsp_Coord3D_A32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BD),//0x012000BD - PixelType_Gvsp_Coord3D_A32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3005),//0x81203005 - PixelType_Gvsp_Coord3D_C32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BF),//0x012000BF - PixelType_Gvsp_Coord3D_C32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3006),//0x81203006 - - PixelType_Gvsp_Coord3D_ABC16 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x00B9),//0x023000B9 - -}; - -//enum MvUsbPixelType -//{ -// -//}; - -//跨平台定义 -//Cross Platform Definition -#ifdef WIN32 -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -#include -#endif - - -#endif /* _MV_PIXEL_TYPE_H_ */ diff --git a/hnurm_camera/CameraCalibration/include/TimeQueue.hpp b/hnurm_camera/CameraCalibration/include/TimeQueue.hpp deleted file mode 100755 index 086ba0668e5c60b0c4896dff5366d33a2c8af735..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/TimeQueue.hpp +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef DATA_QUEUE_HPP -#define DATA_QUEUE_HPP - -#include -#include -#include -#include - -using namespace std::literals; - -namespace hnurm -{ - template - class TimeQueue - { - - using Us = std::chrono::microseconds; - using tp = std::chrono::time_point; - - private: - int size_; /**< 队列的最大大小 */ - std::queue> data_queue; /**< 数据队列 */ - std::timed_mutex mtx; /**< 带有超时功能的互斥锁 */ - - public: - /** - * @brief 时间队列的构造函数 - * - * @param max_size 队列的最大大小,默认为1000 - */ - explicit TimeQueue(int max_size = 1000) : size_(max_size) {} - - /** - * @brief 从时间队列中取出一个距离传入时间最近的数据,并将其从队列中删除 - * - * @param data 要获取的数据 - * @param time 传入的时间 - * @return 如果成功取出数据并删除,则返回true,否则返回false - */ - bool Get(DataType &data, tp &time); - - /** - * @brief 向时间队列中更新数据 - * - * @param data 要更新的数据 - * @param time 数据的更新时间 - * @return 如果成功更新数据,则返回true,否则返回false - */ - bool Update(const DataType &data, tp &time); - }; - - /** - * @brief 从时间队列中取出一个距离传入时间最近的数据,并将其从队列中删除 - * - * @param data 要获取的数据 - * @param time 传入的时间 - * @return - */ - template - bool TimeQueue::Get(DataType &data, tp &time) - { - if (mtx.try_lock_for(2us)) { - std::lock_guard guard(mtx, std::adopt_lock); - Us delta_t; - if (!data_queue.empty()) { // 队列不为空 - data = data_queue.front().first;// 初始化时间差 - delta_t = std::chrono::duration_cast(std::chrono::abs(data_queue.front().second - time)); - data_queue.pop(); - while (!data_queue.empty())// 队列不为空,继续寻找更近的数据 - { - if (abs(data_queue.front().second - time) < delta_t)// 找到更近的数据 - { - data = data_queue.front().first; - delta_t = std::chrono::duration_cast(std::chrono::abs(data_queue.front().second - time)); - data_queue.pop(); - continue;// 下一轮可能还有更近的数据 - } - return true;// 判断不通过,说明已经不能再找到更近的数据了 - } - return true;// 队列已经为空也直接返回 - } - } - return false; // 锁不上||队列为空 - } - - /** - * @brief 向时间队列中更新数据 - * - * @param data 要更新的数据 - * @param time 数据的更新时间 - * @return - */ - template - bool TimeQueue::Update(const DataType &data, tp &time) - { - if (mtx.try_lock_for(2ms)) - { - std::lock_guard guard(mtx, std::adopt_lock); - while (data_queue.size() >= size_) // 队列满了,清除最早的数据直到队列有空位 - data_queue.pop(); - data_queue.push(std::make_pair(data, time)); - return true; - } - return false; - } - -} // namespace - -#endif // !DATA_QUEUE_HPP \ No newline at end of file diff --git a/hnurm_camera/CameraCalibration/include/armor.hpp b/hnurm_camera/CameraCalibration/include/armor.hpp deleted file mode 100755 index f0de85e02dd4a401d191dcc822818fae52f1e721..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/armor.hpp +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2022 Chen Jun -// 在MIT许可证下发布。 - -#ifndef ARMOR_DETECTOR_ARMOR_HPP_ -#define ARMOR_DETECTOR_ARMOR_HPP_ - -#include -#include -#include - -// STL -#include -#include - -namespace hnurm -{ - const int BLUE = 0; - const int RED = 1; - - enum ArmorType - { - SMALL = 0, LARGE = 1 - }; - - /** - * @brief Light类表示一个灯,继承自cv::RotatedRect类 - */ - struct Light: public cv::RotatedRect - { - Light() = default; - - /** - * @brief 构造函数 - * @param box 矩形框 - */ - explicit Light(const cv::RotatedRect& box) - : cv::RotatedRect(box) - { - cv::Point2f p[4]; - box.points(p); - std::sort(p, p + 4, [](const cv::Point2f &a, const cv::Point2f &b) - { return a.y < b.y; }); - top = (p[0] + p[1]) / 2; - bottom = (p[2] + p[3]) / 2; - - length = cv::norm(top - bottom); - width = cv::norm(p[0] - p[1]); - - tilt_angle = std::atan2(std::abs(top.x - bottom.x), std::abs(top.y - bottom.y)); - tilt_angle = tilt_angle / CV_PI * 180; - } - - int color; // 灯的颜色 - cv::Point2f top, bottom; // 灯的顶点和底点 - double length; // 灯的长度 - double width; // 灯的宽度 - float tilt_angle; // 灯的倾斜角度 - }; - - /** - * @brief Armor类表示一个装甲,包含灯、中心点、四个角点、数字ROI图像、数字、索引、相似度、置信度、分类结果、装甲类型等信息 - */ - struct Armor - { - // 左灯条、右灯条 - Light left_light, right_light; - - // 装甲板中心点 - cv::Point2f center; - - // 装甲板的四个角点,顺序为左上、左下、右下、右上 - std::vector points2d; - - // 数字ROI图像 - cv::Mat number_img; - - std::string number; // 数字 - int idx{}; // 索引 - float similarity{}; // 相似度 - float confidence{}; // 置信度 - std::string classification_result; // 分类结果 - - ArmorType armor_type = ArmorType::SMALL; // 装甲类型 - - double distance_to_image_center{}; // 距离图像中心的像素值 - // todo - Eigen::Vector3d position; // 位置 - Eigen::Matrix3d rotation; // 旋转 - Eigen::Matrix3d _r1; // 相机坐标系到云台坐标系 - Eigen::Matrix3d _r2; // 先对pitch进行旋转 - Eigen::Matrix3d _r3; // 再对yaw进行旋转,变为世界坐标系(pitch、yaw为0) - Eigen::Matrix3d _rmat; - Eigen::Vector3d _translation; - - Armor() = default; - - /** - * @brief 构造函数 - * @param l1 左灯条 - * @param l2 右灯条 - */ - Armor(const Light &l1, const Light &l2) - { - if (l1.center.x < l2.center.x) - { - left_light = l1, right_light = l2; - } - else - { - left_light = l2, right_light = l1; - } - center = (left_light.center + right_light.center) / 2; - - points2d.resize(9); - points2d[0] = left_light.top; - points2d[1] = left_light.bottom; - points2d[2] = right_light.bottom; - points2d[3] = right_light.top; - - points2d[4] = (left_light.top+right_light.top)/2; - points2d[5] = (left_light.top+left_light.bottom)/2; - points2d[6] = (left_light.bottom+right_light.bottom)/2; - points2d[7] = (right_light.bottom+right_light.top)/2; - - points2d[8] = center; - } - - /** - * @brief 在给定的图像上绘制装甲 - * @param canvas 绘制的图像 - */ - void showArmor(cv::Mat &canvas) - { - // 绘制装甲 - cv::line(canvas, points2d[0], points2d[1], cv::Scalar(0, 255, 0), 2); - cv::line(canvas, points2d[1], points2d[2], cv::Scalar(0, 255, 0), 2); - cv::line(canvas, points2d[2], points2d[3], cv::Scalar(0, 255, 0), 2); - cv::line(canvas, points2d[3], points2d[0], cv::Scalar(0, 255, 0), 2); - // 绘制中心点 - cv::circle(canvas, center, 10, cv::Scalar(0, 255, 0), 2); - // 在装甲的左上角绘制分类结果 - cv::putText(canvas, classification_result, points2d[0], cv::FONT_HERSHEY_SIMPLEX, - 1, cv::Scalar(0, 255, 0), 2); - - } - }; - -} // namespace hnurm - -#endif // ARMOR_DETECTOR_ARMOR_HPP_ diff --git a/hnurm_camera/CameraCalibration/include/easylogging++.h b/hnurm_camera/CameraCalibration/include/easylogging++.h deleted file mode 100755 index e53d23b54ea93663114e163fc47e638729604330..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/easylogging++.h +++ /dev/null @@ -1,4581 +0,0 @@ -// -// Bismillah ar-Rahmaan ar-Raheem -// -// Easylogging++ v9.96.7 -// Single-header only, cross-platform logging library for C++ applications -// -// Copyright (c) 2012-2018 Amrayn Web Services -// Copyright (c) 2012-2018 @abumusamq -// -// This library is released under the MIT Licence. -// https://github.com/amrayn/easyloggingpp/blob/master/LICENSE -// -// https://amrayn.com -// http://muflihun.com -// - -#ifndef EASYLOGGINGPP_H -#define EASYLOGGINGPP_H - -#define ELPP_THREAD_SAFE -#define ELPP_FEATURE_CRASH_LOG -#define ELPP_HANDLE_SIGABRT - -// Compilers and C++0x/C++11 Evaluation -#if __cplusplus >= 201103L -# define ELPP_CXX11 1 -#endif // __cplusplus >= 201103L -#if (defined(__GNUC__)) -# define ELPP_COMPILER_GCC 1 -#else -# define ELPP_COMPILER_GCC 0 -#endif -#if ELPP_COMPILER_GCC -# define ELPP_GCC_VERSION (__GNUC__ * 10000 \ -+ __GNUC_MINOR__ * 100 \ -+ __GNUC_PATCHLEVEL__) -# if defined(__GXX_EXPERIMENTAL_CXX0X__) -# define ELPP_CXX0X 1 -# endif -#endif -// Visual C++ -#if defined(_MSC_VER) -# define ELPP_COMPILER_MSVC 1 -#else -# define ELPP_COMPILER_MSVC 0 -#endif -#define ELPP_CRT_DBG_WARNINGS ELPP_COMPILER_MSVC -#if ELPP_COMPILER_MSVC -# if (_MSC_VER == 1600) -# define ELPP_CXX0X 1 -# elif(_MSC_VER >= 1700) -# define ELPP_CXX11 1 -# endif -#endif -// Clang++ -#if (defined(__clang__) && (__clang__ == 1)) -# define ELPP_COMPILER_CLANG 1 -#else -# define ELPP_COMPILER_CLANG 0 -#endif -#if ELPP_COMPILER_CLANG -# if __has_include() -# include // Make __GLIBCXX__ defined when using libstdc++ -# if !defined(__GLIBCXX__) || __GLIBCXX__ >= 20150426 -# define ELPP_CLANG_SUPPORTS_THREAD -# endif // !defined(__GLIBCXX__) || __GLIBCXX__ >= 20150426 -# endif // __has_include() -#endif -#if (defined(__MINGW32__) || defined(__MINGW64__)) -# define ELPP_MINGW 1 -#else -# define ELPP_MINGW 0 -#endif -#if (defined(__CYGWIN__) && (__CYGWIN__ == 1)) -# define ELPP_CYGWIN 1 -#else -# define ELPP_CYGWIN 0 -#endif -#if (defined(__INTEL_COMPILER)) -# define ELPP_COMPILER_INTEL 1 -#else -# define ELPP_COMPILER_INTEL 0 -#endif -// Operating System Evaluation -// Windows -#if (defined(_WIN32) || defined(_WIN64)) -# define ELPP_OS_WINDOWS 1 -#else -# define ELPP_OS_WINDOWS 0 -#endif -// Linux -#if (defined(__linux) || defined(__linux__)) -# define ELPP_OS_LINUX 1 -#else -# define ELPP_OS_LINUX 0 -#endif -#if (defined(__APPLE__)) -# define ELPP_OS_MAC 1 -#else -# define ELPP_OS_MAC 0 -#endif -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) -# define ELPP_OS_FREEBSD 1 -#else -# define ELPP_OS_FREEBSD 0 -#endif -#if (defined(__sun)) -# define ELPP_OS_SOLARIS 1 -#else -# define ELPP_OS_SOLARIS 0 -#endif -#if (defined(_AIX)) -# define ELPP_OS_AIX 1 -#else -# define ELPP_OS_AIX 0 -#endif -#if (defined(__NetBSD__)) -# define ELPP_OS_NETBSD 1 -#else -# define ELPP_OS_NETBSD 0 -#endif -#if defined(__EMSCRIPTEN__) -# define ELPP_OS_EMSCRIPTEN 1 -#else -# define ELPP_OS_EMSCRIPTEN 0 -#endif -#if (defined(__QNX__) || defined(__QNXNTO__)) -# define ELPP_OS_QNX 1 -#else -# define ELPP_OS_QNX 0 -#endif -// Unix -#if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_NETBSD || ELPP_OS_SOLARIS || ELPP_OS_AIX || ELPP_OS_EMSCRIPTEN || ELPP_OS_QNX) && (!ELPP_OS_WINDOWS)) -# define ELPP_OS_UNIX 1 -#else -# define ELPP_OS_UNIX 0 -#endif -#if (defined(__ANDROID__)) -# define ELPP_OS_ANDROID 1 -#else -# define ELPP_OS_ANDROID 0 -#endif -// Evaluating Cygwin as *nix OS -#if !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN -# undef ELPP_OS_UNIX -# undef ELPP_OS_LINUX -# define ELPP_OS_UNIX 1 -# define ELPP_OS_LINUX 1 -#endif // !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN -#if !defined(ELPP_INTERNAL_DEBUGGING_OUT_INFO) -# define ELPP_INTERNAL_DEBUGGING_OUT_INFO std::cout -#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) -#if !defined(ELPP_INTERNAL_DEBUGGING_OUT_ERROR) -# define ELPP_INTERNAL_DEBUGGING_OUT_ERROR std::cerr -#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) -#if !defined(ELPP_INTERNAL_DEBUGGING_ENDL) -# define ELPP_INTERNAL_DEBUGGING_ENDL std::endl -#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) -#if !defined(ELPP_INTERNAL_DEBUGGING_MSG) -# define ELPP_INTERNAL_DEBUGGING_MSG(msg) msg -#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) -// Internal Assertions and errors -#if !defined(ELPP_DISABLE_ASSERT) -# if (defined(ELPP_DEBUG_ASSERT_FAILURE)) -# define ELPP_ASSERT(expr, msg) if (!(expr)) { \ -std::stringstream internalInfoStream; internalInfoStream << msg; \ -ELPP_INTERNAL_DEBUGGING_OUT_ERROR \ -<< "EASYLOGGING++ ASSERTION FAILED (LINE: " << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" \ -<< ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" << ELPP_INTERNAL_DEBUGGING_ENDL; base::utils::abort(1, \ -"ELPP Assertion failure, please define ELPP_DEBUG_ASSERT_FAILURE"); } -# else -# define ELPP_ASSERT(expr, msg) if (!(expr)) { \ -std::stringstream internalInfoStream; internalInfoStream << msg; \ -ELPP_INTERNAL_DEBUGGING_OUT_ERROR\ -<< "ASSERTION FAILURE FROM EASYLOGGING++ (LINE: " \ -<< __LINE__ << ") [" #expr << "] WITH MESSAGE \"" << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" \ -<< ELPP_INTERNAL_DEBUGGING_ENDL; } -# endif // (defined(ELPP_DEBUG_ASSERT_FAILURE)) -#else -# define ELPP_ASSERT(x, y) -#endif //(!defined(ELPP_DISABLE_ASSERT) -#if ELPP_COMPILER_MSVC -# define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \ -{ char buff[256]; strerror_s(buff, 256, errno); \ -ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << buff << " [" << errno << "]";} (void)0 -#else -# define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \ -ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << strerror(errno) << " [" << errno << "]"; (void)0 -#endif // ELPP_COMPILER_MSVC -#if defined(ELPP_DEBUG_ERRORS) -# if !defined(ELPP_INTERNAL_ERROR) -# define ELPP_INTERNAL_ERROR(msg, pe) { \ -std::stringstream internalInfoStream; internalInfoStream << " " << msg; \ -ELPP_INTERNAL_DEBUGGING_OUT_ERROR \ -<< "ERROR FROM EASYLOGGING++ (LINE: " << __LINE__ << ") " \ -<< ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << ELPP_INTERNAL_DEBUGGING_ENDL; \ -if (pe) { ELPP_INTERNAL_DEBUGGING_OUT_ERROR << " "; ELPP_INTERNAL_DEBUGGING_WRITE_PERROR; }} (void)0 -# endif -#else -# undef ELPP_INTERNAL_INFO -# define ELPP_INTERNAL_ERROR(msg, pe) -#endif // defined(ELPP_DEBUG_ERRORS) -#if (defined(ELPP_DEBUG_INFO)) -# if !(defined(ELPP_INTERNAL_INFO_LEVEL)) -# define ELPP_INTERNAL_INFO_LEVEL 9 -# endif // !(defined(ELPP_INTERNAL_INFO_LEVEL)) -# if !defined(ELPP_INTERNAL_INFO) -# define ELPP_INTERNAL_INFO(lvl, msg) { if (lvl <= ELPP_INTERNAL_INFO_LEVEL) { \ -std::stringstream internalInfoStream; internalInfoStream << " " << msg; \ -ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) \ -<< ELPP_INTERNAL_DEBUGGING_ENDL; }} -# endif -#else -# undef ELPP_INTERNAL_INFO -# define ELPP_INTERNAL_INFO(lvl, msg) -#endif // (defined(ELPP_DEBUG_INFO)) -#if (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG)) -# if (ELPP_COMPILER_GCC && !ELPP_MINGW && !ELPP_CYGWIN && !ELPP_OS_ANDROID && !ELPP_OS_EMSCRIPTEN && !ELPP_OS_QNX) -# define ELPP_STACKTRACE 1 -# else -# if ELPP_COMPILER_MSVC -# pragma message("Stack trace not available for this compiler") -# else -# warning "Stack trace not available for this compiler"; -# endif // ELPP_COMPILER_MSVC -# define ELPP_STACKTRACE 0 -# endif // ELPP_COMPILER_GCC -#else -# define ELPP_STACKTRACE 0 -#endif // (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG)) -// Miscellaneous macros -#define ELPP_UNUSED(x) (void)x -#if ELPP_OS_UNIX -// Log file permissions for unix-based systems -# define ELPP_LOG_PERMS S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IRGRP | S_IXGRP | S_IWOTH | S_IXOTH -#endif // ELPP_OS_UNIX -#if defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC -# if defined(ELPP_EXPORT_SYMBOLS) -# define ELPP_EXPORT __declspec(dllexport) -# else -# define ELPP_EXPORT __declspec(dllimport) -# endif // defined(ELPP_EXPORT_SYMBOLS) -#else -# define ELPP_EXPORT -#endif // defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC -// Some special functions that are VC++ specific -#undef STRTOK -#undef STRERROR -#undef STRCAT -#undef STRCPY -#if ELPP_CRT_DBG_WARNINGS -# define STRTOK(a, b, c) strtok_s(a, b, c) -# define STRERROR(a, b, c) strerror_s(a, b, c) -# define STRCAT(a, b, len) strcat_s(a, len, b) -# define STRCPY(a, b, len) strcpy_s(a, len, b) -#else -# define STRTOK(a, b, c) strtok(a, b) -# define STRERROR(a, b, c) strerror(c) -# define STRCAT(a, b, len) strcat(a, b) -# define STRCPY(a, b, len) strcpy(a, b) -#endif -// Compiler specific support evaluations -#if (ELPP_MINGW && !defined(ELPP_FORCE_USE_STD_THREAD)) -# define ELPP_USE_STD_THREADING 0 -#else -# if ((ELPP_COMPILER_CLANG && defined(ELPP_CLANG_SUPPORTS_THREAD)) || \ - (!ELPP_COMPILER_CLANG && defined(ELPP_CXX11)) || \ - defined(ELPP_FORCE_USE_STD_THREAD)) -# define ELPP_USE_STD_THREADING 1 -# else -# define ELPP_USE_STD_THREADING 0 -# endif -#endif -#undef ELPP_FINAL -#if ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702) -# define ELPP_FINAL -#else -# define ELPP_FINAL final -#endif // ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702) -#if defined(ELPP_EXPERIMENTAL_ASYNC) -# define ELPP_ASYNC_LOGGING 1 -#else -# define ELPP_ASYNC_LOGGING 0 -#endif // defined(ELPP_EXPERIMENTAL_ASYNC) -#if defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING -# define ELPP_THREADING_ENABLED 1 -#else -# define ELPP_THREADING_ENABLED 0 -#endif // defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING -// Function macro ELPP_FUNC -#undef ELPP_FUNC -#if ELPP_COMPILER_MSVC // Visual C++ -# define ELPP_FUNC __FUNCSIG__ -#elif ELPP_COMPILER_GCC // GCC -# define ELPP_FUNC __PRETTY_FUNCTION__ -#elif ELPP_COMPILER_INTEL // Intel C++ -# define ELPP_FUNC __PRETTY_FUNCTION__ -#elif ELPP_COMPILER_CLANG // Clang++ -# define ELPP_FUNC __PRETTY_FUNCTION__ -#else -# if defined(__func__) -# define ELPP_FUNC __func__ -# else -# define ELPP_FUNC "" -# endif // defined(__func__) -#endif // defined(_MSC_VER) -#undef ELPP_VARIADIC_TEMPLATES_SUPPORTED -// Keep following line commented until features are fixed -#define ELPP_VARIADIC_TEMPLATES_SUPPORTED \ -(ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800)) -// Logging Enable/Disable macros -#if defined(ELPP_DISABLE_LOGS) -#define ELPP_LOGGING_ENABLED 0 -#else -#define ELPP_LOGGING_ENABLED 1 -#endif -#if (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_DEBUG_LOG 1 -#else -# define ELPP_DEBUG_LOG 0 -#endif // (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_INFO_LOG 1 -#else -# define ELPP_INFO_LOG 0 -#endif // (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_WARNING_LOG 1 -#else -# define ELPP_WARNING_LOG 0 -#endif // (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_ERROR_LOG 1 -#else -# define ELPP_ERROR_LOG 0 -#endif // (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_FATAL_LOG 1 -#else -# define ELPP_FATAL_LOG 0 -#endif // (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_TRACE_LOG 1 -#else -# define ELPP_TRACE_LOG 0 -#endif // (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED)) -# define ELPP_VERBOSE_LOG 1 -#else -# define ELPP_VERBOSE_LOG 0 -#endif // (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED)) -#if (!(ELPP_CXX0X || ELPP_CXX11)) -# error "C++0x (or higher) support not detected! (Is `-std=c++11' missing?)" -#endif // (!(ELPP_CXX0X || ELPP_CXX11)) -// Headers -#if defined(ELPP_SYSLOG) -# include -#endif // defined(ELPP_SYSLOG) -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(ELPP_UNICODE) -# include -# if ELPP_OS_WINDOWS -# include -# endif // ELPP_OS_WINDOWS -#endif // defined(ELPP_UNICODE) -#ifdef HAVE_EXECINFO -# include -# include -#endif // ENABLE_EXECINFO -#if ELPP_OS_ANDROID -# include -#endif // ELPP_OS_ANDROID -#if ELPP_OS_UNIX -# include -# include -#elif ELPP_OS_WINDOWS -# include -# include -# if defined(WIN32_LEAN_AND_MEAN) -# if defined(ELPP_WINSOCK2) -# include -# else -# include -# endif // defined(ELPP_WINSOCK2) -# endif // defined(WIN32_LEAN_AND_MEAN) -#endif // ELPP_OS_UNIX -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if ELPP_THREADING_ENABLED -# if ELPP_USE_STD_THREADING -# include -# include -# else -# if ELPP_OS_UNIX -# include -# endif // ELPP_OS_UNIX -# endif // ELPP_USE_STD_THREADING -#endif // ELPP_THREADING_ENABLED -#if ELPP_ASYNC_LOGGING -# if defined(ELPP_NO_SLEEP_FOR) -# include -# endif // defined(ELPP_NO_SLEEP_FOR) -# include -# include -# include -#endif // ELPP_ASYNC_LOGGING -#if defined(ELPP_STL_LOGGING) -// For logging STL based templates -# include -# include -# include -# include -# include -# include -# if defined(ELPP_LOG_STD_ARRAY) -# include -# endif // defined(ELPP_LOG_STD_ARRAY) -# if defined(ELPP_LOG_UNORDERED_SET) -# include -# endif // defined(ELPP_UNORDERED_SET) -#endif // defined(ELPP_STL_LOGGING) -#if defined(ELPP_QT_LOGGING) -// For logging Qt based classes & templates -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif // defined(ELPP_QT_LOGGING) -#if defined(ELPP_BOOST_LOGGING) -// For logging boost based classes & templates -# include -# include -# include -# include -# include -# include -# include -# include -#endif // defined(ELPP_BOOST_LOGGING) -#if defined(ELPP_WXWIDGETS_LOGGING) -// For logging wxWidgets based classes & templates -# include -#endif // defined(ELPP_WXWIDGETS_LOGGING) -#if defined(ELPP_UTC_DATETIME) -# define elpptime_r gmtime_r -# define elpptime_s gmtime_s -# define elpptime gmtime -#else -# define elpptime_r localtime_r -# define elpptime_s localtime_s -# define elpptime localtime -#endif // defined(ELPP_UTC_DATETIME) -// Forward declarations -namespace el { -class Logger; -class LogMessage; -class PerformanceTrackingData; -class Loggers; -class Helpers; -template class Callback; -class LogDispatchCallback; -class PerformanceTrackingCallback; -class LoggerRegistrationCallback; -class LogDispatchData; -namespace base { -class Storage; -class RegisteredLoggers; -class PerformanceTracker; -class MessageBuilder; -class Writer; -class PErrorWriter; -class LogDispatcher; -class DefaultLogBuilder; -class DefaultLogDispatchCallback; -#if ELPP_ASYNC_LOGGING -class AsyncLogDispatchCallback; -class AsyncDispatchWorker; -#endif // ELPP_ASYNC_LOGGING -class DefaultPerformanceTrackingCallback; -} // namespace base -} // namespace el -/// @brief Easylogging++ entry namespace -namespace el { -/// @brief Namespace containing base/internal functionality used by Easylogging++ -namespace base { -/// @brief Data types used by Easylogging++ -namespace type { -#undef ELPP_LITERAL -#undef ELPP_STRLEN -#undef ELPP_COUT -#if defined(ELPP_UNICODE) -# define ELPP_LITERAL(txt) L##txt -# define ELPP_STRLEN wcslen -# if defined ELPP_CUSTOM_COUT -# define ELPP_COUT ELPP_CUSTOM_COUT -# else -# define ELPP_COUT std::wcout -# endif // defined ELPP_CUSTOM_COUT -typedef wchar_t char_t; -typedef std::wstring string_t; -typedef std::wstringstream stringstream_t; -typedef std::wfstream fstream_t; -typedef std::wostream ostream_t; -#else -# define ELPP_LITERAL(txt) txt -# define ELPP_STRLEN strlen -# if defined ELPP_CUSTOM_COUT -# define ELPP_COUT ELPP_CUSTOM_COUT -# else -# define ELPP_COUT std::cout -# endif // defined ELPP_CUSTOM_COUT -typedef char char_t; -typedef std::string string_t; -typedef std::stringstream stringstream_t; -typedef std::fstream fstream_t; -typedef std::ostream ostream_t; -#endif // defined(ELPP_UNICODE) -#if defined(ELPP_CUSTOM_COUT_LINE) -# define ELPP_COUT_LINE(logLine) ELPP_CUSTOM_COUT_LINE(logLine) -#else -# define ELPP_COUT_LINE(logLine) logLine << std::flush -#endif // defined(ELPP_CUSTOM_COUT_LINE) -typedef unsigned int EnumType; -typedef unsigned short VerboseLevel; -typedef unsigned long int LineNumber; -typedef std::shared_ptr StoragePointer; -typedef std::shared_ptr LogDispatchCallbackPtr; -typedef std::shared_ptr PerformanceTrackingCallbackPtr; -typedef std::shared_ptr LoggerRegistrationCallbackPtr; -typedef std::unique_ptr PerformanceTrackerPtr; -} // namespace type -/// @brief Internal helper class that prevent copy constructor for class -/// -/// @detail When using this class simply inherit it privately -class NoCopy { - protected: - NoCopy(void) {} - private: - NoCopy(const NoCopy&); - NoCopy& operator=(const NoCopy&); -}; -/// @brief Internal helper class that makes all default constructors private. -/// -/// @detail This prevents initializing class making it static unless an explicit constructor is declared. -/// When using this class simply inherit it privately -class StaticClass { - private: - StaticClass(void); - StaticClass(const StaticClass&); - StaticClass& operator=(const StaticClass&); -}; -} // namespace base -/// @brief Represents enumeration for severity level used to determine level of logging -/// -/// @detail With Easylogging++, developers may disable or enable any level regardless of -/// what the severity is. Or they can choose to log using hierarchical logging flag -enum class Level : base::type::EnumType { - /// @brief Generic level that represents all the levels. Useful when setting global configuration for all levels - Global = 1, - /// @brief Information that can be useful to back-trace certain events - mostly useful than debug logs. - Trace = 2, - /// @brief Informational events most useful for developers to debug application - Debug = 4, - /// @brief Severe error information that will presumably abort application - Fatal = 8, - /// @brief Information representing errors in application but application will keep running - Error = 16, - /// @brief Useful when application has potentially harmful situations - Warning = 32, - /// @brief Information that can be highly useful and vary with verbose logging level. - Verbose = 64, - /// @brief Mainly useful to represent current progress of application - Info = 128, - /// @brief Represents unknown level - Unknown = 1010 -}; -} // namespace el -namespace std { -template<> struct hash { - public: - std::size_t operator()(const el::Level& l) const { - return hash {}(static_cast(l)); - } -}; -} -namespace el { -/// @brief Static class that contains helper functions for el::Level -class LevelHelper : base::StaticClass { - public: - /// @brief Represents minimum valid level. Useful when iterating through enum. - static const base::type::EnumType kMinValid = static_cast(Level::Trace); - /// @brief Represents maximum valid level. This is used internally and you should not need it. - static const base::type::EnumType kMaxValid = static_cast(Level::Info); - /// @brief Casts level to int, useful for iterating through enum. - static base::type::EnumType castToInt(Level level) { - return static_cast(level); - } - /// @brief Casts int(ushort) to level, useful for iterating through enum. - static Level castFromInt(base::type::EnumType l) { - return static_cast(l); - } - /// @brief Converts level to associated const char* - /// @return Upper case string based level. - static const char* convertToString(Level level); - /// @brief Converts from levelStr to Level - /// @param levelStr Upper case string based level. - /// Lower case is also valid but providing upper case is recommended. - static Level convertFromString(const char* levelStr); - /// @brief Applies specified function to each level starting from startIndex - /// @param startIndex initial value to start the iteration from. This is passed as pointer and - /// is left-shifted so this can be used inside function (fn) to represent current level. - /// @param fn function to apply with each level. This bool represent whether or not to stop iterating through levels. - static void forEachLevel(base::type::EnumType* startIndex, const std::function& fn); -}; -/// @brief Represents enumeration of ConfigurationType used to configure or access certain aspect -/// of logging -enum class ConfigurationType : base::type::EnumType { - /// @brief Determines whether or not corresponding level and logger of logging is enabled - /// You may disable all logs by using el::Level::Global - Enabled = 1, - /// @brief Whether or not to write corresponding log to log file - ToFile = 2, - /// @brief Whether or not to write corresponding level and logger log to standard output. - /// By standard output meaning termnal, command prompt etc - ToStandardOutput = 4, - /// @brief Determines format of logging corresponding level and logger. - Format = 8, - /// @brief Determines log file (full path) to write logs to for corresponding level and logger - Filename = 16, - /// @brief Specifies precision of the subsecond part. It should be within range (1-6). - SubsecondPrecision = 32, - /// @brief Alias of SubsecondPrecision (for backward compatibility) - MillisecondsWidth = SubsecondPrecision, - /// @brief Determines whether or not performance tracking is enabled. - /// - /// @detail This does not depend on logger or level. Performance tracking always uses 'performance' logger - PerformanceTracking = 64, - /// @brief Specifies log file max size. - /// - /// @detail If file size of corresponding log file (for corresponding level) is >= specified size, log file will - /// be truncated and re-initiated. - MaxLogFileSize = 128, - /// @brief Specifies number of log entries to hold until we flush pending log data - LogFlushThreshold = 256, - /// @brief Represents unknown configuration - Unknown = 1010 -}; -/// @brief Static class that contains helper functions for el::ConfigurationType -class ConfigurationTypeHelper : base::StaticClass { - public: - /// @brief Represents minimum valid configuration type. Useful when iterating through enum. - static const base::type::EnumType kMinValid = static_cast(ConfigurationType::Enabled); - /// @brief Represents maximum valid configuration type. This is used internally and you should not need it. - static const base::type::EnumType kMaxValid = static_cast(ConfigurationType::MaxLogFileSize); - /// @brief Casts configuration type to int, useful for iterating through enum. - static base::type::EnumType castToInt(ConfigurationType configurationType) { - return static_cast(configurationType); - } - /// @brief Casts int(ushort) to configuration type, useful for iterating through enum. - static ConfigurationType castFromInt(base::type::EnumType c) { - return static_cast(c); - } - /// @brief Converts configuration type to associated const char* - /// @returns Upper case string based configuration type. - static const char* convertToString(ConfigurationType configurationType); - /// @brief Converts from configStr to ConfigurationType - /// @param configStr Upper case string based configuration type. - /// Lower case is also valid but providing upper case is recommended. - static ConfigurationType convertFromString(const char* configStr); - /// @brief Applies specified function to each configuration type starting from startIndex - /// @param startIndex initial value to start the iteration from. This is passed by pointer and is left-shifted - /// so this can be used inside function (fn) to represent current configuration type. - /// @param fn function to apply with each configuration type. - /// This bool represent whether or not to stop iterating through configurations. - static inline void forEachConfigType(base::type::EnumType* startIndex, const std::function& fn); -}; -/// @brief Flags used while writing logs. This flags are set by user -enum class LoggingFlag : base::type::EnumType { - /// @brief Makes sure we have new line for each container log entry - NewLineForContainer = 1, - /// @brief Makes sure if -vmodule is used and does not specifies a module, then verbose - /// logging is allowed via that module. - AllowVerboseIfModuleNotSpecified = 2, - /// @brief When handling crashes by default, detailed crash reason will be logged as well - LogDetailedCrashReason = 4, - /// @brief Allows to disable application abortion when logged using FATAL level - DisableApplicationAbortOnFatalLog = 8, - /// @brief Flushes log with every log-entry (performance sensitive) - Disabled by default - ImmediateFlush = 16, - /// @brief Enables strict file rolling - StrictLogFileSizeCheck = 32, - /// @brief Make terminal output colorful for supported terminals - ColoredTerminalOutput = 64, - /// @brief Supports use of multiple logging in same macro, e.g, CLOG(INFO, "default", "network") - MultiLoggerSupport = 128, - /// @brief Disables comparing performance tracker's checkpoints - DisablePerformanceTrackingCheckpointComparison = 256, - /// @brief Disable VModules - DisableVModules = 512, - /// @brief Disable VModules extensions - DisableVModulesExtensions = 1024, - /// @brief Enables hierarchical logging - HierarchicalLogging = 2048, - /// @brief Creates logger automatically when not available - CreateLoggerAutomatically = 4096, - /// @brief Adds spaces b/w logs that separated by left-shift operator - AutoSpacing = 8192, - /// @brief Preserves time format and does not convert it to sec, hour etc (performance tracking only) - FixedTimeFormat = 16384, - // @brief Ignore SIGINT or crash - IgnoreSigInt = 32768, -}; -namespace base { -/// @brief Namespace containing constants used internally. -namespace consts { -static const char kFormatSpecifierCharValue = 'v'; -static const char kFormatSpecifierChar = '%'; -static const unsigned int kMaxLogPerCounter = 100000; -static const unsigned int kMaxLogPerContainer = 100; -static const unsigned int kDefaultSubsecondPrecision = 3; - -#ifdef ELPP_DEFAULT_LOGGER -static const char* kDefaultLoggerId = ELPP_DEFAULT_LOGGER; -#else -static const char* kDefaultLoggerId = "default"; -#endif - -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) -#ifdef ELPP_DEFAULT_PERFORMANCE_LOGGER -static const char* kPerformanceLoggerId = ELPP_DEFAULT_PERFORMANCE_LOGGER; -#else -static const char* kPerformanceLoggerId = "performance"; -#endif // ELPP_DEFAULT_PERFORMANCE_LOGGER -#endif - -#if defined(ELPP_SYSLOG) -static const char* kSysLogLoggerId = "syslog"; -#endif // defined(ELPP_SYSLOG) - -#if ELPP_OS_WINDOWS -static const char* kFilePathSeparator = "\\"; -#else -static const char* kFilePathSeparator = "/"; -#endif // ELPP_OS_WINDOWS - -static const std::size_t kSourceFilenameMaxLength = 100; -static const std::size_t kSourceLineMaxLength = 10; -static const Level kPerformanceTrackerDefaultLevel = Level::Info; -const struct { - double value; - const base::type::char_t* unit; -} kTimeFormats[] = { - { 1000.0f, ELPP_LITERAL("us") }, - { 1000.0f, ELPP_LITERAL("ms") }, - { 60.0f, ELPP_LITERAL("seconds") }, - { 60.0f, ELPP_LITERAL("minutes") }, - { 24.0f, ELPP_LITERAL("hours") }, - { 7.0f, ELPP_LITERAL("days") } -}; -static const int kTimeFormatsCount = sizeof(kTimeFormats) / sizeof(kTimeFormats[0]); -const struct { - int numb; - const char* name; - const char* brief; - const char* detail; -} kCrashSignals[] = { - // NOTE: Do not re-order, if you do please check CrashHandler(bool) constructor and CrashHandler::setHandler(..) - { - SIGABRT, "SIGABRT", "Abnormal termination", - "Program was abnormally terminated." - }, - { - SIGFPE, "SIGFPE", "Erroneous arithmetic operation", - "Arithmetic operation issue such as division by zero or operation resulting in overflow." - }, - { - SIGILL, "SIGILL", "Illegal instruction", - "Generally due to a corruption in the code or to an attempt to execute data." - }, - { - SIGSEGV, "SIGSEGV", "Invalid access to memory", - "Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory." - }, - { - SIGINT, "SIGINT", "Interactive attention signal", - "Interruption generated (generally) by user or operating system." - }, -}; -static const int kCrashSignalsCount = sizeof(kCrashSignals) / sizeof(kCrashSignals[0]); -} // namespace consts -} // namespace base -typedef std::function PreRollOutCallback; -namespace base { -static inline void defaultPreRollOutCallback(const char*, std::size_t) {} -/// @brief Enum to represent timestamp unit -enum class TimestampUnit : base::type::EnumType { - Microsecond = 0, Millisecond = 1, Second = 2, Minute = 3, Hour = 4, Day = 5 -}; -/// @brief Format flags used to determine specifiers that are active for performance improvements. -enum class FormatFlags : base::type::EnumType { - DateTime = 1 << 1, - LoggerId = 1 << 2, - File = 1 << 3, - Line = 1 << 4, - Location = 1 << 5, - Function = 1 << 6, - User = 1 << 7, - Host = 1 << 8, - LogMessage = 1 << 9, - VerboseLevel = 1 << 10, - AppName = 1 << 11, - ThreadId = 1 << 12, - Level = 1 << 13, - FileBase = 1 << 14, - LevelShort = 1 << 15 -}; -/// @brief A subsecond precision class containing actual width and offset of the subsecond part -class SubsecondPrecision { - public: - SubsecondPrecision(void) { - init(base::consts::kDefaultSubsecondPrecision); - } - explicit SubsecondPrecision(int width) { - init(width); - } - bool operator==(const SubsecondPrecision& ssPrec) { - return m_width == ssPrec.m_width && m_offset == ssPrec.m_offset; - } - int m_width; - unsigned int m_offset; - private: - void init(int width); -}; -/// @brief Type alias of SubsecondPrecision -typedef SubsecondPrecision MillisecondsWidth; -/// @brief Namespace containing utility functions/static classes used internally -namespace utils { -/// @brief Deletes memory safely and points to null -template -static -typename std::enable_if::value, void>::type -safeDelete(T*& pointer) { - if (pointer == nullptr) - return; - delete pointer; - pointer = nullptr; -} -/// @brief Bitwise operations for C++11 strong enum class. This casts e into Flag_T and returns value after bitwise operation -/// Use these function as
flag = bitwise::Or(MyEnum::val1, flag);
-namespace bitwise { -template -static inline base::type::EnumType And(Enum e, base::type::EnumType flag) { - return static_cast(flag) & static_cast(e); -} -template -static inline base::type::EnumType Not(Enum e, base::type::EnumType flag) { - return static_cast(flag) & ~(static_cast(e)); -} -template -static inline base::type::EnumType Or(Enum e, base::type::EnumType flag) { - return static_cast(flag) | static_cast(e); -} -} // namespace bitwise -template -static inline void addFlag(Enum e, base::type::EnumType* flag) { - *flag = base::utils::bitwise::Or(e, *flag); -} -template -static inline void removeFlag(Enum e, base::type::EnumType* flag) { - *flag = base::utils::bitwise::Not(e, *flag); -} -template -static inline bool hasFlag(Enum e, base::type::EnumType flag) { - return base::utils::bitwise::And(e, flag) > 0x0; -} -} // namespace utils -namespace threading { -#if ELPP_THREADING_ENABLED -# if !ELPP_USE_STD_THREADING -namespace internal { -/// @brief A mutex wrapper for compiler that dont yet support std::recursive_mutex -class Mutex : base::NoCopy { - public: - Mutex(void) { -# if ELPP_OS_UNIX - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&m_underlyingMutex, &attr); - pthread_mutexattr_destroy(&attr); -# elif ELPP_OS_WINDOWS - InitializeCriticalSection(&m_underlyingMutex); -# endif // ELPP_OS_UNIX - } - - virtual ~Mutex(void) { -# if ELPP_OS_UNIX - pthread_mutex_destroy(&m_underlyingMutex); -# elif ELPP_OS_WINDOWS - DeleteCriticalSection(&m_underlyingMutex); -# endif // ELPP_OS_UNIX - } - - inline void lock(void) { -# if ELPP_OS_UNIX - pthread_mutex_lock(&m_underlyingMutex); -# elif ELPP_OS_WINDOWS - EnterCriticalSection(&m_underlyingMutex); -# endif // ELPP_OS_UNIX - } - - inline bool try_lock(void) { -# if ELPP_OS_UNIX - return (pthread_mutex_trylock(&m_underlyingMutex) == 0); -# elif ELPP_OS_WINDOWS - return TryEnterCriticalSection(&m_underlyingMutex); -# endif // ELPP_OS_UNIX - } - - inline void unlock(void) { -# if ELPP_OS_UNIX - pthread_mutex_unlock(&m_underlyingMutex); -# elif ELPP_OS_WINDOWS - LeaveCriticalSection(&m_underlyingMutex); -# endif // ELPP_OS_UNIX - } - - private: -# if ELPP_OS_UNIX - pthread_mutex_t m_underlyingMutex; -# elif ELPP_OS_WINDOWS - CRITICAL_SECTION m_underlyingMutex; -# endif // ELPP_OS_UNIX -}; -/// @brief Scoped lock for compiler that dont yet support std::lock_guard -template -class ScopedLock : base::NoCopy { - public: - explicit ScopedLock(M& mutex) { - m_mutex = &mutex; - m_mutex->lock(); - } - - virtual ~ScopedLock(void) { - m_mutex->unlock(); - } - private: - M* m_mutex; - ScopedLock(void); -}; -} // namespace internal -typedef base::threading::internal::Mutex Mutex; -typedef base::threading::internal::ScopedLock ScopedLock; -# else -typedef std::recursive_mutex Mutex; -typedef std::lock_guard ScopedLock; -# endif // !ELPP_USE_STD_THREADING -#else -namespace internal { -/// @brief Mutex wrapper used when multi-threading is disabled. -class NoMutex : base::NoCopy { - public: - NoMutex(void) {} - inline void lock(void) {} - inline bool try_lock(void) { - return true; - } - inline void unlock(void) {} -}; -/// @brief Lock guard wrapper used when multi-threading is disabled. -template -class NoScopedLock : base::NoCopy { - public: - explicit NoScopedLock(Mutex&) { - } - virtual ~NoScopedLock(void) { - } - private: - NoScopedLock(void); -}; -} // namespace internal -typedef base::threading::internal::NoMutex Mutex; -typedef base::threading::internal::NoScopedLock ScopedLock; -#endif // ELPP_THREADING_ENABLED -/// @brief Base of thread safe class, this class is inheritable-only -class ThreadSafe { - public: - virtual inline void acquireLock(void) ELPP_FINAL { m_mutex.lock(); } - virtual inline void releaseLock(void) ELPP_FINAL { m_mutex.unlock(); } - virtual inline base::threading::Mutex& lock(void) ELPP_FINAL { return m_mutex; } - protected: - ThreadSafe(void) {} - virtual ~ThreadSafe(void) {} - private: - base::threading::Mutex m_mutex; -}; - -#if ELPP_THREADING_ENABLED -# if !ELPP_USE_STD_THREADING -/// @brief Gets ID of currently running threading in windows systems. On unix, nothing is returned. -static std::string getCurrentThreadId(void) { - std::stringstream ss; -# if (ELPP_OS_WINDOWS) - ss << GetCurrentThreadId(); -# endif // (ELPP_OS_WINDOWS) - return ss.str(); -} -# else -/// @brief Gets ID of currently running threading using std::this_thread::get_id() -static std::string getCurrentThreadId(void) { - std::stringstream ss; - ss << std::this_thread::get_id(); - return ss.str(); -} -# endif // !ELPP_USE_STD_THREADING -#else -static inline std::string getCurrentThreadId(void) { - return std::string(); -} -#endif // ELPP_THREADING_ENABLED -} // namespace threading -namespace utils { -class File : base::StaticClass { - public: - /// @brief Creates new out file stream for specified filename. - /// @return Pointer to newly created fstream or nullptr - static base::type::fstream_t* newFileStream(const std::string& filename); - - /// @brief Gets size of file provided in stream - static std::size_t getSizeOfFile(base::type::fstream_t* fs); - - /// @brief Determines whether or not provided path exist in current file system - static bool pathExists(const char* path, bool considerFile = false); - - /// @brief Creates specified path on file system - /// @param path Path to create. - static bool createPath(const std::string& path); - /// @brief Extracts path of filename with leading slash - static std::string extractPathFromFilename(const std::string& fullPath, - const char* separator = base::consts::kFilePathSeparator); - /// @brief builds stripped filename and puts it in buff - static void buildStrippedFilename(const char* filename, char buff[], - std::size_t limit = base::consts::kSourceFilenameMaxLength); - /// @brief builds base filename and puts it in buff - static void buildBaseFilename(const std::string& fullPath, char buff[], - std::size_t limit = base::consts::kSourceFilenameMaxLength, - const char* separator = base::consts::kFilePathSeparator); -}; -/// @brief String utilities helper class used internally. You should not use it. -class Str : base::StaticClass { - public: - /// @brief Checks if character is digit. Dont use libc implementation of it to prevent locale issues. - static inline bool isDigit(char c) { - return c >= '0' && c <= '9'; - } - - /// @brief Matches wildcards, '*' and '?' only supported. - static bool wildCardMatch(const char* str, const char* pattern); - - static std::string& ltrim(std::string& str); - static std::string& rtrim(std::string& str); - static std::string& trim(std::string& str); - - /// @brief Determines whether or not str starts with specified string - /// @param str String to check - /// @param start String to check against - /// @return Returns true if starts with specified string, false otherwise - static bool startsWith(const std::string& str, const std::string& start); - - /// @brief Determines whether or not str ends with specified string - /// @param str String to check - /// @param end String to check against - /// @return Returns true if ends with specified string, false otherwise - static bool endsWith(const std::string& str, const std::string& end); - - /// @brief Replaces all instances of replaceWhat with 'replaceWith'. Original variable is changed for performance. - /// @param [in,out] str String to replace from - /// @param replaceWhat Character to replace - /// @param replaceWith Character to replace with - /// @return Modified version of str - static std::string& replaceAll(std::string& str, char replaceWhat, char replaceWith); - - /// @brief Replaces all instances of 'replaceWhat' with 'replaceWith'. (String version) Replaces in place - /// @param str String to replace from - /// @param replaceWhat Character to replace - /// @param replaceWith Character to replace with - /// @return Modified (original) str - static std::string& replaceAll(std::string& str, const std::string& replaceWhat, - const std::string& replaceWith); - - static void replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat, - const base::type::string_t& replaceWith); -#if defined(ELPP_UNICODE) - static void replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat, - const std::string& replaceWith); -#endif // defined(ELPP_UNICODE) - /// @brief Converts string to uppercase - /// @param str String to convert - /// @return Uppercase string - static std::string& toUpper(std::string& str); - - /// @brief Compares cstring equality - uses strcmp - static bool cStringEq(const char* s1, const char* s2); - - /// @brief Compares cstring equality (case-insensitive) - uses toupper(char) - /// Dont use strcasecmp because of CRT (VC++) - static bool cStringCaseEq(const char* s1, const char* s2); - - /// @brief Returns true if c exist in str - static bool contains(const char* str, char c); - - static char* convertAndAddToBuff(std::size_t n, int len, char* buf, const char* bufLim, bool zeroPadded = true); - static char* addToBuff(const char* str, char* buf, const char* bufLim); - static char* clearBuff(char buff[], std::size_t lim); - - /// @brief Converts wchar* to char* - /// NOTE: Need to free return value after use! - static char* wcharPtrToCharPtr(const wchar_t* line); -}; -/// @brief Operating System helper static class used internally. You should not use it. -class OS : base::StaticClass { - public: -#if ELPP_OS_WINDOWS - /// @brief Gets environment variables for Windows based OS. - /// We are not using getenv(const char*) because of CRT deprecation - /// @param varname Variable name to get environment variable value for - /// @return If variable exist the value of it otherwise nullptr - static const char* getWindowsEnvironmentVariable(const char* varname); -#endif // ELPP_OS_WINDOWS -#if ELPP_OS_ANDROID - /// @brief Reads android property value - static std::string getProperty(const char* prop); - - /// @brief Reads android device name - static std::string getDeviceName(void); -#endif // ELPP_OS_ANDROID - - /// @brief Runs command on terminal and returns the output. - /// - /// @detail This is applicable only on unix based systems, for all other OS, an empty string is returned. - /// @param command Bash command - /// @return Result of bash output or empty string if no result found. - static const std::string getBashOutput(const char* command); - - /// @brief Gets environment variable. This is cross-platform and CRT safe (for VC++) - /// @param variableName Environment variable name - /// @param defaultVal If no environment variable or value found the value to return by default - /// @param alternativeBashCommand If environment variable not found what would be alternative bash command - /// in order to look for value user is looking for. E.g, for 'user' alternative command will 'whoami' - static std::string getEnvironmentVariable(const char* variableName, const char* defaultVal, - const char* alternativeBashCommand = nullptr); - /// @brief Gets current username. - static std::string currentUser(void); - - /// @brief Gets current host name or computer name. - /// - /// @detail For android systems this is device name with its manufacturer and model separated by hyphen - static std::string currentHost(void); - /// @brief Whether or not terminal supports colors - static bool termSupportsColor(void); -}; -/// @brief Contains utilities for cross-platform date/time. This class make use of el::base::utils::Str -class DateTime : base::StaticClass { - public: - /// @brief Cross platform gettimeofday for Windows and unix platform. This can be used to determine current microsecond. - /// - /// @detail For unix system it uses gettimeofday(timeval*, timezone*) and for Windows, a separate implementation is provided - /// @param [in,out] tv Pointer that gets updated - static void gettimeofday(struct timeval* tv); - - /// @brief Gets current date and time with a subsecond part. - /// @param format User provided date/time format - /// @param ssPrec A pointer to base::SubsecondPrecision from configuration (non-null) - /// @returns string based date time in specified format. - static std::string getDateTime(const char* format, const base::SubsecondPrecision* ssPrec); - - /// @brief Converts timeval (struct from ctime) to string using specified format and subsecond precision - static std::string timevalToString(struct timeval tval, const char* format, - const el::base::SubsecondPrecision* ssPrec); - - /// @brief Formats time to get unit accordingly, units like second if > 1000 or minutes if > 60000 etc - static base::type::string_t formatTime(unsigned long long time, base::TimestampUnit timestampUnit); - - /// @brief Gets time difference in milli/micro second depending on timestampUnit - static unsigned long long getTimeDifference(const struct timeval& endTime, const struct timeval& startTime, - base::TimestampUnit timestampUnit); - - - static struct ::tm* buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo); - private: - static char* parseFormat(char* buf, std::size_t bufSz, const char* format, const struct tm* tInfo, - std::size_t msec, const base::SubsecondPrecision* ssPrec); -}; -/// @brief Command line arguments for application if specified using el::Helpers::setArgs(..) or START_EASYLOGGINGPP(..) -class CommandLineArgs { - public: - CommandLineArgs(void) { - setArgs(0, static_cast(nullptr)); - } - CommandLineArgs(int argc, const char** argv) { - setArgs(argc, argv); - } - CommandLineArgs(int argc, char** argv) { - setArgs(argc, argv); - } - virtual ~CommandLineArgs(void) {} - /// @brief Sets arguments and parses them - inline void setArgs(int argc, const char** argv) { - setArgs(argc, const_cast(argv)); - } - /// @brief Sets arguments and parses them - void setArgs(int argc, char** argv); - /// @brief Returns true if arguments contain paramKey with a value (separated by '=') - bool hasParamWithValue(const char* paramKey) const; - /// @brief Returns value of arguments - /// @see hasParamWithValue(const char*) - const char* getParamValue(const char* paramKey) const; - /// @brief Return true if arguments has a param (not having a value) i,e without '=' - bool hasParam(const char* paramKey) const; - /// @brief Returns true if no params available. This exclude argv[0] - bool empty(void) const; - /// @brief Returns total number of arguments. This exclude argv[0] - std::size_t size(void) const; - friend base::type::ostream_t& operator<<(base::type::ostream_t& os, const CommandLineArgs& c); - - private: - int m_argc; - char** m_argv; - std::unordered_map m_paramsWithValue; - std::vector m_params; -}; -/// @brief Abstract registry (aka repository) that provides basic interface for pointer repository specified by T_Ptr type. -/// -/// @detail Most of the functions are virtual final methods but anything implementing this abstract class should implement -/// unregisterAll() and deepCopy(const AbstractRegistry&) and write registerNew() method according to container -/// and few more methods; get() to find element, unregister() to unregister single entry. -/// Please note that this is thread-unsafe and should also implement thread-safety mechanisms in implementation. -template -class AbstractRegistry : public base::threading::ThreadSafe { - public: - typedef typename Container::iterator iterator; - typedef typename Container::const_iterator const_iterator; - - /// @brief Default constructor - AbstractRegistry(void) {} - - /// @brief Move constructor that is useful for base classes - AbstractRegistry(AbstractRegistry&& sr) { - if (this == &sr) { - return; - } - unregisterAll(); - m_list = std::move(sr.m_list); - } - - bool operator==(const AbstractRegistry& other) { - if (size() != other.size()) { - return false; - } - for (std::size_t i = 0; i < m_list.size(); ++i) { - if (m_list.at(i) != other.m_list.at(i)) { - return false; - } - } - return true; - } - - bool operator!=(const AbstractRegistry& other) { - if (size() != other.size()) { - return true; - } - for (std::size_t i = 0; i < m_list.size(); ++i) { - if (m_list.at(i) != other.m_list.at(i)) { - return true; - } - } - return false; - } - - /// @brief Assignment move operator - AbstractRegistry& operator=(AbstractRegistry&& sr) { - if (this == &sr) { - return *this; - } - unregisterAll(); - m_list = std::move(sr.m_list); - return *this; - } - - virtual ~AbstractRegistry(void) { - } - - /// @return Iterator pointer from start of repository - virtual inline iterator begin(void) ELPP_FINAL { - return m_list.begin(); - } - - /// @return Iterator pointer from end of repository - virtual inline iterator end(void) ELPP_FINAL { - return m_list.end(); - } - - - /// @return Constant iterator pointer from start of repository - virtual inline const_iterator cbegin(void) const ELPP_FINAL { - return m_list.cbegin(); - } - - /// @return End of repository - virtual inline const_iterator cend(void) const ELPP_FINAL { - return m_list.cend(); - } - - /// @return Whether or not repository is empty - virtual inline bool empty(void) const ELPP_FINAL { - return m_list.empty(); - } - - /// @return Size of repository - virtual inline std::size_t size(void) const ELPP_FINAL { - return m_list.size(); - } - - /// @brief Returns underlying container by reference - virtual inline Container& list(void) ELPP_FINAL { - return m_list; - } - - /// @brief Returns underlying container by constant reference. - virtual inline const Container& list(void) const ELPP_FINAL { - return m_list; - } - - /// @brief Unregisters all the pointers from current repository. - virtual void unregisterAll(void) = 0; - - protected: - virtual void deepCopy(const AbstractRegistry&) = 0; - void reinitDeepCopy(const AbstractRegistry& sr) { - unregisterAll(); - deepCopy(sr); - } - - private: - Container m_list; -}; - -/// @brief A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate version) -/// -/// @detail NOTE: This is thread-unsafe implementation (although it contains lock function, it does not use these functions) -/// of AbstractRegistry. Any implementation of this class should be -/// explicitly (by using lock functions) -template -class Registry : public AbstractRegistry> { - public: - typedef typename Registry::iterator iterator; - typedef typename Registry::const_iterator const_iterator; - - Registry(void) {} - - /// @brief Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor. - Registry(const Registry& sr) : AbstractRegistry>() { - if (this == &sr) { - return; - } - this->reinitDeepCopy(sr); - } - - /// @brief Assignment operator that unregisters all the existing registries and deeply copies each of repo element - /// @see unregisterAll() - /// @see deepCopy(const AbstractRegistry&) - Registry& operator=(const Registry& sr) { - if (this == &sr) { - return *this; - } - this->reinitDeepCopy(sr); - return *this; - } - - virtual ~Registry(void) { - unregisterAll(); - } - - protected: - virtual void unregisterAll(void) ELPP_FINAL { - if (!this->empty()) { - for (auto&& curr : this->list()) { - base::utils::safeDelete(curr.second); - } - this->list().clear(); - } - } - -/// @brief Registers new registry to repository. - virtual void registerNew(const T_Key& uniqKey, T_Ptr* ptr) ELPP_FINAL { - unregister(uniqKey); - this->list().insert(std::make_pair(uniqKey, ptr)); - } - -/// @brief Unregisters single entry mapped to specified unique key - void unregister(const T_Key& uniqKey) { - T_Ptr* existing = get(uniqKey); - if (existing != nullptr) { - this->list().erase(uniqKey); - base::utils::safeDelete(existing); - } - } - -/// @brief Gets pointer from repository. If none found, nullptr is returned. - T_Ptr* get(const T_Key& uniqKey) { - iterator it = this->list().find(uniqKey); - return it == this->list().end() - ? nullptr - : it->second; - } - - private: - virtual void deepCopy(const AbstractRegistry>& sr) ELPP_FINAL { - for (const_iterator it = sr.cbegin(); it != sr.cend(); ++it) { - registerNew(it->first, new T_Ptr(*it->second)); - } - } -}; - -/// @brief A pointer registry mechanism to manage memory and provide search functionalities. (predicate version) -/// -/// @detail NOTE: This is thread-unsafe implementation of AbstractRegistry. Any implementation of this class -/// should be made thread-safe explicitly -template -class RegistryWithPred : public AbstractRegistry> { - public: - typedef typename RegistryWithPred::iterator iterator; - typedef typename RegistryWithPred::const_iterator const_iterator; - - RegistryWithPred(void) { - } - - virtual ~RegistryWithPred(void) { - unregisterAll(); - } - - /// @brief Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor. - RegistryWithPred(const RegistryWithPred& sr) : AbstractRegistry>() { - if (this == &sr) { - return; - } - this->reinitDeepCopy(sr); - } - - /// @brief Assignment operator that unregisters all the existing registries and deeply copies each of repo element - /// @see unregisterAll() - /// @see deepCopy(const AbstractRegistry&) - RegistryWithPred& operator=(const RegistryWithPred& sr) { - if (this == &sr) { - return *this; - } - this->reinitDeepCopy(sr); - return *this; - } - - friend base::type::ostream_t& operator<<(base::type::ostream_t& os, const RegistryWithPred& sr) { - for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) { - os << ELPP_LITERAL(" ") << **it << ELPP_LITERAL("\n"); - } - return os; - } - - protected: - virtual void unregisterAll(void) ELPP_FINAL { - if (!this->empty()) { - for (auto&& curr : this->list()) { - base::utils::safeDelete(curr); - } - this->list().clear(); - } - } - - virtual void unregister(T_Ptr*& ptr) ELPP_FINAL { - if (ptr) { - iterator iter = this->begin(); - for (; iter != this->end(); ++iter) { - if (ptr == *iter) { - break; - } - } - if (iter != this->end() && *iter != nullptr) { - this->list().erase(iter); - base::utils::safeDelete(*iter); - } - } - } - - virtual inline void registerNew(T_Ptr* ptr) ELPP_FINAL { - this->list().push_back(ptr); - } - -/// @brief Gets pointer from repository with specified arguments. Arguments are passed to predicate -/// in order to validate pointer. - template - T_Ptr* get(const T& arg1, const T2 arg2) { - iterator iter = std::find_if(this->list().begin(), this->list().end(), Pred(arg1, arg2)); - if (iter != this->list().end() && *iter != nullptr) { - return *iter; - } - return nullptr; - } - - private: - virtual void deepCopy(const AbstractRegistry>& sr) { - for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) { - registerNew(new T_Ptr(**it)); - } - } -}; -class Utils { - public: - template - static bool installCallback(const std::string& id, std::unordered_map* mapT) { - if (mapT->find(id) == mapT->end()) { - mapT->insert(std::make_pair(id, TPtr(new T()))); - return true; - } - return false; - } - - template - static void uninstallCallback(const std::string& id, std::unordered_map* mapT) { - if (mapT->find(id) != mapT->end()) { - mapT->erase(id); - } - } - - template - static T* callback(const std::string& id, std::unordered_map* mapT) { - typename std::unordered_map::iterator iter = mapT->find(id); - if (iter != mapT->end()) { - return static_cast(iter->second.get()); - } - return nullptr; - } -}; -} // namespace utils -} // namespace base -/// @brief Base of Easylogging++ friendly class -/// -/// @detail After inheriting this class publicly, implement pure-virtual function `void log(std::ostream&) const` -class Loggable { - public: - virtual ~Loggable(void) {} - virtual void log(el::base::type::ostream_t&) const = 0; - private: - friend inline el::base::type::ostream_t& operator<<(el::base::type::ostream_t& os, const Loggable& loggable) { - loggable.log(os); - return os; - } -}; -namespace base { -/// @brief Represents log format containing flags and date format. This is used internally to start initial log -class LogFormat : public Loggable { - public: - LogFormat(void); - LogFormat(Level level, const base::type::string_t& format); - LogFormat(const LogFormat& logFormat); - LogFormat(LogFormat&& logFormat); - LogFormat& operator=(const LogFormat& logFormat); - virtual ~LogFormat(void) {} - bool operator==(const LogFormat& other); - - /// @brief Updates format to be used while logging. - /// @param userFormat User provided format - void parseFromFormat(const base::type::string_t& userFormat); - - inline Level level(void) const { - return m_level; - } - - inline const base::type::string_t& userFormat(void) const { - return m_userFormat; - } - - inline const base::type::string_t& format(void) const { - return m_format; - } - - inline const std::string& dateTimeFormat(void) const { - return m_dateTimeFormat; - } - - inline base::type::EnumType flags(void) const { - return m_flags; - } - - inline bool hasFlag(base::FormatFlags flag) const { - return base::utils::hasFlag(flag, m_flags); - } - - virtual void log(el::base::type::ostream_t& os) const { - os << m_format; - } - - protected: - /// @brief Updates date time format if available in currFormat. - /// @param index Index where %datetime, %date or %time was found - /// @param [in,out] currFormat current format that is being used to format - virtual void updateDateFormat(std::size_t index, base::type::string_t& currFormat) ELPP_FINAL; - - /// @brief Updates %level from format. This is so that we dont have to do it at log-writing-time. It uses m_format and m_level - virtual void updateFormatSpec(void) ELPP_FINAL; - - inline void addFlag(base::FormatFlags flag) { - base::utils::addFlag(flag, &m_flags); - } - - private: - Level m_level; - base::type::string_t m_userFormat; - base::type::string_t m_format; - std::string m_dateTimeFormat; - base::type::EnumType m_flags; - std::string m_currentUser; - std::string m_currentHost; - friend class el::Logger; // To resolve loggerId format specifier easily -}; -} // namespace base -/// @brief Resolving function for format specifier -typedef std::function FormatSpecifierValueResolver; -/// @brief User-provided custom format specifier -/// @see el::Helpers::installCustomFormatSpecifier -/// @see FormatSpecifierValueResolver -class CustomFormatSpecifier { - public: - CustomFormatSpecifier(const char* formatSpecifier, const FormatSpecifierValueResolver& resolver) : - m_formatSpecifier(formatSpecifier), m_resolver(resolver) {} - inline const char* formatSpecifier(void) const { - return m_formatSpecifier; - } - inline const FormatSpecifierValueResolver& resolver(void) const { - return m_resolver; - } - inline bool operator==(const char* formatSpecifier) { - return strcmp(m_formatSpecifier, formatSpecifier) == 0; - } - - private: - const char* m_formatSpecifier; - FormatSpecifierValueResolver m_resolver; -}; -/// @brief Represents single configuration that has representing level, configuration type and a string based value. -/// -/// @detail String based value means any value either its boolean, integer or string itself, it will be embedded inside quotes -/// and will be parsed later. -/// -/// Consider some examples below: -/// * el::Configuration confEnabledInfo(el::Level::Info, el::ConfigurationType::Enabled, "true"); -/// * el::Configuration confMaxLogFileSizeInfo(el::Level::Info, el::ConfigurationType::MaxLogFileSize, "2048"); -/// * el::Configuration confFilenameInfo(el::Level::Info, el::ConfigurationType::Filename, "/var/log/my.log"); -class Configuration : public Loggable { - public: - Configuration(const Configuration& c); - Configuration& operator=(const Configuration& c); - - virtual ~Configuration(void) { - } - - /// @brief Full constructor used to sets value of configuration - Configuration(Level level, ConfigurationType configurationType, const std::string& value); - - /// @brief Gets level of current configuration - inline Level level(void) const { - return m_level; - } - - /// @brief Gets configuration type of current configuration - inline ConfigurationType configurationType(void) const { - return m_configurationType; - } - - /// @brief Gets string based configuration value - inline const std::string& value(void) const { - return m_value; - } - - /// @brief Set string based configuration value - /// @param value Value to set. Values have to be std::string; For boolean values use "true", "false", for any integral values - /// use them in quotes. They will be parsed when configuring - inline void setValue(const std::string& value) { - m_value = value; - } - - virtual void log(el::base::type::ostream_t& os) const; - - /// @brief Used to find configuration from configuration (pointers) repository. Avoid using it. - class Predicate { - public: - Predicate(Level level, ConfigurationType configurationType); - - bool operator()(const Configuration* conf) const; - - private: - Level m_level; - ConfigurationType m_configurationType; - }; - - private: - Level m_level; - ConfigurationType m_configurationType; - std::string m_value; -}; - -/// @brief Thread-safe Configuration repository -/// -/// @detail This repository represents configurations for all the levels and configuration type mapped to a value. -class Configurations : public base::utils::RegistryWithPred { - public: - /// @brief Default constructor with empty repository - Configurations(void); - - /// @brief Constructor used to set configurations using configuration file. - /// @param configurationFile Full path to configuration file - /// @param useDefaultsForRemaining Lets you set the remaining configurations to default. - /// @param base If provided, this configuration will be based off existing repository that this argument is pointing to. - /// @see parseFromFile(const std::string&, Configurations* base) - /// @see setRemainingToDefault() - Configurations(const std::string& configurationFile, bool useDefaultsForRemaining = true, - Configurations* base = nullptr); - - virtual ~Configurations(void) { - } - - /// @brief Parses configuration from file. - /// @param configurationFile Full path to configuration file - /// @param base Configurations to base new configuration repository off. This value is used when you want to use - /// existing Configurations to base all the values and then set rest of configuration via configuration file. - /// @return True if successfully parsed, false otherwise. You may define 'ELPP_DEBUG_ASSERT_FAILURE' to make sure you - /// do not proceed without successful parse. - bool parseFromFile(const std::string& configurationFile, Configurations* base = nullptr); - - /// @brief Parse configurations from configuration string. - /// - /// @detail This configuration string has same syntax as configuration file contents. Make sure all the necessary - /// new line characters are provided. - /// @param base Configurations to base new configuration repository off. This value is used when you want to use - /// existing Configurations to base all the values and then set rest of configuration via configuration text. - /// @return True if successfully parsed, false otherwise. You may define 'ELPP_DEBUG_ASSERT_FAILURE' to make sure you - /// do not proceed without successful parse. - bool parseFromText(const std::string& configurationsString, Configurations* base = nullptr); - - /// @brief Sets configuration based-off an existing configurations. - /// @param base Pointer to existing configurations. - void setFromBase(Configurations* base); - - /// @brief Determines whether or not specified configuration type exists in the repository. - /// - /// @detail Returns as soon as first level is found. - /// @param configurationType Type of configuration to check existence for. - bool hasConfiguration(ConfigurationType configurationType); - - /// @brief Determines whether or not specified configuration type exists for specified level - /// @param level Level to check - /// @param configurationType Type of configuration to check existence for. - bool hasConfiguration(Level level, ConfigurationType configurationType); - - /// @brief Sets value of configuration for specified level. - /// - /// @detail Any existing configuration for specified level will be replaced. Also note that configuration types - /// ConfigurationType::SubsecondPrecision and ConfigurationType::PerformanceTracking will be ignored if not set for - /// Level::Global because these configurations are not dependant on level. - /// @param level Level to set configuration for (el::Level). - /// @param configurationType Type of configuration (el::ConfigurationType) - /// @param value A string based value. Regardless of what the data type of configuration is, it will always be string - /// from users' point of view. This is then parsed later to be used internally. - /// @see Configuration::setValue(const std::string& value) - /// @see el::Level - /// @see el::ConfigurationType - void set(Level level, ConfigurationType configurationType, const std::string& value); - - /// @brief Sets single configuration based on other single configuration. - /// @see set(Level level, ConfigurationType configurationType, const std::string& value) - void set(Configuration* conf); - - inline Configuration* get(Level level, ConfigurationType configurationType) { - base::threading::ScopedLock scopedLock(lock()); - return RegistryWithPred::get(level, configurationType); - } - - /// @brief Sets configuration for all levels. - /// @param configurationType Type of configuration - /// @param value String based value - /// @see Configurations::set(Level level, ConfigurationType configurationType, const std::string& value) - inline void setGlobally(ConfigurationType configurationType, const std::string& value) { - setGlobally(configurationType, value, false); - } - - /// @brief Clears repository so that all the configurations are unset - inline void clear(void) { - base::threading::ScopedLock scopedLock(lock()); - unregisterAll(); - } - - /// @brief Gets configuration file used in parsing this configurations. - /// - /// @detail If this repository was set manually or by text this returns empty string. - inline const std::string& configurationFile(void) const { - return m_configurationFile; - } - - /// @brief Sets configurations to "factory based" configurations. - void setToDefault(void); - - /// @brief Lets you set the remaining configurations to default. - /// - /// @detail By remaining, it means that the level/type a configuration does not exist for. - /// This function is useful when you want to minimize chances of failures, e.g, if you have a configuration file that sets - /// configuration for all the configurations except for Enabled or not, we use this so that ENABLED is set to default i.e, - /// true. If you dont do this explicitly (either by calling this function or by using second param in Constructor - /// and try to access a value, an error is thrown - void setRemainingToDefault(void); - - /// @brief Parser used internally to parse configurations from file or text. - /// - /// @detail This class makes use of base::utils::Str. - /// You should not need this unless you are working on some tool for Easylogging++ - class Parser : base::StaticClass { - public: - /// @brief Parses configuration from file. - /// @param configurationFile Full path to configuration file - /// @param sender Sender configurations pointer. Usually 'this' is used from calling class - /// @param base Configurations to base new configuration repository off. This value is used when you want to use - /// existing Configurations to base all the values and then set rest of configuration via configuration file. - /// @return True if successfully parsed, false otherwise. You may define '_STOP_ON_FIRSTELPP_ASSERTION' to make sure you - /// do not proceed without successful parse. - static bool parseFromFile(const std::string& configurationFile, Configurations* sender, - Configurations* base = nullptr); - - /// @brief Parse configurations from configuration string. - /// - /// @detail This configuration string has same syntax as configuration file contents. Make sure all the necessary - /// new line characters are provided. You may define '_STOP_ON_FIRSTELPP_ASSERTION' to make sure you - /// do not proceed without successful parse (This is recommended) - /// @param configurationsString the configuration in plain text format - /// @param sender Sender configurations pointer. Usually 'this' is used from calling class - /// @param base Configurations to base new configuration repository off. This value is used when you want to use - /// existing Configurations to base all the values and then set rest of configuration via configuration text. - /// @return True if successfully parsed, false otherwise. - static bool parseFromText(const std::string& configurationsString, Configurations* sender, - Configurations* base = nullptr); - - private: - friend class el::Loggers; - static void ignoreComments(std::string* line); - static bool isLevel(const std::string& line); - static bool isComment(const std::string& line); - static inline bool isConfig(const std::string& line); - static bool parseLine(std::string* line, std::string* currConfigStr, std::string* currLevelStr, Level* currLevel, - Configurations* conf); - }; - - private: - std::string m_configurationFile; - bool m_isFromFile; - friend class el::Loggers; - - /// @brief Unsafely sets configuration if does not already exist - void unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string& value); - - /// @brief Thread unsafe set - void unsafeSet(Level level, ConfigurationType configurationType, const std::string& value); - - /// @brief Sets configurations for all levels including Level::Global if includeGlobalLevel is true - /// @see Configurations::setGlobally(ConfigurationType configurationType, const std::string& value) - void setGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel); - - /// @brief Sets configurations (Unsafely) for all levels including Level::Global if includeGlobalLevel is true - /// @see Configurations::setGlobally(ConfigurationType configurationType, const std::string& value) - void unsafeSetGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel); -}; - -namespace base { -typedef std::shared_ptr FileStreamPtr; -typedef std::unordered_map LogStreamsReferenceMap; -typedef std::shared_ptr LogStreamsReferenceMapPtr; -/// @brief Configurations with data types. -/// -/// @detail el::Configurations have string based values. This is whats used internally in order to read correct configurations. -/// This is to perform faster while writing logs using correct configurations. -/// -/// This is thread safe and final class containing non-virtual destructor (means nothing should inherit this class) -class TypedConfigurations : public base::threading::ThreadSafe { - public: - /// @brief Constructor to initialize (construct) the object off el::Configurations - /// @param configurations Configurations pointer/reference to base this typed configurations off. - /// @param logStreamsReference Use ELPP->registeredLoggers()->logStreamsReference() - TypedConfigurations(Configurations* configurations, LogStreamsReferenceMapPtr logStreamsReference); - - TypedConfigurations(const TypedConfigurations& other); - - virtual ~TypedConfigurations(void) { - } - - const Configurations* configurations(void) const { - return m_configurations; - } - - bool enabled(Level level); - bool toFile(Level level); - const std::string& filename(Level level); - bool toStandardOutput(Level level); - const base::LogFormat& logFormat(Level level); - const base::SubsecondPrecision& subsecondPrecision(Level level = Level::Global); - const base::MillisecondsWidth& millisecondsWidth(Level level = Level::Global); - bool performanceTracking(Level level = Level::Global); - base::type::fstream_t* fileStream(Level level); - std::size_t maxLogFileSize(Level level); - std::size_t logFlushThreshold(Level level); - - private: - Configurations* m_configurations; - std::unordered_map m_enabledMap; - std::unordered_map m_toFileMap; - std::unordered_map m_filenameMap; - std::unordered_map m_toStandardOutputMap; - std::unordered_map m_logFormatMap; - std::unordered_map m_subsecondPrecisionMap; - std::unordered_map m_performanceTrackingMap; - std::unordered_map m_fileStreamMap; - std::unordered_map m_maxLogFileSizeMap; - std::unordered_map m_logFlushThresholdMap; - LogStreamsReferenceMapPtr m_logStreamsReference = nullptr; - - friend class el::Helpers; - friend class el::base::MessageBuilder; - friend class el::base::Writer; - friend class el::base::DefaultLogDispatchCallback; - friend class el::base::LogDispatcher; - - template - inline Conf_T getConfigByVal(Level level, const std::unordered_map* confMap, const char* confName) { - base::threading::ScopedLock scopedLock(lock()); - return unsafeGetConfigByVal(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope - } - - template - inline Conf_T& getConfigByRef(Level level, std::unordered_map* confMap, const char* confName) { - base::threading::ScopedLock scopedLock(lock()); - return unsafeGetConfigByRef(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope - } - - template - Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map* confMap, const char* confName) { - ELPP_UNUSED(confName); - typename std::unordered_map::const_iterator it = confMap->find(level); - if (it == confMap->end()) { - try { - return confMap->at(Level::Global); - } catch (...) { - ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level [" - << LevelHelper::convertToString(level) << "]" - << std::endl << "Please ensure you have properly configured logger.", false); - return Conf_T(); - } - } - return it->second; - } - - template - Conf_T& unsafeGetConfigByRef(Level level, std::unordered_map* confMap, const char* confName) { - ELPP_UNUSED(confName); - typename std::unordered_map::iterator it = confMap->find(level); - if (it == confMap->end()) { - try { - return confMap->at(Level::Global); - } catch (...) { - ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level [" - << LevelHelper::convertToString(level) << "]" - << std::endl << "Please ensure you have properly configured logger.", false); - } - } - return it->second; - } - - template - void setValue(Level level, const Conf_T& value, std::unordered_map* confMap, - bool includeGlobalLevel = true) { - // If map is empty and we are allowed to add into generic level (Level::Global), do it! - if (confMap->empty() && includeGlobalLevel) { - confMap->insert(std::make_pair(Level::Global, value)); - return; - } - // If same value exist in generic level already, dont add it to explicit level - typename std::unordered_map::iterator it = confMap->find(Level::Global); - if (it != confMap->end() && it->second == value) { - return; - } - // Now make sure we dont double up values if we really need to add it to explicit level - it = confMap->find(level); - if (it == confMap->end()) { - // Value not found for level, add new - confMap->insert(std::make_pair(level, value)); - } else { - // Value found, just update value - confMap->at(level) = value; - } - } - - void build(Configurations* configurations); - unsigned long getULong(std::string confVal); - std::string resolveFilename(const std::string& filename); - void insertFile(Level level, const std::string& fullFilename); - bool unsafeValidateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback); - - inline bool validateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback) { - base::threading::ScopedLock scopedLock(lock()); - return unsafeValidateFileRolling(level, preRollOutCallback); - } -}; -/// @brief Class that keeps record of current line hit for occasional logging -class HitCounter { - public: - HitCounter(void) : - m_filename(""), - m_lineNumber(0), - m_hitCounts(0) { - } - - HitCounter(const char* filename, base::type::LineNumber lineNumber) : - m_filename(filename), - m_lineNumber(lineNumber), - m_hitCounts(0) { - } - - HitCounter(const HitCounter& hitCounter) : - m_filename(hitCounter.m_filename), - m_lineNumber(hitCounter.m_lineNumber), - m_hitCounts(hitCounter.m_hitCounts) { - } - - HitCounter& operator=(const HitCounter& hitCounter) { - if (&hitCounter != this) { - m_filename = hitCounter.m_filename; - m_lineNumber = hitCounter.m_lineNumber; - m_hitCounts = hitCounter.m_hitCounts; - } - return *this; - } - - virtual ~HitCounter(void) { - } - - /// @brief Resets location of current hit counter - inline void resetLocation(const char* filename, base::type::LineNumber lineNumber) { - m_filename = filename; - m_lineNumber = lineNumber; - } - - /// @brief Validates hit counts and resets it if necessary - inline void validateHitCounts(std::size_t n) { - if (m_hitCounts >= base::consts::kMaxLogPerCounter) { - m_hitCounts = (n >= 1 ? base::consts::kMaxLogPerCounter % n : 0); - } - ++m_hitCounts; - } - - inline const char* filename(void) const { - return m_filename; - } - - inline base::type::LineNumber lineNumber(void) const { - return m_lineNumber; - } - - inline std::size_t hitCounts(void) const { - return m_hitCounts; - } - - inline void increment(void) { - ++m_hitCounts; - } - - class Predicate { - public: - Predicate(const char* filename, base::type::LineNumber lineNumber) - : m_filename(filename), - m_lineNumber(lineNumber) { - } - inline bool operator()(const HitCounter* counter) { - return ((counter != nullptr) && - (strcmp(counter->m_filename, m_filename) == 0) && - (counter->m_lineNumber == m_lineNumber)); - } - - private: - const char* m_filename; - base::type::LineNumber m_lineNumber; - }; - - private: - const char* m_filename; - base::type::LineNumber m_lineNumber; - std::size_t m_hitCounts; -}; -/// @brief Repository for hit counters used across the application -class RegisteredHitCounters : public base::utils::RegistryWithPred { - public: - /// @brief Validates counter for every N, i.e, registers new if does not exist otherwise updates original one - /// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned - bool validateEveryN(const char* filename, base::type::LineNumber lineNumber, std::size_t n); - - /// @brief Validates counter for hits >= N, i.e, registers new if does not exist otherwise updates original one - /// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned - bool validateAfterN(const char* filename, base::type::LineNumber lineNumber, std::size_t n); - - /// @brief Validates counter for hits are <= n, i.e, registers new if does not exist otherwise updates original one - /// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned - bool validateNTimes(const char* filename, base::type::LineNumber lineNumber, std::size_t n); - - /// @brief Gets hit counter registered at specified position - inline const base::HitCounter* getCounter(const char* filename, base::type::LineNumber lineNumber) { - base::threading::ScopedLock scopedLock(lock()); - return get(filename, lineNumber); - } -}; -/// @brief Action to be taken for dispatching -enum class DispatchAction : base::type::EnumType { - None = 1, NormalLog = 2, SysLog = 4 -}; -} // namespace base -template -class Callback : protected base::threading::ThreadSafe { - public: - Callback(void) : m_enabled(true) {} - inline bool enabled(void) const { - return m_enabled; - } - inline void setEnabled(bool enabled) { - base::threading::ScopedLock scopedLock(lock()); - m_enabled = enabled; - } - protected: - virtual void handle(const T* handlePtr) = 0; - private: - bool m_enabled; -}; -class LogDispatchData { - public: - LogDispatchData() : m_logMessage(nullptr), m_dispatchAction(base::DispatchAction::None) {} - inline const LogMessage* logMessage(void) const { - return m_logMessage; - } - inline base::DispatchAction dispatchAction(void) const { - return m_dispatchAction; - } - inline void setLogMessage(LogMessage* logMessage) { - m_logMessage = logMessage; - } - inline void setDispatchAction(base::DispatchAction dispatchAction) { - m_dispatchAction = dispatchAction; - } - private: - LogMessage* m_logMessage; - base::DispatchAction m_dispatchAction; - friend class base::LogDispatcher; - -}; -class LogDispatchCallback : public Callback { - protected: - virtual void handle(const LogDispatchData* data); - base::threading::Mutex& fileHandle(const LogDispatchData* data); - private: - friend class base::LogDispatcher; - std::unordered_map> m_fileLocks; - base::threading::Mutex m_fileLocksMapLock; -}; -class PerformanceTrackingCallback : public Callback { - private: - friend class base::PerformanceTracker; -}; -class LoggerRegistrationCallback : public Callback { - private: - friend class base::RegisteredLoggers; -}; -class LogBuilder : base::NoCopy { - public: - LogBuilder() : m_termSupportsColor(base::utils::OS::termSupportsColor()) {} - virtual ~LogBuilder(void) { - ELPP_INTERNAL_INFO(3, "Destroying log builder...") - } - virtual base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const = 0; - void convertToColoredOutput(base::type::string_t* logLine, Level level); - private: - bool m_termSupportsColor; - friend class el::base::DefaultLogDispatchCallback; -}; -typedef std::shared_ptr LogBuilderPtr; -/// @brief Represents a logger holding ID and configurations we need to write logs -/// -/// @detail This class does not write logs itself instead its used by writer to read configurations from. -class Logger : public base::threading::ThreadSafe, public Loggable { - public: - Logger(const std::string& id, base::LogStreamsReferenceMapPtr logStreamsReference); - Logger(const std::string& id, const Configurations& configurations, base::LogStreamsReferenceMapPtr logStreamsReference); - Logger(const Logger& logger); - Logger& operator=(const Logger& logger); - - virtual ~Logger(void) { - base::utils::safeDelete(m_typedConfigurations); - } - - virtual inline void log(el::base::type::ostream_t& os) const { - os << m_id.c_str(); - } - - /// @brief Configures the logger using specified configurations. - void configure(const Configurations& configurations); - - /// @brief Reconfigures logger using existing configurations - void reconfigure(void); - - inline const std::string& id(void) const { - return m_id; - } - - inline const std::string& parentApplicationName(void) const { - return m_parentApplicationName; - } - - inline void setParentApplicationName(const std::string& parentApplicationName) { - m_parentApplicationName = parentApplicationName; - } - - inline Configurations* configurations(void) { - return &m_configurations; - } - - inline base::TypedConfigurations* typedConfigurations(void) { - return m_typedConfigurations; - } - - static bool isValidId(const std::string& id); - - /// @brief Flushes logger to sync all log files for all levels - void flush(void); - - void flush(Level level, base::type::fstream_t* fs); - - inline bool isFlushNeeded(Level level) { - return ++m_unflushedCount.find(level)->second >= m_typedConfigurations->logFlushThreshold(level); - } - - inline LogBuilder* logBuilder(void) const { - return m_logBuilder.get(); - } - - inline void setLogBuilder(const LogBuilderPtr& logBuilder) { - m_logBuilder = logBuilder; - } - - inline bool enabled(Level level) const { - return m_typedConfigurations->enabled(level); - } - -#if ELPP_VARIADIC_TEMPLATES_SUPPORTED -# define LOGGER_LEVEL_WRITERS_SIGNATURES(FUNCTION_NAME)\ -template \ -inline void FUNCTION_NAME(const char*, const T&, const Args&...);\ -template \ -inline void FUNCTION_NAME(const T&); - - template - inline void verbose(int, const char*, const T&, const Args&...); - - template - inline void verbose(int, const T&); - - LOGGER_LEVEL_WRITERS_SIGNATURES(info) - LOGGER_LEVEL_WRITERS_SIGNATURES(debug) - LOGGER_LEVEL_WRITERS_SIGNATURES(warn) - LOGGER_LEVEL_WRITERS_SIGNATURES(error) - LOGGER_LEVEL_WRITERS_SIGNATURES(fatal) - LOGGER_LEVEL_WRITERS_SIGNATURES(trace) -# undef LOGGER_LEVEL_WRITERS_SIGNATURES -#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED - private: - std::string m_id; - base::TypedConfigurations* m_typedConfigurations; - base::type::stringstream_t m_stream; - std::string m_parentApplicationName; - bool m_isConfigured; - Configurations m_configurations; - std::unordered_map m_unflushedCount; - base::LogStreamsReferenceMapPtr m_logStreamsReference = nullptr; - LogBuilderPtr m_logBuilder; - - friend class el::LogMessage; - friend class el::Loggers; - friend class el::Helpers; - friend class el::base::RegisteredLoggers; - friend class el::base::DefaultLogDispatchCallback; - friend class el::base::MessageBuilder; - friend class el::base::Writer; - friend class el::base::PErrorWriter; - friend class el::base::Storage; - friend class el::base::PerformanceTracker; - friend class el::base::LogDispatcher; - - Logger(void); - -#if ELPP_VARIADIC_TEMPLATES_SUPPORTED - template - void log_(Level, int, const char*, const T&, const Args&...); - - template - inline void log_(Level, int, const T&); - - template - void log(Level, const char*, const T&, const Args&...); - - template - inline void log(Level, const T&); -#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED - - void initUnflushedCount(void); - - inline base::type::stringstream_t& stream(void) { - return m_stream; - } - - void resolveLoggerFormatSpec(void) const; -}; -namespace base { -/// @brief Loggers repository -class RegisteredLoggers : public base::utils::Registry { - public: - explicit RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder); - - virtual ~RegisteredLoggers(void) { - unsafeFlushAll(); - } - - inline void setDefaultConfigurations(const Configurations& configurations) { - base::threading::ScopedLock scopedLock(lock()); - m_defaultConfigurations.setFromBase(const_cast(&configurations)); - } - - inline Configurations* defaultConfigurations(void) { - return &m_defaultConfigurations; - } - - Logger* get(const std::string& id, bool forceCreation = true); - - template - inline bool installLoggerRegistrationCallback(const std::string& id) { - return base::utils::Utils::installCallback(id, - &m_loggerRegistrationCallbacks); - } - - template - inline void uninstallLoggerRegistrationCallback(const std::string& id) { - base::utils::Utils::uninstallCallback(id, &m_loggerRegistrationCallbacks); - } - - template - inline T* loggerRegistrationCallback(const std::string& id) { - return base::utils::Utils::callback(id, &m_loggerRegistrationCallbacks); - } - - bool remove(const std::string& id); - - inline bool has(const std::string& id) { - return get(id, false) != nullptr; - } - - inline void unregister(Logger*& logger) { - base::threading::ScopedLock scopedLock(lock()); - base::utils::Registry::unregister(logger->id()); - } - - inline LogStreamsReferenceMapPtr logStreamsReference(void) { - return m_logStreamsReference; - } - - inline void flushAll(void) { - base::threading::ScopedLock scopedLock(lock()); - unsafeFlushAll(); - } - - inline void setDefaultLogBuilder(LogBuilderPtr& logBuilderPtr) { - base::threading::ScopedLock scopedLock(lock()); - m_defaultLogBuilder = logBuilderPtr; - } - - private: - LogBuilderPtr m_defaultLogBuilder; - Configurations m_defaultConfigurations; - base::LogStreamsReferenceMapPtr m_logStreamsReference = nullptr; - std::unordered_map m_loggerRegistrationCallbacks; - friend class el::base::Storage; - - void unsafeFlushAll(void); -}; -/// @brief Represents registries for verbose logging -class VRegistry : base::NoCopy, public base::threading::ThreadSafe { - public: - explicit VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags); - - /// @brief Sets verbose level. Accepted range is 0-9 - void setLevel(base::type::VerboseLevel level); - - inline base::type::VerboseLevel level(void) const { - return m_level; - } - - inline void clearModules(void) { - base::threading::ScopedLock scopedLock(lock()); - m_modules.clear(); - } - - void setModules(const char* modules); - - bool allowed(base::type::VerboseLevel vlevel, const char* file); - - inline const std::unordered_map& modules(void) const { - return m_modules; - } - - void setFromArgs(const base::utils::CommandLineArgs* commandLineArgs); - - /// @brief Whether or not vModules enabled - inline bool vModulesEnabled(void) { - return !base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags); - } - - private: - base::type::VerboseLevel m_level; - base::type::EnumType* m_pFlags; - std::unordered_map m_modules; -}; -} // namespace base -class LogMessage { - public: - LogMessage(Level level, const std::string& file, base::type::LineNumber line, const std::string& func, - base::type::VerboseLevel verboseLevel, Logger* logger) : - m_level(level), m_file(file), m_line(line), m_func(func), - m_verboseLevel(verboseLevel), m_logger(logger), m_message(logger->stream().str()) { - } - inline Level level(void) const { - return m_level; - } - inline const std::string& file(void) const { - return m_file; - } - inline base::type::LineNumber line(void) const { - return m_line; - } - inline const std::string& func(void) const { - return m_func; - } - inline base::type::VerboseLevel verboseLevel(void) const { - return m_verboseLevel; - } - inline Logger* logger(void) const { - return m_logger; - } - inline const base::type::string_t& message(void) const { - return m_message; - } - private: - Level m_level; - std::string m_file; - base::type::LineNumber m_line; - std::string m_func; - base::type::VerboseLevel m_verboseLevel; - Logger* m_logger; - base::type::string_t m_message; -}; -namespace base { -#if ELPP_ASYNC_LOGGING -class AsyncLogItem { - public: - explicit AsyncLogItem(const LogMessage& logMessage, const LogDispatchData& data, const base::type::string_t& logLine) - : m_logMessage(logMessage), m_dispatchData(data), m_logLine(logLine) {} - virtual ~AsyncLogItem() {} - inline LogMessage* logMessage(void) { - return &m_logMessage; - } - inline LogDispatchData* data(void) { - return &m_dispatchData; - } - inline base::type::string_t logLine(void) { - return m_logLine; - } - private: - LogMessage m_logMessage; - LogDispatchData m_dispatchData; - base::type::string_t m_logLine; -}; -class AsyncLogQueue : public base::threading::ThreadSafe { - public: - virtual ~AsyncLogQueue() { - ELPP_INTERNAL_INFO(6, "~AsyncLogQueue"); - } - - inline AsyncLogItem next(void) { - base::threading::ScopedLock scopedLock(lock()); - AsyncLogItem result = m_queue.front(); - m_queue.pop(); - return result; - } - - inline void push(const AsyncLogItem& item) { - base::threading::ScopedLock scopedLock(lock()); - m_queue.push(item); - } - inline void pop(void) { - base::threading::ScopedLock scopedLock(lock()); - m_queue.pop(); - } - inline AsyncLogItem front(void) { - base::threading::ScopedLock scopedLock(lock()); - return m_queue.front(); - } - inline bool empty(void) { - base::threading::ScopedLock scopedLock(lock()); - return m_queue.empty(); - } - private: - std::queue m_queue; -}; -class IWorker { - public: - virtual ~IWorker() {} - virtual void start() = 0; -}; -#endif // ELPP_ASYNC_LOGGING -/// @brief Easylogging++ management storage -class Storage : base::NoCopy, public base::threading::ThreadSafe { - public: -#if ELPP_ASYNC_LOGGING - Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker); -#else - explicit Storage(const LogBuilderPtr& defaultLogBuilder); -#endif // ELPP_ASYNC_LOGGING - - virtual ~Storage(void); - - inline bool validateEveryNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t occasion) { - return hitCounters()->validateEveryN(filename, lineNumber, occasion); - } - - inline bool validateAfterNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) { - return hitCounters()->validateAfterN(filename, lineNumber, n); - } - - inline bool validateNTimesCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) { - return hitCounters()->validateNTimes(filename, lineNumber, n); - } - - inline base::RegisteredHitCounters* hitCounters(void) const { - return m_registeredHitCounters; - } - - inline base::RegisteredLoggers* registeredLoggers(void) const { - return m_registeredLoggers; - } - - inline base::VRegistry* vRegistry(void) const { - return m_vRegistry; - } - -#if ELPP_ASYNC_LOGGING - inline base::AsyncLogQueue* asyncLogQueue(void) const { - return m_asyncLogQueue; - } -#endif // ELPP_ASYNC_LOGGING - - inline const base::utils::CommandLineArgs* commandLineArgs(void) const { - return &m_commandLineArgs; - } - - inline void addFlag(LoggingFlag flag) { - base::utils::addFlag(flag, &m_flags); - } - - inline void removeFlag(LoggingFlag flag) { - base::utils::removeFlag(flag, &m_flags); - } - - inline bool hasFlag(LoggingFlag flag) const { - return base::utils::hasFlag(flag, m_flags); - } - - inline base::type::EnumType flags(void) const { - return m_flags; - } - - inline void setFlags(base::type::EnumType flags) { - m_flags = flags; - } - - inline void setPreRollOutCallback(const PreRollOutCallback& callback) { - m_preRollOutCallback = callback; - } - - inline void unsetPreRollOutCallback(void) { - m_preRollOutCallback = base::defaultPreRollOutCallback; - } - - inline PreRollOutCallback& preRollOutCallback(void) { - return m_preRollOutCallback; - } - - bool hasCustomFormatSpecifier(const char* formatSpecifier); - void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier); - bool uninstallCustomFormatSpecifier(const char* formatSpecifier); - - const std::vector* customFormatSpecifiers(void) const { - return &m_customFormatSpecifiers; - } - - base::threading::Mutex& customFormatSpecifiersLock() { - return m_customFormatSpecifiersLock; - } - - inline void setLoggingLevel(Level level) { - m_loggingLevel = level; - } - - template - inline bool installLogDispatchCallback(const std::string& id) { - return base::utils::Utils::installCallback(id, &m_logDispatchCallbacks); - } - - template - inline void uninstallLogDispatchCallback(const std::string& id) { - base::utils::Utils::uninstallCallback(id, &m_logDispatchCallbacks); - } - template - inline T* logDispatchCallback(const std::string& id) { - return base::utils::Utils::callback(id, &m_logDispatchCallbacks); - } - -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - template - inline bool installPerformanceTrackingCallback(const std::string& id) { - return base::utils::Utils::installCallback(id, - &m_performanceTrackingCallbacks); - } - - template - inline void uninstallPerformanceTrackingCallback(const std::string& id) { - base::utils::Utils::uninstallCallback(id, - &m_performanceTrackingCallbacks); - } - - template - inline T* performanceTrackingCallback(const std::string& id) { - return base::utils::Utils::callback(id, &m_performanceTrackingCallbacks); - } -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - - /// @brief Sets thread name for current thread. Requires std::thread - inline void setThreadName(const std::string& name) { - if (name.empty()) return; - base::threading::ScopedLock scopedLock(m_threadNamesLock); - m_threadNames[base::threading::getCurrentThreadId()] = name; - } - - inline std::string getThreadName(const std::string& threadId) { - base::threading::ScopedLock scopedLock(m_threadNamesLock); - std::unordered_map::const_iterator it = m_threadNames.find(threadId); - if (it == m_threadNames.end()) { - return threadId; - } - return it->second; - } - private: - base::RegisteredHitCounters* m_registeredHitCounters; - base::RegisteredLoggers* m_registeredLoggers; - base::type::EnumType m_flags; - base::VRegistry* m_vRegistry; -#if ELPP_ASYNC_LOGGING - base::AsyncLogQueue* m_asyncLogQueue; - base::IWorker* m_asyncDispatchWorker; -#endif // ELPP_ASYNC_LOGGING - base::utils::CommandLineArgs m_commandLineArgs; - PreRollOutCallback m_preRollOutCallback; - std::unordered_map m_logDispatchCallbacks; - std::unordered_map m_performanceTrackingCallbacks; - std::unordered_map m_threadNames; - std::vector m_customFormatSpecifiers; - base::threading::Mutex m_customFormatSpecifiersLock; - base::threading::Mutex m_threadNamesLock; - Level m_loggingLevel; - - friend class el::Helpers; - friend class el::base::DefaultLogDispatchCallback; - friend class el::LogBuilder; - friend class el::base::MessageBuilder; - friend class el::base::Writer; - friend class el::base::PerformanceTracker; - friend class el::base::LogDispatcher; - - void setApplicationArguments(int argc, char** argv); - - inline void setApplicationArguments(int argc, const char** argv) { - setApplicationArguments(argc, const_cast(argv)); - } -}; -extern ELPP_EXPORT base::type::StoragePointer elStorage; -#define ELPP el::base::elStorage -class DefaultLogDispatchCallback : public LogDispatchCallback { - protected: - void handle(const LogDispatchData* data); - private: - const LogDispatchData* m_data; - void dispatch(base::type::string_t&& logLine); -}; -#if ELPP_ASYNC_LOGGING -class AsyncLogDispatchCallback : public LogDispatchCallback { - protected: - void handle(const LogDispatchData* data); -}; -class AsyncDispatchWorker : public base::IWorker, public base::threading::ThreadSafe { - public: - AsyncDispatchWorker(); - virtual ~AsyncDispatchWorker(); - - bool clean(void); - void emptyQueue(void); - virtual void start(void); - void handle(AsyncLogItem* logItem); - void run(void); - - void setContinueRunning(bool value) { - base::threading::ScopedLock scopedLock(m_continueRunningLock); - m_continueRunning = value; - } - - bool continueRunning(void) const { - return m_continueRunning; - } - private: - std::condition_variable cv; - bool m_continueRunning; - base::threading::Mutex m_continueRunningLock; -}; -#endif // ELPP_ASYNC_LOGGING -} // namespace base -namespace base { -class DefaultLogBuilder : public LogBuilder { - public: - base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const; -}; -/// @brief Dispatches log messages -class LogDispatcher : base::NoCopy { - public: - LogDispatcher(bool proceed, LogMessage* logMessage, base::DispatchAction dispatchAction) : - m_proceed(proceed), - m_logMessage(logMessage), - m_dispatchAction(std::move(dispatchAction)) { - } - - void dispatch(void); - - private: - bool m_proceed; - LogMessage* m_logMessage; - base::DispatchAction m_dispatchAction; -}; -#if defined(ELPP_STL_LOGGING) -/// @brief Workarounds to write some STL logs -/// -/// @detail There is workaround needed to loop through some stl containers. In order to do that, we need iterable containers -/// of same type and provide iterator interface and pass it on to writeIterator(). -/// Remember, this is passed by value in constructor so that we dont change original containers. -/// This operation is as expensive as Big-O(std::min(class_.size(), base::consts::kMaxLogPerContainer)) -namespace workarounds { -/// @brief Abstract IterableContainer template that provides interface for iterable classes of type T -template -class IterableContainer { - public: - typedef typename Container::iterator iterator; - typedef typename Container::const_iterator const_iterator; - IterableContainer(void) {} - virtual ~IterableContainer(void) {} - iterator begin(void) { - return getContainer().begin(); - } - iterator end(void) { - return getContainer().end(); - } - private: - virtual Container& getContainer(void) = 0; -}; -/// @brief Implements IterableContainer and provides iterable std::priority_queue class -template, typename Comparator = std::less> -class IterablePriorityQueue : public IterableContainer, - public std::priority_queue { - public: - IterablePriorityQueue(std::priority_queue queue_) { - std::size_t count_ = 0; - while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) { - this->push(queue_.top()); - queue_.pop(); - } - } - private: - inline Container& getContainer(void) { - return this->c; - } -}; -/// @brief Implements IterableContainer and provides iterable std::queue class -template> -class IterableQueue : public IterableContainer, public std::queue { - public: - IterableQueue(std::queue queue_) { - std::size_t count_ = 0; - while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) { - this->push(queue_.front()); - queue_.pop(); - } - } - private: - inline Container& getContainer(void) { - return this->c; - } -}; -/// @brief Implements IterableContainer and provides iterable std::stack class -template> -class IterableStack : public IterableContainer, public std::stack { - public: - IterableStack(std::stack stack_) { - std::size_t count_ = 0; - while (++count_ < base::consts::kMaxLogPerContainer && !stack_.empty()) { - this->push(stack_.top()); - stack_.pop(); - } - } - private: - inline Container& getContainer(void) { - return this->c; - } -}; -} // namespace workarounds -#endif // defined(ELPP_STL_LOGGING) -// Log message builder -class MessageBuilder { - public: - MessageBuilder(void) : m_logger(nullptr), m_containerLogSeparator(ELPP_LITERAL("")) {} - void initialize(Logger* logger); - -# define ELPP_SIMPLE_LOG(LOG_TYPE)\ -MessageBuilder& operator<<(LOG_TYPE msg) {\ -m_logger->stream() << msg;\ -if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {\ -m_logger->stream() << " ";\ -}\ -return *this;\ -} - - inline MessageBuilder& operator<<(const std::string& msg) { - return operator<<(msg.c_str()); - } - ELPP_SIMPLE_LOG(char) - ELPP_SIMPLE_LOG(bool) - ELPP_SIMPLE_LOG(signed short) - ELPP_SIMPLE_LOG(unsigned short) - ELPP_SIMPLE_LOG(signed int) - ELPP_SIMPLE_LOG(unsigned int) - ELPP_SIMPLE_LOG(signed long) - ELPP_SIMPLE_LOG(unsigned long) - ELPP_SIMPLE_LOG(float) - ELPP_SIMPLE_LOG(double) - ELPP_SIMPLE_LOG(char*) - ELPP_SIMPLE_LOG(const char*) - ELPP_SIMPLE_LOG(const void*) - ELPP_SIMPLE_LOG(long double) - inline MessageBuilder& operator<<(const std::wstring& msg) { - return operator<<(msg.c_str()); - } - MessageBuilder& operator<<(const wchar_t* msg); - // ostream manipulators - inline MessageBuilder& operator<<(std::ostream& (*OStreamMani)(std::ostream&)) { - m_logger->stream() << OStreamMani; - return *this; - } -#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp) \ -template \ -inline MessageBuilder& operator<<(const temp& template_inst) { \ -return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ -} -#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp) \ -template \ -inline MessageBuilder& operator<<(const temp& template_inst) { \ -return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ -} -#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp) \ -template \ -inline MessageBuilder& operator<<(const temp& template_inst) { \ -return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ -} -#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp) \ -template \ -inline MessageBuilder& operator<<(const temp& template_inst) { \ -return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ -} -#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp) \ -template \ -inline MessageBuilder& operator<<(const temp& template_inst) { \ -return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ -} - -#if defined(ELPP_STL_LOGGING) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(std::vector) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(std::list) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(std::deque) - ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(std::set) - ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(std::multiset) - ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::map) - ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::multimap) - template - inline MessageBuilder& operator<<(const std::queue& queue_) { - base::workarounds::IterableQueue iterableQueue_ = - static_cast >(queue_); - return writeIterator(iterableQueue_.begin(), iterableQueue_.end(), iterableQueue_.size()); - } - template - inline MessageBuilder& operator<<(const std::stack& stack_) { - base::workarounds::IterableStack iterableStack_ = - static_cast >(stack_); - return writeIterator(iterableStack_.begin(), iterableStack_.end(), iterableStack_.size()); - } - template - inline MessageBuilder& operator<<(const std::priority_queue& priorityQueue_) { - base::workarounds::IterablePriorityQueue iterablePriorityQueue_ = - static_cast >(priorityQueue_); - return writeIterator(iterablePriorityQueue_.begin(), iterablePriorityQueue_.end(), iterablePriorityQueue_.size()); - } - template - MessageBuilder& operator<<(const std::pair& pair_) { - m_logger->stream() << ELPP_LITERAL("("); - operator << (static_cast(pair_.first)); - m_logger->stream() << ELPP_LITERAL(", "); - operator << (static_cast(pair_.second)); - m_logger->stream() << ELPP_LITERAL(")"); - return *this; - } - template - MessageBuilder& operator<<(const std::bitset& bitset_) { - m_logger->stream() << ELPP_LITERAL("["); - operator << (bitset_.to_string()); - m_logger->stream() << ELPP_LITERAL("]"); - return *this; - } -# if defined(ELPP_LOG_STD_ARRAY) - template - inline MessageBuilder& operator<<(const std::array& array) { - return writeIterator(array.begin(), array.end(), array.size()); - } -# endif // defined(ELPP_LOG_STD_ARRAY) -# if defined(ELPP_LOG_UNORDERED_MAP) - ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_map) - ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_multimap) -# endif // defined(ELPP_LOG_UNORDERED_MAP) -# if defined(ELPP_LOG_UNORDERED_SET) - ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_set) - ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_multiset) -# endif // defined(ELPP_LOG_UNORDERED_SET) -#endif // defined(ELPP_STL_LOGGING) -#if defined(ELPP_QT_LOGGING) - inline MessageBuilder& operator<<(const QString& msg) { -# if defined(ELPP_UNICODE) - m_logger->stream() << msg.toStdWString(); -# else - m_logger->stream() << msg.toStdString(); -# endif // defined(ELPP_UNICODE) - return *this; - } - inline MessageBuilder& operator<<(const QByteArray& msg) { - return operator << (QString(msg)); - } - inline MessageBuilder& operator<<(const QStringRef& msg) { - return operator<<(msg.toString()); - } - inline MessageBuilder& operator<<(qint64 msg) { -# if defined(ELPP_UNICODE) - m_logger->stream() << QString::number(msg).toStdWString(); -# else - m_logger->stream() << QString::number(msg).toStdString(); -# endif // defined(ELPP_UNICODE) - return *this; - } - inline MessageBuilder& operator<<(quint64 msg) { -# if defined(ELPP_UNICODE) - m_logger->stream() << QString::number(msg).toStdWString(); -# else - m_logger->stream() << QString::number(msg).toStdString(); -# endif // defined(ELPP_UNICODE) - return *this; - } - inline MessageBuilder& operator<<(QChar msg) { - m_logger->stream() << msg.toLatin1(); - return *this; - } - inline MessageBuilder& operator<<(const QLatin1String& msg) { - m_logger->stream() << msg.latin1(); - return *this; - } - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QList) - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QVector) - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QQueue) - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QSet) - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QLinkedList) - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QStack) - template - MessageBuilder& operator<<(const QPair& pair_) { - m_logger->stream() << ELPP_LITERAL("("); - operator << (static_cast(pair_.first)); - m_logger->stream() << ELPP_LITERAL(", "); - operator << (static_cast(pair_.second)); - m_logger->stream() << ELPP_LITERAL(")"); - return *this; - } - template - MessageBuilder& operator<<(const QMap& map_) { - m_logger->stream() << ELPP_LITERAL("["); - QList keys = map_.keys(); - typename QList::const_iterator begin = keys.begin(); - typename QList::const_iterator end = keys.end(); - int max_ = static_cast(base::consts::kMaxLogPerContainer); // to prevent warning - for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) { - m_logger->stream() << ELPP_LITERAL("("); - operator << (static_cast(*begin)); - m_logger->stream() << ELPP_LITERAL(", "); - operator << (static_cast(map_.value(*begin))); - m_logger->stream() << ELPP_LITERAL(")"); - m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeparator : ELPP_LITERAL("")); - } - if (begin != end) { - m_logger->stream() << ELPP_LITERAL("..."); - } - m_logger->stream() << ELPP_LITERAL("]"); - return *this; - } - template - inline MessageBuilder& operator<<(const QMultiMap& map_) { - operator << (static_cast>(map_)); - return *this; - } - template - MessageBuilder& operator<<(const QHash& hash_) { - m_logger->stream() << ELPP_LITERAL("["); - QList keys = hash_.keys(); - typename QList::const_iterator begin = keys.begin(); - typename QList::const_iterator end = keys.end(); - int max_ = static_cast(base::consts::kMaxLogPerContainer); // prevent type warning - for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) { - m_logger->stream() << ELPP_LITERAL("("); - operator << (static_cast(*begin)); - m_logger->stream() << ELPP_LITERAL(", "); - operator << (static_cast(hash_.value(*begin))); - m_logger->stream() << ELPP_LITERAL(")"); - m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeparator : ELPP_LITERAL("")); - } - if (begin != end) { - m_logger->stream() << ELPP_LITERAL("..."); - } - m_logger->stream() << ELPP_LITERAL("]"); - return *this; - } - template - inline MessageBuilder& operator<<(const QMultiHash& multiHash_) { - operator << (static_cast>(multiHash_)); - return *this; - } -#endif // defined(ELPP_QT_LOGGING) -#if defined(ELPP_BOOST_LOGGING) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::vector) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::stable_vector) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::list) - ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::deque) - ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::map) - ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::flat_map) - ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::set) - ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::flat_set) -#endif // defined(ELPP_BOOST_LOGGING) - - /// @brief Macro used internally that can be used externally to make containers easylogging++ friendly - /// - /// @detail This macro expands to write an ostream& operator<< for container. This container is expected to - /// have begin() and end() methods that return respective iterators - /// @param ContainerType Type of container e.g, MyList from WX_DECLARE_LIST(int, MyList); in wxwidgets - /// @param SizeMethod Method used to get size of container. - /// @param ElementInstance Instance of element to be fed out. Instance name is "elem". See WXELPP_ENABLED macro - /// for an example usage -#define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \ -el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\ -const el::base::type::char_t* sep = ELPP->hasFlag(el::LoggingFlag::NewLineForContainer) ? \ -ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");\ -ContainerType::const_iterator elem = container.begin();\ -ContainerType::const_iterator endElem = container.end();\ -std::size_t size_ = container.SizeMethod; \ -ss << ELPP_LITERAL("[");\ -for (std::size_t i = 0; elem != endElem && i < el::base::consts::kMaxLogPerContainer; ++i, ++elem) { \ -ss << ElementInstance;\ -ss << ((i < size_ - 1) ? sep : ELPP_LITERAL(""));\ -}\ -if (elem != endElem) {\ -ss << ELPP_LITERAL("...");\ -}\ -ss << ELPP_LITERAL("]");\ -return ss;\ -} -#if defined(ELPP_WXWIDGETS_LOGGING) - ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(wxVector) -# define ELPP_WX_PTR_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), *(*elem)) -# define ELPP_WX_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), (*elem)) -# define ELPP_WX_HASH_MAP_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), \ -ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_LITERAL(")") -#else -# define ELPP_WX_PTR_ENABLED(ContainerType) -# define ELPP_WX_ENABLED(ContainerType) -# define ELPP_WX_HASH_MAP_ENABLED(ContainerType) -#endif // defined(ELPP_WXWIDGETS_LOGGING) - // Other classes - template - ELPP_SIMPLE_LOG(const Class&) -#undef ELPP_SIMPLE_LOG -#undef ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG -#undef ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG -#undef ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG -#undef ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG -#undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG - private: - Logger* m_logger; - const base::type::char_t* m_containerLogSeparator; - - template - MessageBuilder& writeIterator(Iterator begin_, Iterator end_, std::size_t size_) { - m_logger->stream() << ELPP_LITERAL("["); - for (std::size_t i = 0; begin_ != end_ && i < base::consts::kMaxLogPerContainer; ++i, ++begin_) { - operator << (*begin_); - m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeparator : ELPP_LITERAL("")); - } - if (begin_ != end_) { - m_logger->stream() << ELPP_LITERAL("..."); - } - m_logger->stream() << ELPP_LITERAL("]"); - if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) { - m_logger->stream() << " "; - } - return *this; - } -}; -/// @brief Writes nothing - Used when certain log is disabled -class NullWriter : base::NoCopy { - public: - NullWriter(void) {} - - // Null manipulator - inline NullWriter& operator<<(std::ostream& (*)(std::ostream&)) { - return *this; - } - - template - inline NullWriter& operator<<(const T&) { - return *this; - } - - inline operator bool() { - return true; - } -}; -/// @brief Main entry point of each logging -class Writer : base::NoCopy { - public: - Writer(Level level, const char* file, base::type::LineNumber line, - const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog, - base::type::VerboseLevel verboseLevel = 0) : - m_msg(nullptr), m_level(level), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel), - m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction) { - } - - Writer(LogMessage* msg, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog) : - m_msg(msg), m_level(msg != nullptr ? msg->level() : Level::Unknown), - m_line(0), m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction) { - } - - virtual ~Writer(void) { - processDispatch(); - } - - template - inline Writer& operator<<(const T& log) { -#if ELPP_LOGGING_ENABLED - if (m_proceed) { - m_messageBuilder << log; - } -#endif // ELPP_LOGGING_ENABLED - return *this; - } - - inline Writer& operator<<(std::ostream& (*log)(std::ostream&)) { -#if ELPP_LOGGING_ENABLED - if (m_proceed) { - m_messageBuilder << log; - } -#endif // ELPP_LOGGING_ENABLED - return *this; - } - - inline operator bool() { - return true; - } - - Writer& construct(Logger* logger, bool needLock = true); - Writer& construct(int count, const char* loggerIds, ...); - protected: - LogMessage* m_msg; - Level m_level; - const char* m_file; - const base::type::LineNumber m_line; - const char* m_func; - base::type::VerboseLevel m_verboseLevel; - Logger* m_logger; - bool m_proceed; - base::MessageBuilder m_messageBuilder; - base::DispatchAction m_dispatchAction; - std::vector m_loggerIds; - friend class el::Helpers; - - void initializeLogger(const std::string& loggerId, bool lookup = true, bool needLock = true); - void processDispatch(); - void triggerDispatch(void); -}; -class PErrorWriter : public base::Writer { - public: - PErrorWriter(Level level, const char* file, base::type::LineNumber line, - const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog, - base::type::VerboseLevel verboseLevel = 0) : - base::Writer(level, file, line, func, dispatchAction, verboseLevel) { - } - - virtual ~PErrorWriter(void); -}; -} // namespace base -// Logging from Logger class. Why this is here? Because we have Storage and Writer class available -#if ELPP_VARIADIC_TEMPLATES_SUPPORTED -template -void Logger::log_(Level level, int vlevel, const char* s, const T& value, const Args&... args) { - base::MessageBuilder b; - b.initialize(this); - while (*s) { - if (*s == base::consts::kFormatSpecifierChar) { - if (*(s + 1) == base::consts::kFormatSpecifierChar) { - ++s; - } else { - if (*(s + 1) == base::consts::kFormatSpecifierCharValue) { - ++s; - b << value; - log_(level, vlevel, ++s, args...); - return; - } - } - } - b << *s++; - } - ELPP_INTERNAL_ERROR("Too many arguments provided. Unable to handle. Please provide more format specifiers", false); -} -template -void Logger::log_(Level level, int vlevel, const T& log) { - if (level == Level::Verbose) { - if (ELPP->vRegistry()->allowed(vlevel, __FILE__)) { - base::Writer(Level::Verbose, "FILE", 0, "FUNCTION", - base::DispatchAction::NormalLog, vlevel).construct(this, false) << log; - } else { - stream().str(ELPP_LITERAL("")); - releaseLock(); - } - } else { - base::Writer(level, "FILE", 0, "FUNCTION").construct(this, false) << log; - } -} -template -inline void Logger::log(Level level, const char* s, const T& value, const Args&... args) { - acquireLock(); // released in Writer! - log_(level, 0, s, value, args...); -} -template -inline void Logger::log(Level level, const T& log) { - acquireLock(); // released in Writer! - log_(level, 0, log); -} -# if ELPP_VERBOSE_LOG -template -inline void Logger::verbose(int vlevel, const char* s, const T& value, const Args&... args) { - acquireLock(); // released in Writer! - log_(el::Level::Verbose, vlevel, s, value, args...); -} -template -inline void Logger::verbose(int vlevel, const T& log) { - acquireLock(); // released in Writer! - log_(el::Level::Verbose, vlevel, log); -} -# else -template -inline void Logger::verbose(int, const char*, const T&, const Args&...) { - return; -} -template -inline void Logger::verbose(int, const T&) { - return; -} -# endif // ELPP_VERBOSE_LOG -# define LOGGER_LEVEL_WRITERS(FUNCTION_NAME, LOG_LEVEL)\ -template \ -inline void Logger::FUNCTION_NAME(const char* s, const T& value, const Args&... args) {\ -log(LOG_LEVEL, s, value, args...);\ -}\ -template \ -inline void Logger::FUNCTION_NAME(const T& value) {\ -log(LOG_LEVEL, value);\ -} -# define LOGGER_LEVEL_WRITERS_DISABLED(FUNCTION_NAME, LOG_LEVEL)\ -template \ -inline void Logger::FUNCTION_NAME(const char*, const T&, const Args&...) {\ -return;\ -}\ -template \ -inline void Logger::FUNCTION_NAME(const T&) {\ -return;\ -} - -# if ELPP_INFO_LOG -LOGGER_LEVEL_WRITERS(info, Level::Info) -# else -LOGGER_LEVEL_WRITERS_DISABLED(info, Level::Info) -# endif // ELPP_INFO_LOG -# if ELPP_DEBUG_LOG -LOGGER_LEVEL_WRITERS(debug, Level::Debug) -# else -LOGGER_LEVEL_WRITERS_DISABLED(debug, Level::Debug) -# endif // ELPP_DEBUG_LOG -# if ELPP_WARNING_LOG -LOGGER_LEVEL_WRITERS(warn, Level::Warning) -# else -LOGGER_LEVEL_WRITERS_DISABLED(warn, Level::Warning) -# endif // ELPP_WARNING_LOG -# if ELPP_ERROR_LOG -LOGGER_LEVEL_WRITERS(error, Level::Error) -# else -LOGGER_LEVEL_WRITERS_DISABLED(error, Level::Error) -# endif // ELPP_ERROR_LOG -# if ELPP_FATAL_LOG -LOGGER_LEVEL_WRITERS(fatal, Level::Fatal) -# else -LOGGER_LEVEL_WRITERS_DISABLED(fatal, Level::Fatal) -# endif // ELPP_FATAL_LOG -# if ELPP_TRACE_LOG -LOGGER_LEVEL_WRITERS(trace, Level::Trace) -# else -LOGGER_LEVEL_WRITERS_DISABLED(trace, Level::Trace) -# endif // ELPP_TRACE_LOG -# undef LOGGER_LEVEL_WRITERS -# undef LOGGER_LEVEL_WRITERS_DISABLED -#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED -#if ELPP_COMPILER_MSVC -# define ELPP_VARIADIC_FUNC_MSVC(variadicFunction, variadicArgs) variadicFunction variadicArgs -# define ELPP_VARIADIC_FUNC_MSVC_RUN(variadicFunction, ...) ELPP_VARIADIC_FUNC_MSVC(variadicFunction, (__VA_ARGS__)) -# define el_getVALength(...) ELPP_VARIADIC_FUNC_MSVC_RUN(el_resolveVALength, 0, ## __VA_ARGS__,\ -10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) -#else -# if ELPP_COMPILER_CLANG -# define el_getVALength(...) el_resolveVALength(0, __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) -# else -# define el_getVALength(...) el_resolveVALength(0, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) -# endif // ELPP_COMPILER_CLANG -#endif // ELPP_COMPILER_MSVC -#define el_resolveVALength(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N -#define ELPP_WRITE_LOG(writer, level, dispatchAction, ...) \ -writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#define ELPP_WRITE_LOG_IF(writer, condition, level, dispatchAction, ...) if (condition) \ -writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#define ELPP_WRITE_LOG_EVERY_N(writer, occasion, level, dispatchAction, ...) \ -ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion) && \ -writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#define ELPP_WRITE_LOG_AFTER_N(writer, n, level, dispatchAction, ...) \ -ELPP->validateAfterNCounter(__FILE__, __LINE__, n) && \ -writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#define ELPP_WRITE_LOG_N_TIMES(writer, n, level, dispatchAction, ...) \ -ELPP->validateNTimesCounter(__FILE__, __LINE__, n) && \ -writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) -class PerformanceTrackingData { - public: - enum class DataType : base::type::EnumType { - Checkpoint = 1, Complete = 2 - }; - // Do not use constructor, will run into multiple definition error, use init(PerformanceTracker*) - explicit PerformanceTrackingData(DataType dataType) : m_performanceTracker(nullptr), - m_dataType(dataType), m_firstCheckpoint(false), m_file(""), m_line(0), m_func("") {} - inline const std::string* blockName(void) const; - inline const struct timeval* startTime(void) const; - inline const struct timeval* endTime(void) const; - inline const struct timeval* lastCheckpointTime(void) const; - inline const base::PerformanceTracker* performanceTracker(void) const { - return m_performanceTracker; - } - inline PerformanceTrackingData::DataType dataType(void) const { - return m_dataType; - } - inline bool firstCheckpoint(void) const { - return m_firstCheckpoint; - } - inline std::string checkpointId(void) const { - return m_checkpointId; - } - inline const char* file(void) const { - return m_file; - } - inline base::type::LineNumber line(void) const { - return m_line; - } - inline const char* func(void) const { - return m_func; - } - inline const base::type::string_t* formattedTimeTaken() const { - return &m_formattedTimeTaken; - } - inline const std::string& loggerId(void) const; - private: - base::PerformanceTracker* m_performanceTracker; - base::type::string_t m_formattedTimeTaken; - PerformanceTrackingData::DataType m_dataType; - bool m_firstCheckpoint; - std::string m_checkpointId; - const char* m_file; - base::type::LineNumber m_line; - const char* m_func; - inline void init(base::PerformanceTracker* performanceTracker, bool firstCheckpoint = false) { - m_performanceTracker = performanceTracker; - m_firstCheckpoint = firstCheckpoint; - } - - friend class el::base::PerformanceTracker; -}; -namespace base { -/// @brief Represents performanceTracker block of code that conditionally adds performance status to log -/// either when goes outside the scope of when checkpoint() is called -class PerformanceTracker : public base::threading::ThreadSafe, public Loggable { - public: - PerformanceTracker(const std::string& blockName, - base::TimestampUnit timestampUnit = base::TimestampUnit::Millisecond, - const std::string& loggerId = std::string(el::base::consts::kPerformanceLoggerId), - bool scopedLog = true, Level level = base::consts::kPerformanceTrackerDefaultLevel); - /// @brief Copy constructor - PerformanceTracker(const PerformanceTracker& t) : - m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog), - m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled), - m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) { - } - virtual ~PerformanceTracker(void); - /// @brief A checkpoint for current performanceTracker block. - void checkpoint(const std::string& id = std::string(), const char* file = __FILE__, - base::type::LineNumber line = __LINE__, - const char* func = ""); - inline Level level(void) const { - return m_level; - } - private: - std::string m_blockName; - base::TimestampUnit m_timestampUnit; - std::string m_loggerId; - bool m_scopedLog; - Level m_level; - bool m_hasChecked; - std::string m_lastCheckpointId; - bool m_enabled; - struct timeval m_startTime, m_endTime, m_lastCheckpointTime; - - PerformanceTracker(void); - - friend class el::PerformanceTrackingData; - friend class base::DefaultPerformanceTrackingCallback; - - const inline base::type::string_t getFormattedTimeTaken() const { - return getFormattedTimeTaken(m_startTime); - } - - const base::type::string_t getFormattedTimeTaken(struct timeval startTime) const; - - virtual inline void log(el::base::type::ostream_t& os) const { - os << getFormattedTimeTaken(); - } -}; -class DefaultPerformanceTrackingCallback : public PerformanceTrackingCallback { - protected: - void handle(const PerformanceTrackingData* data) { - m_data = data; - base::type::stringstream_t ss; - if (m_data->dataType() == PerformanceTrackingData::DataType::Complete) { - ss << ELPP_LITERAL("Executed [") << m_data->blockName()->c_str() << ELPP_LITERAL("] in [") << - *m_data->formattedTimeTaken() << ELPP_LITERAL("]"); - } else { - ss << ELPP_LITERAL("Performance checkpoint"); - if (!m_data->checkpointId().empty()) { - ss << ELPP_LITERAL(" [") << m_data->checkpointId().c_str() << ELPP_LITERAL("]"); - } - ss << ELPP_LITERAL(" for block [") << m_data->blockName()->c_str() << ELPP_LITERAL("] : [") << - *m_data->performanceTracker(); - if (!ELPP->hasFlag(LoggingFlag::DisablePerformanceTrackingCheckpointComparison) - && m_data->performanceTracker()->m_hasChecked) { - ss << ELPP_LITERAL(" ([") << *m_data->formattedTimeTaken() << ELPP_LITERAL("] from "); - if (m_data->performanceTracker()->m_lastCheckpointId.empty()) { - ss << ELPP_LITERAL("last checkpoint"); - } else { - ss << ELPP_LITERAL("checkpoint '") << m_data->performanceTracker()->m_lastCheckpointId.c_str() << ELPP_LITERAL("'"); - } - ss << ELPP_LITERAL(")]"); - } else { - ss << ELPP_LITERAL("]"); - } - } - el::base::Writer(m_data->performanceTracker()->level(), m_data->file(), m_data->line(), m_data->func()).construct(1, - m_data->loggerId().c_str()) << ss.str(); - } - private: - const PerformanceTrackingData* m_data; -}; -} // namespace base -inline const std::string* PerformanceTrackingData::blockName() const { - return const_cast(&m_performanceTracker->m_blockName); -} -inline const struct timeval* PerformanceTrackingData::startTime() const { - return const_cast(&m_performanceTracker->m_startTime); -} -inline const struct timeval* PerformanceTrackingData::endTime() const { - return const_cast(&m_performanceTracker->m_endTime); -} -inline const struct timeval* PerformanceTrackingData::lastCheckpointTime() const { - return const_cast(&m_performanceTracker->m_lastCheckpointTime); -} -inline const std::string& PerformanceTrackingData::loggerId(void) const { - return m_performanceTracker->m_loggerId; -} -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) -namespace base { -/// @brief Contains some internal debugging tools like crash handler and stack tracer -namespace debug { -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) -class StackTrace : base::NoCopy { - public: - static const unsigned int kMaxStack = 64; - static const unsigned int kStackStart = 2; // We want to skip c'tor and StackTrace::generateNew() - class StackTraceEntry { - public: - StackTraceEntry(std::size_t index, const std::string& loc, const std::string& demang, const std::string& hex, - const std::string& addr); - StackTraceEntry(std::size_t index, const std::string& loc) : - m_index(index), - m_location(loc) { - } - std::size_t m_index; - std::string m_location; - std::string m_demangled; - std::string m_hex; - std::string m_addr; - friend std::ostream& operator<<(std::ostream& ss, const StackTraceEntry& si); - - private: - StackTraceEntry(void); - }; - - StackTrace(void) { - generateNew(); - } - - virtual ~StackTrace(void) { - } - - inline std::vector& getLatestStack(void) { - return m_stack; - } - - friend std::ostream& operator<<(std::ostream& os, const StackTrace& st); - - private: - std::vector m_stack; - - void generateNew(void); -}; -/// @brief Handles unexpected crashes -class CrashHandler : base::NoCopy { - public: - typedef void (*Handler)(int); - - explicit CrashHandler(bool useDefault); - explicit CrashHandler(const Handler& cHandler) { - setHandler(cHandler); - } - void setHandler(const Handler& cHandler); - - private: - Handler m_handler; -}; -#else -class CrashHandler { - public: - explicit CrashHandler(bool) {} -}; -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) -} // namespace debug -} // namespace base -extern base::debug::CrashHandler elCrashHandler; -#define MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance) \ -el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamInstance, const ClassType& ClassInstance) -/// @brief Initializes syslog with process ID, options and facility. calls closelog() on d'tor -class SysLogInitializer { - public: - SysLogInitializer(const char* processIdent, int options = 0, int facility = 0) { -#if defined(ELPP_SYSLOG) - (void)base::consts::kSysLogLoggerId; - openlog(processIdent, options, facility); -#else - ELPP_UNUSED(processIdent); - ELPP_UNUSED(options); - ELPP_UNUSED(facility); -#endif // defined(ELPP_SYSLOG) - } - virtual ~SysLogInitializer(void) { -#if defined(ELPP_SYSLOG) - closelog(); -#endif // defined(ELPP_SYSLOG) - } -}; -#define ELPP_INITIALIZE_SYSLOG(id, opt, fac) el::SysLogInitializer elSyslogInit(id, opt, fac) -/// @brief Static helpers for developers -class Helpers : base::StaticClass { - public: - /// @brief Shares logging repository (base::Storage) - static inline void setStorage(base::type::StoragePointer storage) { - ELPP = storage; - } - /// @return Main storage repository - static inline base::type::StoragePointer storage() { - return ELPP; - } - /// @brief Sets application arguments and figures out whats active for logging and whats not. - static inline void setArgs(int argc, char** argv) { - ELPP->setApplicationArguments(argc, argv); - } - /// @copydoc setArgs(int argc, char** argv) - static inline void setArgs(int argc, const char** argv) { - ELPP->setApplicationArguments(argc, const_cast(argv)); - } - /// @brief Sets thread name for current thread. Requires std::thread - static inline void setThreadName(const std::string& name) { - ELPP->setThreadName(name); - } - static inline std::string getThreadName() { - return ELPP->getThreadName(base::threading::getCurrentThreadId()); - } -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) - /// @brief Overrides default crash handler and installs custom handler. - /// @param crashHandler A functor with no return type that takes single int argument. - /// Handler is a typedef with specification: void (*Handler)(int) - static inline void setCrashHandler(const el::base::debug::CrashHandler::Handler& crashHandler) { - el::elCrashHandler.setHandler(crashHandler); - } - /// @brief Abort due to crash with signal in parameter - /// @param sig Crash signal - static void crashAbort(int sig, const char* sourceFile = "", unsigned int long line = 0); - /// @brief Logs reason of crash as per sig - /// @param sig Crash signal - /// @param stackTraceIfAvailable Includes stack trace if available - /// @param level Logging level - /// @param logger Logger to use for logging - static void logCrashReason(int sig, bool stackTraceIfAvailable = false, - Level level = Level::Fatal, const char* logger = base::consts::kDefaultLoggerId); -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) - /// @brief Installs pre rollout callback, this callback is triggered when log file is about to be rolled out - /// (can be useful for backing up) - static inline void installPreRollOutCallback(const PreRollOutCallback& callback) { - ELPP->setPreRollOutCallback(callback); - } - /// @brief Uninstalls pre rollout callback - static inline void uninstallPreRollOutCallback(void) { - ELPP->unsetPreRollOutCallback(); - } - /// @brief Installs post log dispatch callback, this callback is triggered when log is dispatched - template - static inline bool installLogDispatchCallback(const std::string& id) { - return ELPP->installLogDispatchCallback(id); - } - /// @brief Uninstalls log dispatch callback - template - static inline void uninstallLogDispatchCallback(const std::string& id) { - ELPP->uninstallLogDispatchCallback(id); - } - template - static inline T* logDispatchCallback(const std::string& id) { - return ELPP->logDispatchCallback(id); - } -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - /// @brief Installs post performance tracking callback, this callback is triggered when performance tracking is finished - template - static inline bool installPerformanceTrackingCallback(const std::string& id) { - return ELPP->installPerformanceTrackingCallback(id); - } - /// @brief Uninstalls post performance tracking handler - template - static inline void uninstallPerformanceTrackingCallback(const std::string& id) { - ELPP->uninstallPerformanceTrackingCallback(id); - } - template - static inline T* performanceTrackingCallback(const std::string& id) { - return ELPP->performanceTrackingCallback(id); - } -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - /// @brief Converts template to std::string - useful for loggable classes to log containers within log(std::ostream&) const - template - static std::string convertTemplateToStdString(const T& templ) { - el::Logger* logger = - ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId); - if (logger == nullptr) { - return std::string(); - } - base::MessageBuilder b; - b.initialize(logger); - logger->acquireLock(); - b << templ; -#if defined(ELPP_UNICODE) - std::string s = std::string(logger->stream().str().begin(), logger->stream().str().end()); -#else - std::string s = logger->stream().str(); -#endif // defined(ELPP_UNICODE) - logger->stream().str(ELPP_LITERAL("")); - logger->releaseLock(); - return s; - } - /// @brief Returns command line arguments (pointer) provided to easylogging++ - static inline const el::base::utils::CommandLineArgs* commandLineArgs(void) { - return ELPP->commandLineArgs(); - } - /// @brief Reserve space for custom format specifiers for performance - /// @see std::vector::reserve - static inline void reserveCustomFormatSpecifiers(std::size_t size) { - ELPP->m_customFormatSpecifiers.reserve(size); - } - /// @brief Installs user defined format specifier and handler - static inline void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) { - ELPP->installCustomFormatSpecifier(customFormatSpecifier); - } - /// @brief Uninstalls user defined format specifier and handler - static inline bool uninstallCustomFormatSpecifier(const char* formatSpecifier) { - return ELPP->uninstallCustomFormatSpecifier(formatSpecifier); - } - /// @brief Returns true if custom format specifier is installed - static inline bool hasCustomFormatSpecifier(const char* formatSpecifier) { - return ELPP->hasCustomFormatSpecifier(formatSpecifier); - } - static inline void validateFileRolling(Logger* logger, Level level) { - if (ELPP == nullptr || logger == nullptr) return; - logger->m_typedConfigurations->validateFileRolling(level, ELPP->preRollOutCallback()); - } -}; -/// @brief Static helpers to deal with loggers and their configurations -class Loggers : base::StaticClass { - public: - /// @brief Gets existing or registers new logger - static Logger* getLogger(const std::string& identity, bool registerIfNotAvailable = true); - /// @brief Changes default log builder for future loggers - static void setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr); - /// @brief Installs logger registration callback, this callback is triggered when new logger is registered - template - static inline bool installLoggerRegistrationCallback(const std::string& id) { - return ELPP->registeredLoggers()->installLoggerRegistrationCallback(id); - } - /// @brief Uninstalls log dispatch callback - template - static inline void uninstallLoggerRegistrationCallback(const std::string& id) { - ELPP->registeredLoggers()->uninstallLoggerRegistrationCallback(id); - } - template - static inline T* loggerRegistrationCallback(const std::string& id) { - return ELPP->registeredLoggers()->loggerRegistrationCallback(id); - } - /// @brief Unregisters logger - use it only when you know what you are doing, you may unregister - /// loggers initialized / used by third-party libs. - static bool unregisterLogger(const std::string& identity); - /// @brief Whether or not logger with id is registered - static bool hasLogger(const std::string& identity); - /// @brief Reconfigures specified logger with new configurations - static Logger* reconfigureLogger(Logger* logger, const Configurations& configurations); - /// @brief Reconfigures logger with new configurations after looking it up using identity - static Logger* reconfigureLogger(const std::string& identity, const Configurations& configurations); - /// @brief Reconfigures logger's single configuration - static Logger* reconfigureLogger(const std::string& identity, ConfigurationType configurationType, - const std::string& value); - /// @brief Reconfigures all the existing loggers with new configurations - static void reconfigureAllLoggers(const Configurations& configurations); - /// @brief Reconfigures single configuration for all the loggers - static inline void reconfigureAllLoggers(ConfigurationType configurationType, const std::string& value) { - reconfigureAllLoggers(Level::Global, configurationType, value); - } - /// @brief Reconfigures single configuration for all the loggers for specified level - static void reconfigureAllLoggers(Level level, ConfigurationType configurationType, - const std::string& value); - /// @brief Sets default configurations. This configuration is used for future (and conditionally for existing) loggers - static void setDefaultConfigurations(const Configurations& configurations, - bool reconfigureExistingLoggers = false); - /// @brief Returns current default - static const Configurations* defaultConfigurations(void); - /// @brief Returns log stream reference pointer if needed by user - static const base::LogStreamsReferenceMapPtr logStreamsReference(void); - /// @brief Default typed configuration based on existing defaultConf - static base::TypedConfigurations defaultTypedConfigurations(void); - /// @brief Populates all logger IDs in current repository. - /// @param [out] targetList List of fill up. - static std::vector* populateAllLoggerIds(std::vector* targetList); - /// @brief Sets configurations from global configuration file. - static void configureFromGlobal(const char* globalConfigurationFilePath); - /// @brief Configures loggers using command line arg. Ensure you have already set command line args, - /// @return False if invalid argument or argument with no value provided, true if attempted to configure logger. - /// If true is returned that does not mean it has been configured successfully, it only means that it - /// has attempted to configure logger using configuration file provided in argument - static bool configureFromArg(const char* argKey); - /// @brief Flushes all loggers for all levels - Be careful if you dont know how many loggers are registered - static void flushAll(void); - /// @brief Adds logging flag used internally. - static inline void addFlag(LoggingFlag flag) { - ELPP->addFlag(flag); - } - /// @brief Removes logging flag used internally. - static inline void removeFlag(LoggingFlag flag) { - ELPP->removeFlag(flag); - } - /// @brief Determines whether or not certain flag is active - static inline bool hasFlag(LoggingFlag flag) { - return ELPP->hasFlag(flag); - } - /// @brief Adds flag and removes it when scope goes out - class ScopedAddFlag { - public: - ScopedAddFlag(LoggingFlag flag) : m_flag(flag) { - Loggers::addFlag(m_flag); - } - ~ScopedAddFlag(void) { - Loggers::removeFlag(m_flag); - } - private: - LoggingFlag m_flag; - }; - /// @brief Removes flag and add it when scope goes out - class ScopedRemoveFlag { - public: - ScopedRemoveFlag(LoggingFlag flag) : m_flag(flag) { - Loggers::removeFlag(m_flag); - } - ~ScopedRemoveFlag(void) { - Loggers::addFlag(m_flag); - } - private: - LoggingFlag m_flag; - }; - /// @brief Sets hierarchy for logging. Needs to enable logging flag (HierarchicalLogging) - static void setLoggingLevel(Level level) { - ELPP->setLoggingLevel(level); - } - /// @brief Sets verbose level on the fly - static void setVerboseLevel(base::type::VerboseLevel level); - /// @brief Gets current verbose level - static base::type::VerboseLevel verboseLevel(void); - /// @brief Sets vmodules as specified (on the fly) - static void setVModules(const char* modules); - /// @brief Clears vmodules - static void clearVModules(void); -}; -class VersionInfo : base::StaticClass { - public: - /// @brief Current version number - static const std::string version(void); - - /// @brief Release date of current version - static const std::string releaseDate(void); -}; -} // namespace el -#undef VLOG_IS_ON -/// @brief Determines whether verbose logging is on for specified level current file. -#define VLOG_IS_ON(verboseLevel) (ELPP->vRegistry()->allowed(verboseLevel, __FILE__)) -#undef TIMED_BLOCK -#undef TIMED_SCOPE -#undef TIMED_SCOPE_IF -#undef TIMED_FUNC -#undef TIMED_FUNC_IF -#undef ELPP_MIN_UNIT -#if defined(ELPP_PERFORMANCE_MICROSECONDS) -# define ELPP_MIN_UNIT el::base::TimestampUnit::Microsecond -#else -# define ELPP_MIN_UNIT el::base::TimestampUnit::Millisecond -#endif // (defined(ELPP_PERFORMANCE_MICROSECONDS)) -/// @brief Performance tracked scope. Performance gets written when goes out of scope using -/// 'performance' logger. -/// -/// @detail Please note in order to check the performance at a certain time you can use obj->checkpoint(); -/// @see el::base::PerformanceTracker -/// @see el::base::PerformanceTracker::checkpoint -// Note: Do not surround this definition with null macro because of obj instance -#define TIMED_SCOPE_IF(obj, blockname, condition) el::base::type::PerformanceTrackerPtr obj( condition ? \ - new el::base::PerformanceTracker(blockname, ELPP_MIN_UNIT) : nullptr ) -#define TIMED_SCOPE(obj, blockname) TIMED_SCOPE_IF(obj, blockname, true) -#define TIMED_BLOCK(obj, blockName) for (struct { int i; el::base::type::PerformanceTrackerPtr timer; } obj = { 0, \ - el::base::type::PerformanceTrackerPtr(new el::base::PerformanceTracker(blockName, ELPP_MIN_UNIT)) }; obj.i < 1; ++obj.i) -/// @brief Performance tracked function. Performance gets written when goes out of scope using -/// 'performance' logger. -/// -/// @detail Please note in order to check the performance at a certain time you can use obj->checkpoint(); -/// @see el::base::PerformanceTracker -/// @see el::base::PerformanceTracker::checkpoint -#define TIMED_FUNC_IF(obj,condition) TIMED_SCOPE_IF(obj, ELPP_FUNC, condition) -#define TIMED_FUNC(obj) TIMED_SCOPE(obj, ELPP_FUNC) -#undef PERFORMANCE_CHECKPOINT -#undef PERFORMANCE_CHECKPOINT_WITH_ID -#define PERFORMANCE_CHECKPOINT(obj) obj->checkpoint(std::string(), __FILE__, __LINE__, ELPP_FUNC) -#define PERFORMANCE_CHECKPOINT_WITH_ID(obj, id) obj->checkpoint(id, __FILE__, __LINE__, ELPP_FUNC) -#undef ELPP_COUNTER -#undef ELPP_COUNTER_POS -/// @brief Gets hit counter for file/line -#define ELPP_COUNTER (ELPP->hitCounters()->getCounter(__FILE__, __LINE__)) -/// @brief Gets hit counter position for file/line, -1 if not registered yet -#define ELPP_COUNTER_POS (ELPP_COUNTER == nullptr ? -1 : ELPP_COUNTER->hitCounts()) -// Undef levels to support LOG(LEVEL) -#undef INFO -#undef WARNING -#undef DEBUG -#undef ERROR -#undef FATAL -#undef TRACE -#undef VERBOSE -// Undef existing -#undef CINFO -#undef CWARNING -#undef CDEBUG -#undef CFATAL -#undef CERROR -#undef CTRACE -#undef CVERBOSE -#undef CINFO_IF -#undef CWARNING_IF -#undef CDEBUG_IF -#undef CERROR_IF -#undef CFATAL_IF -#undef CTRACE_IF -#undef CVERBOSE_IF -#undef CINFO_EVERY_N -#undef CWARNING_EVERY_N -#undef CDEBUG_EVERY_N -#undef CERROR_EVERY_N -#undef CFATAL_EVERY_N -#undef CTRACE_EVERY_N -#undef CVERBOSE_EVERY_N -#undef CINFO_AFTER_N -#undef CWARNING_AFTER_N -#undef CDEBUG_AFTER_N -#undef CERROR_AFTER_N -#undef CFATAL_AFTER_N -#undef CTRACE_AFTER_N -#undef CVERBOSE_AFTER_N -#undef CINFO_N_TIMES -#undef CWARNING_N_TIMES -#undef CDEBUG_N_TIMES -#undef CERROR_N_TIMES -#undef CFATAL_N_TIMES -#undef CTRACE_N_TIMES -#undef CVERBOSE_N_TIMES -// Normal logs -#if ELPP_INFO_LOG -# define CINFO(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Info, dispatchAction, __VA_ARGS__) -#else -# define CINFO(writer, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_INFO_LOG -#if ELPP_WARNING_LOG -# define CWARNING(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Warning, dispatchAction, __VA_ARGS__) -#else -# define CWARNING(writer, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_WARNING_LOG -#if ELPP_DEBUG_LOG -# define CDEBUG(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Debug, dispatchAction, __VA_ARGS__) -#else -# define CDEBUG(writer, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_DEBUG_LOG -#if ELPP_ERROR_LOG -# define CERROR(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Error, dispatchAction, __VA_ARGS__) -#else -# define CERROR(writer, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_ERROR_LOG -#if ELPP_FATAL_LOG -# define CFATAL(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Fatal, dispatchAction, __VA_ARGS__) -#else -# define CFATAL(writer, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_FATAL_LOG -#if ELPP_TRACE_LOG -# define CTRACE(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Trace, dispatchAction, __VA_ARGS__) -#else -# define CTRACE(writer, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_TRACE_LOG -#if ELPP_VERBOSE_LOG -# define CVERBOSE(writer, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel)) writer(\ -el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#else -# define CVERBOSE(writer, vlevel, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_VERBOSE_LOG -// Conditional logs -#if ELPP_INFO_LOG -# define CINFO_IF(writer, condition_, dispatchAction, ...) \ -ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Info, dispatchAction, __VA_ARGS__) -#else -# define CINFO_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_INFO_LOG -#if ELPP_WARNING_LOG -# define CWARNING_IF(writer, condition_, dispatchAction, ...)\ -ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Warning, dispatchAction, __VA_ARGS__) -#else -# define CWARNING_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_WARNING_LOG -#if ELPP_DEBUG_LOG -# define CDEBUG_IF(writer, condition_, dispatchAction, ...)\ -ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Debug, dispatchAction, __VA_ARGS__) -#else -# define CDEBUG_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_DEBUG_LOG -#if ELPP_ERROR_LOG -# define CERROR_IF(writer, condition_, dispatchAction, ...)\ -ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Error, dispatchAction, __VA_ARGS__) -#else -# define CERROR_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_ERROR_LOG -#if ELPP_FATAL_LOG -# define CFATAL_IF(writer, condition_, dispatchAction, ...)\ -ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Fatal, dispatchAction, __VA_ARGS__) -#else -# define CFATAL_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_FATAL_LOG -#if ELPP_TRACE_LOG -# define CTRACE_IF(writer, condition_, dispatchAction, ...)\ -ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Trace, dispatchAction, __VA_ARGS__) -#else -# define CTRACE_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_TRACE_LOG -#if ELPP_VERBOSE_LOG -# define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel) && (condition_)) writer( \ -el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) -#else -# define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_VERBOSE_LOG -// Occasional logs -#if ELPP_INFO_LOG -# define CINFO_EVERY_N(writer, occasion, dispatchAction, ...)\ -ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Info, dispatchAction, __VA_ARGS__) -#else -# define CINFO_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_INFO_LOG -#if ELPP_WARNING_LOG -# define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...)\ -ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Warning, dispatchAction, __VA_ARGS__) -#else -# define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_WARNING_LOG -#if ELPP_DEBUG_LOG -# define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...)\ -ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Debug, dispatchAction, __VA_ARGS__) -#else -# define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_DEBUG_LOG -#if ELPP_ERROR_LOG -# define CERROR_EVERY_N(writer, occasion, dispatchAction, ...)\ -ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Error, dispatchAction, __VA_ARGS__) -#else -# define CERROR_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_ERROR_LOG -#if ELPP_FATAL_LOG -# define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...)\ -ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Fatal, dispatchAction, __VA_ARGS__) -#else -# define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_FATAL_LOG -#if ELPP_TRACE_LOG -# define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...)\ -ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Trace, dispatchAction, __VA_ARGS__) -#else -# define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_TRACE_LOG -#if ELPP_VERBOSE_LOG -# define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...)\ -CVERBOSE_IF(writer, ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion), vlevel, dispatchAction, __VA_ARGS__) -#else -# define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_VERBOSE_LOG -// After N logs -#if ELPP_INFO_LOG -# define CINFO_AFTER_N(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__) -#else -# define CINFO_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_INFO_LOG -#if ELPP_WARNING_LOG -# define CWARNING_AFTER_N(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__) -#else -# define CWARNING_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_WARNING_LOG -#if ELPP_DEBUG_LOG -# define CDEBUG_AFTER_N(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__) -#else -# define CDEBUG_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_DEBUG_LOG -#if ELPP_ERROR_LOG -# define CERROR_AFTER_N(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__) -#else -# define CERROR_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_ERROR_LOG -#if ELPP_FATAL_LOG -# define CFATAL_AFTER_N(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__) -#else -# define CFATAL_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_FATAL_LOG -#if ELPP_TRACE_LOG -# define CTRACE_AFTER_N(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__) -#else -# define CTRACE_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_TRACE_LOG -#if ELPP_VERBOSE_LOG -# define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...)\ -CVERBOSE_IF(writer, ELPP->validateAfterNCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__) -#else -# define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_VERBOSE_LOG -// N Times logs -#if ELPP_INFO_LOG -# define CINFO_N_TIMES(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__) -#else -# define CINFO_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_INFO_LOG -#if ELPP_WARNING_LOG -# define CWARNING_N_TIMES(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__) -#else -# define CWARNING_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_WARNING_LOG -#if ELPP_DEBUG_LOG -# define CDEBUG_N_TIMES(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__) -#else -# define CDEBUG_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_DEBUG_LOG -#if ELPP_ERROR_LOG -# define CERROR_N_TIMES(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__) -#else -# define CERROR_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_ERROR_LOG -#if ELPP_FATAL_LOG -# define CFATAL_N_TIMES(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__) -#else -# define CFATAL_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_FATAL_LOG -#if ELPP_TRACE_LOG -# define CTRACE_N_TIMES(writer, n, dispatchAction, ...)\ -ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__) -#else -# define CTRACE_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_TRACE_LOG -#if ELPP_VERBOSE_LOG -# define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...)\ -CVERBOSE_IF(writer, ELPP->validateNTimesCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__) -#else -# define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter() -#endif // ELPP_VERBOSE_LOG -// -// Custom Loggers - Requires (level, dispatchAction, loggerId/s) -// -// undef existing -#undef CLOG -#undef CLOG_VERBOSE -#undef CVLOG -#undef CLOG_IF -#undef CLOG_VERBOSE_IF -#undef CVLOG_IF -#undef CLOG_EVERY_N -#undef CVLOG_EVERY_N -#undef CLOG_AFTER_N -#undef CVLOG_AFTER_N -#undef CLOG_N_TIMES -#undef CVLOG_N_TIMES -// Normal logs -#define CLOG(LEVEL, ...)\ -C##LEVEL(el::base::Writer, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CVLOG(vlevel, ...) CVERBOSE(el::base::Writer, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) -// Conditional logs -#define CLOG_IF(condition, LEVEL, ...)\ -C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CVLOG_IF(condition, vlevel, ...)\ -CVERBOSE_IF(el::base::Writer, condition, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) -// Hit counts based logs -#define CLOG_EVERY_N(n, LEVEL, ...)\ -C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CVLOG_EVERY_N(n, vlevel, ...)\ -CVERBOSE_EVERY_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CLOG_AFTER_N(n, LEVEL, ...)\ -C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CVLOG_AFTER_N(n, vlevel, ...)\ -CVERBOSE_AFTER_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CLOG_N_TIMES(n, LEVEL, ...)\ -C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CVLOG_N_TIMES(n, vlevel, ...)\ -CVERBOSE_N_TIMES(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) -// -// Default Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros -// -// undef existing -#undef LOG -#undef VLOG -#undef LOG_IF -#undef VLOG_IF -#undef LOG_EVERY_N -#undef VLOG_EVERY_N -#undef LOG_AFTER_N -#undef VLOG_AFTER_N -#undef LOG_N_TIMES -#undef VLOG_N_TIMES -#undef ELPP_CURR_FILE_LOGGER_ID -#if defined(ELPP_DEFAULT_LOGGER) -# define ELPP_CURR_FILE_LOGGER_ID ELPP_DEFAULT_LOGGER -#else -# define ELPP_CURR_FILE_LOGGER_ID el::base::consts::kDefaultLoggerId -#endif -#undef ELPP_TRACE -#define ELPP_TRACE CLOG(TRACE, ELPP_CURR_FILE_LOGGER_ID) -// Normal logs -#define LOG(LEVEL) CLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define VLOG(vlevel) CVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID) -// Conditional logs -#define LOG_IF(condition, LEVEL) CLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define VLOG_IF(condition, vlevel) CVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID) -// Hit counts based logs -#define LOG_EVERY_N(n, LEVEL) CLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define VLOG_EVERY_N(n, vlevel) CVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) -#define LOG_AFTER_N(n, LEVEL) CLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define VLOG_AFTER_N(n, vlevel) CVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) -#define LOG_N_TIMES(n, LEVEL) CLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define VLOG_N_TIMES(n, vlevel) CVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) -// Generic PLOG() -#undef CPLOG -#undef CPLOG_IF -#undef PLOG -#undef PLOG_IF -#undef DCPLOG -#undef DCPLOG_IF -#undef DPLOG -#undef DPLOG_IF -#define CPLOG(LEVEL, ...)\ -C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define CPLOG_IF(condition, LEVEL, ...)\ -C##LEVEL##_IF(el::base::PErrorWriter, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define DCPLOG(LEVEL, ...)\ -if (ELPP_DEBUG_LOG) C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define DCPLOG_IF(condition, LEVEL, ...)\ -C##LEVEL##_IF(el::base::PErrorWriter, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::NormalLog, __VA_ARGS__) -#define PLOG(LEVEL) CPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define PLOG_IF(condition, LEVEL) CPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DPLOG(LEVEL) DCPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DPLOG_IF(condition, LEVEL) DCPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -// Generic SYSLOG() -#undef CSYSLOG -#undef CSYSLOG_IF -#undef CSYSLOG_EVERY_N -#undef CSYSLOG_AFTER_N -#undef CSYSLOG_N_TIMES -#undef SYSLOG -#undef SYSLOG_IF -#undef SYSLOG_EVERY_N -#undef SYSLOG_AFTER_N -#undef SYSLOG_N_TIMES -#undef DCSYSLOG -#undef DCSYSLOG_IF -#undef DCSYSLOG_EVERY_N -#undef DCSYSLOG_AFTER_N -#undef DCSYSLOG_N_TIMES -#undef DSYSLOG -#undef DSYSLOG_IF -#undef DSYSLOG_EVERY_N -#undef DSYSLOG_AFTER_N -#undef DSYSLOG_N_TIMES -#if defined(ELPP_SYSLOG) -# define CSYSLOG(LEVEL, ...)\ -C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define CSYSLOG_IF(condition, LEVEL, ...)\ -C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define CSYSLOG_EVERY_N(n, LEVEL, ...) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define CSYSLOG_AFTER_N(n, LEVEL, ...) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define CSYSLOG_N_TIMES(n, LEVEL, ...) C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define SYSLOG(LEVEL) CSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId) -# define SYSLOG_IF(condition, LEVEL) CSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId) -# define SYSLOG_EVERY_N(n, LEVEL) CSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId) -# define SYSLOG_AFTER_N(n, LEVEL) CSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId) -# define SYSLOG_N_TIMES(n, LEVEL) CSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId) -# define DCSYSLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define DCSYSLOG_IF(condition, LEVEL, ...)\ -C##LEVEL##_IF(el::base::Writer, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::SysLog, __VA_ARGS__) -# define DCSYSLOG_EVERY_N(n, LEVEL, ...)\ -if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define DCSYSLOG_AFTER_N(n, LEVEL, ...)\ -if (ELPP_DEBUG_LOG) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define DCSYSLOG_N_TIMES(n, LEVEL, ...)\ -if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) -# define DSYSLOG(LEVEL) DCSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId) -# define DSYSLOG_IF(condition, LEVEL) DCSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId) -# define DSYSLOG_EVERY_N(n, LEVEL) DCSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId) -# define DSYSLOG_AFTER_N(n, LEVEL) DCSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId) -# define DSYSLOG_N_TIMES(n, LEVEL) DCSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId) -#else -# define CSYSLOG(LEVEL, ...) el::base::NullWriter() -# define CSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter() -# define CSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter() -# define CSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter() -# define CSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter() -# define SYSLOG(LEVEL) el::base::NullWriter() -# define SYSLOG_IF(condition, LEVEL) el::base::NullWriter() -# define SYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter() -# define SYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter() -# define SYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter() -# define DCSYSLOG(LEVEL, ...) el::base::NullWriter() -# define DCSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter() -# define DCSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter() -# define DCSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter() -# define DCSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter() -# define DSYSLOG(LEVEL) el::base::NullWriter() -# define DSYSLOG_IF(condition, LEVEL) el::base::NullWriter() -# define DSYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter() -# define DSYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter() -# define DSYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter() -#endif // defined(ELPP_SYSLOG) -// -// Custom Debug Only Loggers - Requires (level, loggerId/s) -// -// undef existing -#undef DCLOG -#undef DCVLOG -#undef DCLOG_IF -#undef DCVLOG_IF -#undef DCLOG_EVERY_N -#undef DCVLOG_EVERY_N -#undef DCLOG_AFTER_N -#undef DCVLOG_AFTER_N -#undef DCLOG_N_TIMES -#undef DCVLOG_N_TIMES -// Normal logs -#define DCLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG(LEVEL, __VA_ARGS__) -#define DCLOG_VERBOSE(vlevel, ...) if (ELPP_DEBUG_LOG) CLOG_VERBOSE(vlevel, __VA_ARGS__) -#define DCVLOG(vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG(vlevel, __VA_ARGS__) -// Conditional logs -#define DCLOG_IF(condition, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_IF(condition, LEVEL, __VA_ARGS__) -#define DCVLOG_IF(condition, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_IF(condition, vlevel, __VA_ARGS__) -// Hit counts based logs -#define DCLOG_EVERY_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_EVERY_N(n, LEVEL, __VA_ARGS__) -#define DCVLOG_EVERY_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_EVERY_N(n, vlevel, __VA_ARGS__) -#define DCLOG_AFTER_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_AFTER_N(n, LEVEL, __VA_ARGS__) -#define DCVLOG_AFTER_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_AFTER_N(n, vlevel, __VA_ARGS__) -#define DCLOG_N_TIMES(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_N_TIMES(n, LEVEL, __VA_ARGS__) -#define DCVLOG_N_TIMES(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_N_TIMES(n, vlevel, __VA_ARGS__) -// -// Default Debug Only Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros -// -#if !defined(ELPP_NO_DEBUG_MACROS) -// undef existing -#undef DLOG -#undef DVLOG -#undef DLOG_IF -#undef DVLOG_IF -#undef DLOG_EVERY_N -#undef DVLOG_EVERY_N -#undef DLOG_AFTER_N -#undef DVLOG_AFTER_N -#undef DLOG_N_TIMES -#undef DVLOG_N_TIMES -// Normal logs -#define DLOG(LEVEL) DCLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DVLOG(vlevel) DCVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID) -// Conditional logs -#define DLOG_IF(condition, LEVEL) DCLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DVLOG_IF(condition, vlevel) DCVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID) -// Hit counts based logs -#define DLOG_EVERY_N(n, LEVEL) DCLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DVLOG_EVERY_N(n, vlevel) DCVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) -#define DLOG_AFTER_N(n, LEVEL) DCLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DVLOG_AFTER_N(n, vlevel) DCVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) -#define DLOG_N_TIMES(n, LEVEL) DCLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) -#define DVLOG_N_TIMES(n, vlevel) DCVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) -#endif // defined(ELPP_NO_DEBUG_MACROS) -#if !defined(ELPP_NO_CHECK_MACROS) -// Check macros -#undef CCHECK -#undef CPCHECK -#undef CCHECK_EQ -#undef CCHECK_NE -#undef CCHECK_LT -#undef CCHECK_GT -#undef CCHECK_LE -#undef CCHECK_GE -#undef CCHECK_BOUNDS -#undef CCHECK_NOTNULL -#undef CCHECK_STRCASEEQ -#undef CCHECK_STRCASENE -#undef CHECK -#undef PCHECK -#undef CHECK_EQ -#undef CHECK_NE -#undef CHECK_LT -#undef CHECK_GT -#undef CHECK_LE -#undef CHECK_GE -#undef CHECK_BOUNDS -#undef CHECK_NOTNULL -#undef CHECK_STRCASEEQ -#undef CHECK_STRCASENE -#define CCHECK(condition, ...) CLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] " -#define CPCHECK(condition, ...) CPLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] " -#define CHECK(condition) CCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) -#define PCHECK(condition) CPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) -#define CCHECK_EQ(a, b, ...) CCHECK(a == b, __VA_ARGS__) -#define CCHECK_NE(a, b, ...) CCHECK(a != b, __VA_ARGS__) -#define CCHECK_LT(a, b, ...) CCHECK(a < b, __VA_ARGS__) -#define CCHECK_GT(a, b, ...) CCHECK(a > b, __VA_ARGS__) -#define CCHECK_LE(a, b, ...) CCHECK(a <= b, __VA_ARGS__) -#define CCHECK_GE(a, b, ...) CCHECK(a >= b, __VA_ARGS__) -#define CCHECK_BOUNDS(val, min, max, ...) CCHECK(val >= min && val <= max, __VA_ARGS__) -#define CHECK_EQ(a, b) CCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_NE(a, b) CCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_LT(a, b) CCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_GT(a, b) CCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_LE(a, b) CCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_GE(a, b) CCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_BOUNDS(val, min, max) CCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID) -#define CCHECK_NOTNULL(ptr, ...) CCHECK((ptr) != nullptr, __VA_ARGS__) -#define CCHECK_STREQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \ -<< "Check failed: [" << #str1 << " == " << #str2 << "] " -#define CCHECK_STRNE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \ -<< "Check failed: [" << #str1 << " != " << #str2 << "] " -#define CCHECK_STRCASEEQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \ -<< "Check failed: [" << #str1 << " == " << #str2 << "] " -#define CCHECK_STRCASENE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \ -<< "Check failed: [" << #str1 << " != " << #str2 << "] " -#define CHECK_NOTNULL(ptr) CCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_STREQ(str1, str2) CCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_STRNE(str1, str2) CCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_STRCASEEQ(str1, str2) CCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define CHECK_STRCASENE(str1, str2) CCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#undef DCCHECK -#undef DCCHECK_EQ -#undef DCCHECK_NE -#undef DCCHECK_LT -#undef DCCHECK_GT -#undef DCCHECK_LE -#undef DCCHECK_GE -#undef DCCHECK_BOUNDS -#undef DCCHECK_NOTNULL -#undef DCCHECK_STRCASEEQ -#undef DCCHECK_STRCASENE -#undef DCPCHECK -#undef DCHECK -#undef DCHECK_EQ -#undef DCHECK_NE -#undef DCHECK_LT -#undef DCHECK_GT -#undef DCHECK_LE -#undef DCHECK_GE -#undef DCHECK_BOUNDS_ -#undef DCHECK_NOTNULL -#undef DCHECK_STRCASEEQ -#undef DCHECK_STRCASENE -#undef DPCHECK -#define DCCHECK(condition, ...) if (ELPP_DEBUG_LOG) CCHECK(condition, __VA_ARGS__) -#define DCCHECK_EQ(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_EQ(a, b, __VA_ARGS__) -#define DCCHECK_NE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_NE(a, b, __VA_ARGS__) -#define DCCHECK_LT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LT(a, b, __VA_ARGS__) -#define DCCHECK_GT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GT(a, b, __VA_ARGS__) -#define DCCHECK_LE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LE(a, b, __VA_ARGS__) -#define DCCHECK_GE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GE(a, b, __VA_ARGS__) -#define DCCHECK_BOUNDS(val, min, max, ...) if (ELPP_DEBUG_LOG) CCHECK_BOUNDS(val, min, max, __VA_ARGS__) -#define DCCHECK_NOTNULL(ptr, ...) if (ELPP_DEBUG_LOG) CCHECK_NOTNULL((ptr), __VA_ARGS__) -#define DCCHECK_STREQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STREQ(str1, str2, __VA_ARGS__) -#define DCCHECK_STRNE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRNE(str1, str2, __VA_ARGS__) -#define DCCHECK_STRCASEEQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASEEQ(str1, str2, __VA_ARGS__) -#define DCCHECK_STRCASENE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASENE(str1, str2, __VA_ARGS__) -#define DCPCHECK(condition, ...) if (ELPP_DEBUG_LOG) CPCHECK(condition, __VA_ARGS__) -#define DCHECK(condition) DCCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_EQ(a, b) DCCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_NE(a, b) DCCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_LT(a, b) DCCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_GT(a, b) DCCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_LE(a, b) DCCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_GE(a, b) DCCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_BOUNDS(val, min, max) DCCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_NOTNULL(ptr) DCCHECK_NOTNULL((ptr), ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_STREQ(str1, str2) DCCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_STRNE(str1, str2) DCCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_STRCASEEQ(str1, str2) DCCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define DCHECK_STRCASENE(str1, str2) DCCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) -#define DPCHECK(condition) DCPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) -#endif // defined(ELPP_NO_CHECK_MACROS) -#if defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING) -# define ELPP_USE_DEF_CRASH_HANDLER false -#else -# define ELPP_USE_DEF_CRASH_HANDLER true -#endif // defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING) -#define ELPP_CRASH_HANDLER_INIT -#define ELPP_INIT_EASYLOGGINGPP(val) \ -namespace el { \ -namespace base { \ -el::base::type::StoragePointer elStorage(val); \ -} \ -el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER); \ -} - -#if ELPP_ASYNC_LOGGING -# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\ -new el::base::AsyncDispatchWorker())) -#else -# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()))) -#endif // ELPP_ASYNC_LOGGING -#define INITIALIZE_NULL_EASYLOGGINGPP \ -namespace el {\ -namespace base {\ -el::base::type::StoragePointer elStorage;\ -}\ -el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ -} -#define SHARE_EASYLOGGINGPP(initializedStorage)\ -namespace el {\ -namespace base {\ -el::base::type::StoragePointer elStorage(initializedStorage);\ -}\ -el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ -} - -#if defined(ELPP_UNICODE) -# define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv); std::locale::global(std::locale("")) -#else -# define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv) -#endif // defined(ELPP_UNICODE) -#endif // EASYLOGGINGPP_H diff --git a/hnurm_camera/CameraCalibration/include/tcp_logger.h b/hnurm_camera/CameraCalibration/include/tcp_logger.h deleted file mode 100755 index 994444ca6ef76ae97fc08b8bfcd84954c9021680..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/include/tcp_logger.h +++ /dev/null @@ -1,112 +0,0 @@ -// -// Created by wk on 23-5-21. -// - -#ifndef HNUVISION_TCP_LOGGER_H -#define HNUVISION_TCP_LOGGER_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PORT 1234 -#define QUEUE 20//连接请求队列 - -using namespace std::chrono_literals; - - -class TCP_Logger -{ -public: - TCP_Logger() - { - ss = socket(AF_INET, SOCK_STREAM, 0); - server_sockaddr.sin_family = AF_INET; - server_sockaddr.sin_port = htons(PORT); - server_sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - - if (bind(ss, (struct sockaddr *) &server_sockaddr, sizeof(server_sockaddr)) == -1) - { - perror("bind"); - exit(1); - } - - if (listen(ss, QUEUE) == -1) - { - perror("listen"); - exit(1); - } - - socklen_t length = sizeof(client_sockaddr); - printf("wait for connect\n"); - conn = accept(ss, (struct sockaddr *) &client_sockaddr, &length); - if (conn < 0) - { - perror("connect"); - exit(1); - } - } - - ~TCP_Logger() - { - close(conn); - close(ss); - } - - void update(const std::string &data) - { - if (mtx.try_lock_for(1ms)) - { - send_buf = data + "\n"; - mtx.unlock(); - } - } - - void log() - { - if (mtx.try_lock_for(1ms)) - { - int data_len = send_buf.length(); - if (data_len != 0) - { - if(send(conn, send_buf.c_str(), data_len, 0)<0) - { - perror("send"); - exit(1); - } - send_buf.clear(); - } - mtx.unlock(); - } - } - - void log(const std::string &data) - { - if(send(conn, data.c_str(), data.length(), 0)<0) - { - perror("send"); - exit(1); - } - } - -private: - int ss; - int conn; - - struct sockaddr_in server_sockaddr; - struct sockaddr_in client_sockaddr; - - std::string send_buf; - std::timed_mutex mtx; -}; -#endif//HNUVISION_TCP_LOGGER_H diff --git a/hnurm_camera/CameraCalibration/params/2BDF67015844.yaml b/hnurm_camera/CameraCalibration/params/2BDF67015844.yaml deleted file mode 100755 index 4abee8866c5a43f123d0311af46a59d026129109..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/params/2BDF67015844.yaml +++ /dev/null @@ -1,18 +0,0 @@ -%YAML:1.0 ---- -calibration_time: "2024年03月18日 星期一 17时48分15秒" -# flags: +fix_aspectRatio +fix_principal_point +zero_tangent_dist +fix_k4 +fix_k5 -flags: 6158 -fisheye_model: 0 -camera_matrix: !!opencv-matrix - rows: 3 - cols: 3 - dt: d - data: [ 1.7245231242812490e+03, 0., 6.3950000000000000e+02, 0., - 1.7245231242812490e+03, 3.5950000000000000e+02, 0., 0., 1. ] -distortion_coefficients: !!opencv-matrix - rows: 5 - cols: 1 - dt: d - data: [ -7.7399144521604485e-02, 3.3520598626639680e-01, 0., 0., - 7.5097304240945920e-02 ] diff --git a/hnurm_camera/CameraCalibration/src/Camera.cpp b/hnurm_camera/CameraCalibration/src/Camera.cpp deleted file mode 100755 index b62106107dd6fc60521ec399fba7a1812722a686..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/src/Camera.cpp +++ /dev/null @@ -1,416 +0,0 @@ -#include "Camera.h" -#include "easylogging++.h" -#include -#include -#include -#include -#include -#include - -using namespace cv; -using namespace std; -namespace hnurm -{ - HKcam::HKcam(const cv::FileNode &cfg_node) - { - nRet = MV_OK; - handle = nullptr; - pData = nullptr; - - cfg_node["camera_id"] >> _id; - cfg_node["camera_param_path"] >> _cfg_path; - cfg_node["image_orientation"] >> _nImageOrientation; - cfg_node["video_path"] >> _video_path; - cfg_node["if_record"] >> _if_record; - - - - this->video = cv::VideoCapture(this->_video_path); -// this->video = cv::VideoCapture(0); - - - //没准备视频则打开相机 - if (!this->video.isOpened()) { - if (OpenCam(_id))// here open and config camera - { - CLOG(INFO, "camera") << "Camera " << _id << " opened successfully."; - } else - { - CLOG(ERROR, "camera") << "Camera " << _id << " failed to open!"; - } - - CloseCam(); - - nRet = MV_OK; - handle = nullptr; - pData = nullptr; - // do it again - if (OpenCam(_id))// here open and config camera - { - CLOG(INFO, "camera") << "Camera " << _id << " opened successfully."; - } else - { - CLOG(DEBUG, "camera") << "Camera " << _id << " failed to open!"; - exit(-1); - } - } - } - - HKcam::~HKcam() - { - if (!this->video.isOpened()) { - CloseCam(); - } - } - - void HKcam::SetParam(const std::string &cfg_path) - { - //Get the setParam file - FileStorage CameraParam(cfg_path, FileStorage::READ); - if (!CameraParam.isOpened()) - { - std::cerr << "failed to open CameraParam.xml" << std::endl; - return; - } - - // 宽设置时需考虑步进(16),即设置宽需16的倍数 - int nWidthValue; - CameraParam["nWidthValue"] >> nWidthValue; - nRet = MV_CC_SetIntValue(handle, "Width", nWidthValue); - if (MV_OK == nRet) - printf("set Width = %d OK!\n", nWidthValue); - else - printf("set Width failed! nRet [%x]\n", nRet); - - // 高设置时需考虑步进(2),即设置高需16的倍数 - int nHeightValue; - CameraParam["nHeightValue"] >> nHeightValue; - nRet = MV_CC_SetIntValue(handle, "Height", nHeightValue); - if (MV_OK == nRet) - printf("set height = %d OK!\n", nHeightValue); - else - printf("set height failed! nRet [%x]\n", nRet); - - // 设置水平偏移 - int nOffsetXValue; - CameraParam["nOffsetXValue"] >> nOffsetXValue; - nRet = MV_CC_SetIntValue(handle, "OffsetX", nOffsetXValue); - if (MV_OK == nRet) - printf("set OffsetX = %d OK!\n", nOffsetXValue); - else - printf("set OffsetX failed! nRet [%x]\n", nRet); - - // 设置垂直偏移 - int nOffsetYValue; - CameraParam["nOffsetYValue"] >> nOffsetYValue; - nRet = MV_CC_SetIntValue(handle, "OffsetY", nOffsetYValue); - if (MV_OK == nRet) - printf("set OffsetY = %d OK!\n", nOffsetYValue); - else - printf("set OffsetY failed! nRet [%x]\n", nRet); - - // 设置水平镜像 - bool bSetBoolValue5; - CameraParam["bSetBoolValue5"] >> bSetBoolValue5; - nRet = MV_CC_SetBoolValue(handle, "ReverseX", bSetBoolValue5); - if (MV_OK == nRet) - printf("set ReverseX = %d OK!\n", bSetBoolValue5); - else - printf("set ReverseX Failed! nRet = [%x]\n", nRet); - - // 设置垂直镜像 - bool bSetBoolValue1; - CameraParam["bSetBoolValue1"] >> bSetBoolValue1; - nRet = MV_CC_SetBoolValue(handle, "ReverseY", bSetBoolValue1); - if (MV_OK == nRet) - printf("Set ReverseY = %d OK!\n", bSetBoolValue1); - else - printf("Set ReverseY Failed! nRet = [%x]\n", nRet); - - // 设置像素格式 - int nPixelFormat; - CameraParam["PixelFormat"] >> nPixelFormat; - nRet = MV_CC_SetEnumValue(handle, "PixelFormat", nPixelFormat); - if (MV_OK == nRet) - printf("set PixelFormat = %x OK!\n", nPixelFormat); - else - printf("set PixelFormat failed! nRet [%x]\n", nRet); - - // 设置采集触发帧率 - int nAcquisitionBurstFrameCountValue; - CameraParam["nAcquisitionBurstFrameCountValue"] >> nAcquisitionBurstFrameCountValue; - nRet = MV_CC_SetIntValue(handle, "AcquisitionBurstFrameCount", - nAcquisitionBurstFrameCountValue); - if (MV_OK == nRet) - printf("set AcquisitionBurstFrameCount = %d OK!\n", nAcquisitionBurstFrameCountValue); - else - printf("set AcquisitionBurstFrameCount failed! nRet [%x]\n", nRet); - - // 设置采集帧率 - float fFPSValue; - CameraParam["fFPSValue"] >> fFPSValue; - nRet = MV_CC_SetFloatValue(handle, "AcquisitionFrameRate", fFPSValue); - - if (MV_OK == nRet) - printf("set AcquisitionFrameRate = %f OK!\n", fFPSValue); - else - printf("set AcquisitionFrameRate failed! nRet [%x]\n", nRet); - - // 设置使能采集帧率控制 - bool bSetBoolValue3; - CameraParam["bSetBoolValue3"] >> bSetBoolValue3; - nRet = MV_CC_SetBoolValue(handle, "AcquisitionFrameRateEnable", bSetBoolValue3); - if (MV_OK == nRet) - printf("Set AcquisitionFrameRateEnable = %d OK!\n", bSetBoolValue3); - else - printf("Set AcquisitionFrameRateEnable Failed! nRet = [%x]\n", nRet); - - // 设置曝光时间 - float fExposureTime; - CameraParam["fExposureTime"] >> fExposureTime; - nRet = MV_CC_SetFloatValue(handle, "ExposureTime", fExposureTime); - if (MV_OK == nRet) - printf("set ExposureTime = %f OK!\n", fExposureTime); - else - printf("set ExposureTime failed! nRet [%x]\n", nRet); - - // 设置增益 - float fGainValue; - CameraParam["fGainValue"] >> fGainValue; - nRet = MV_CC_SetFloatValue(handle, "Gain", fGainValue); - if (MV_OK == nRet) - printf("set Gain = %f OK!\n", fGainValue); - else - printf("set Gain failed! nRet [%x]\n", nRet); - - // 设置黑电平 - int nBlackLevelValue; - CameraParam["nBlackLevelValue"] >> nBlackLevelValue; - nRet = MV_CC_SetIntValue(handle, "BlackLevel", nBlackLevelValue); - if (MV_OK == nRet) - printf("set BlackLevel = %d OK!\n", nBlackLevelValue); - else - printf("set BlackLevel failed! nRet [%x]\n", nRet); - - // 设置黑电平使能 - bool bSetBoolValue2; - CameraParam["bSetBoolValue2"] >> bSetBoolValue2; - nRet = MV_CC_SetBoolValue(handle, "BlackLevelEnable", bSetBoolValue2); - if (MV_OK == nRet) - printf("Set BlackLevelEnable = %d OK!\n", bSetBoolValue2); - else - printf("Set BlackLevelEnable Failed! nRet = [%x]\n", nRet); - - //设置录制器 - auto now = chrono::system_clock::now(); - auto now_c = chrono::system_clock::to_time_t(now); - stringstream ss; - ss << put_time(localtime(&now_c), "%Y-%m-%d_%H-%M-%S"); - string time_str = ss.str(); - this->video_writer = cv::VideoWriter(time_str+".avi",cv::VideoWriter::fourcc('X', 'V', 'I', 'D'), 60, cv::Size(nWidthValue, nHeightValue)); - } - - bool HKcam::OpenCam(const string &cameraID) - { - // nRet = MV_OK; - MV_CC_DEVICE_INFO_LIST stDeviceList; - memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST)); - // 枚举设备 - // enum device - nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &stDeviceList); - if (!stDeviceList.nDeviceNum) - { - printf("Find No Devices! nRet = [%x]\n", nRet); - return false; - } - - //select the first camera connected - unsigned int nIndex = 0; - - while (true) - { - // 选择设备并创建句柄 - // select device and create handle - nRet = MV_CC_CreateHandle(&handle, stDeviceList.pDeviceInfo[nIndex]); - if (MV_OK != nRet) - { - printf("MV_CC_CreateHandle fail! nRet [%x]\n", nRet); - return false; - } - - // 获取设备id - // get device id - stringstream ss; - ss << stDeviceList.pDeviceInfo[nIndex]->SpecialInfo.stUsb3VInfo.chDeviceGUID; - ss >> _id; - cout << "camera id " << _id << endl; - - // 若指定了相机id,则判断是否为指定相机 - // if camera id is specified, check if it is the specified camera - if (!cameraID.empty()) - { - if (cameraID != _id)// 若不是指定相机,则关闭句柄并继续枚举 - { - printf("camera id %s not matched to desired %s\n", _id.c_str(), cameraID.c_str()); - MV_CC_CloseDevice(handle); - MV_CC_DestroyHandle(handle); - nIndex++; - if (nIndex >= stDeviceList.nDeviceNum)// 若已枚举完所有相机,则返回 - { - printf("Find No Devices!\n"); - return false; - } - continue; - } else - { - printf("ready to open camera %s\n", _id.c_str()); - } - } else - { - printf("camera id not set, ready to open camera %s\n", _id.c_str()); - } - - // 打开设备 - // open device - nRet = MV_CC_OpenDevice(handle); - if (MV_OK != nRet) - { - printf("MV_CC_OpenDevice fail! nRet [%x]\n", nRet); - return false; - } - - // 设置触发模式为off - // set trigger mode as off - nRet = MV_CC_SetEnumValue(handle, "TriggerMode", 0); - if (MV_OK != nRet) - { - printf("MV_CC_SetTriggerMode fail! nRet [%x]\n", nRet); - return false; - } - - // set param - // 设置参数 - SetParam(_cfg_path); - - // Get payload size - memset(&stParam, 0, sizeof(MVCC_INTVALUE)); - nRet = MV_CC_GetIntValue(handle, "PayloadSize", &stParam); - if (MV_OK != nRet) - { - printf("Get PayloadSize fail! nRet [0x%x]\n", nRet); - return false; - } - - //s tart grab stream - nRet = MV_CC_StartGrabbing(handle); - if (MV_OK != nRet) - { - printf("Start Grabbing fail! nRet [0x%x]\n", nRet); - return false; - } - - // check - stImageInfo = {0}; - memset(&stImageInfo, 0, sizeof(MV_FRAME_OUT_INFO_EX)); - pData = (unsigned char *) malloc(sizeof(unsigned char) * stParam.nCurValue); - if (NULL == pData) - { - std::cout << "can't get size of a frame!" << std::endl; - return false; - } - - return true; - } - } - - bool HKcam::CloseCam() - { - try { - // 停止取流 - // end grab image - nRet = MV_CC_StopGrabbing(handle); - if (MV_OK != nRet) - { - printf("MV_CC_StopGrabbing fail! nRet [%x]\n", nRet); - return false; - } - // 关闭设备 - // close device - nRet = MV_CC_CloseDevice(handle); - if (MV_OK != nRet) - { - printf("MV_CC_CloseDevice fail! nRet [%x]\n", nRet); - return false; - } - // 销毁句柄 - // destroy handle - nRet = MV_CC_DestroyHandle(handle); - if (MV_OK != nRet) - { - printf("MV_CC_DestroyHandle fail! nRet [%x]\n", nRet); - return false; - } - return true; - } catch (...) - { - printf("something went wrong..."); - return false; - } - } - - bool HKcam::SendFrame(ImgInfo &img) - { - nRet = MV_OK; - // todo get time stamp for imu alignment - nRet = MV_CC_GetOneFrameTimeout(handle, pData, stParam.nCurValue, &stImageInfo, 100); - img.time_stamp = std::chrono::steady_clock::now(); - - if (nRet != MV_OK) - { - printf("No data[0x%x]\n", nRet); - return false; - } - - img.img = cv::Mat(stImageInfo.nHeight, stImageInfo.nWidth, CV_8UC3, pData); - // cvtColor(tmp_bayer, img.img, cv::COLOR_BayerGB2RGB); - - // 根据参数对img旋转 - switch (_nImageOrientation) - { - case 0: - break; - case 1: - cv::rotate(img.img, img.img, cv::ROTATE_90_CLOCKWISE); - break; - case 2: - cv::rotate(img.img, img.img, cv::ROTATE_180); - break; - case 3: - cv::rotate(img.img, img.img, cv::ROTATE_90_COUNTERCLOCKWISE); - break; - } - return true; - } - - string HKcam::GetCamName() - { - return _id; - } - - //循环播放视频 - bool HKcam::SendFromVideoCapture(ImgInfo &img) - { - bool ret = this->video.isOpened(); - if (ret){ - static int count = 0; - this->video >> img.img; - count++; - if (count == this->video.get(cv::CAP_PROP_FRAME_COUNT)){ - count = 0 ; - this->video.set(cv::CAP_PROP_POS_FRAMES,0); - } - } - return ret; - } - -}// namespace hnurm diff --git a/hnurm_camera/CameraCalibration/src/easylogging++.cc b/hnurm_camera/CameraCalibration/src/easylogging++.cc deleted file mode 100755 index 4a8d92731d3d3687faa4f3d91cdb25d9ad5d28db..0000000000000000000000000000000000000000 --- a/hnurm_camera/CameraCalibration/src/easylogging++.cc +++ /dev/null @@ -1,3120 +0,0 @@ -// -// Bismillah ar-Rahmaan ar-Raheem -// -// Easylogging++ v9.96.7 -// Cross-platform logging library for C++ applications -// -// Copyright (c) 2012-2018 Amrayn Web Services -// Copyright (c) 2012-2018 @abumusamq -// -// This library is released under the MIT Licence. -// https://github.com/amrayn/easyloggingpp/blob/master/LICENSE -// -// https://amrayn.com -// http://muflihun.com -// - -#include "easylogging++.h" - -#if defined(AUTO_INITIALIZE_EASYLOGGINGPP) -INITIALIZE_EASYLOGGINGPP -#endif - -namespace el { - -// el::base -namespace base { -// el::base::consts -namespace consts { - -// Level log values - These are values that are replaced in place of %level format specifier -// Extra spaces after format specifiers are only for readability purposes in log files -static const base::type::char_t* kInfoLevelLogValue = ELPP_LITERAL("INFO"); -static const base::type::char_t* kDebugLevelLogValue = ELPP_LITERAL("DEBUG"); -static const base::type::char_t* kWarningLevelLogValue = ELPP_LITERAL("WARNING"); -static const base::type::char_t* kErrorLevelLogValue = ELPP_LITERAL("ERROR"); -static const base::type::char_t* kFatalLevelLogValue = ELPP_LITERAL("FATAL"); -static const base::type::char_t* kVerboseLevelLogValue = - ELPP_LITERAL("VERBOSE"); // will become VERBOSE-x where x = verbose level -static const base::type::char_t* kTraceLevelLogValue = ELPP_LITERAL("TRACE"); -static const base::type::char_t* kInfoLevelShortLogValue = ELPP_LITERAL("I"); -static const base::type::char_t* kDebugLevelShortLogValue = ELPP_LITERAL("D"); -static const base::type::char_t* kWarningLevelShortLogValue = ELPP_LITERAL("W"); -static const base::type::char_t* kErrorLevelShortLogValue = ELPP_LITERAL("E"); -static const base::type::char_t* kFatalLevelShortLogValue = ELPP_LITERAL("F"); -static const base::type::char_t* kVerboseLevelShortLogValue = ELPP_LITERAL("V"); -static const base::type::char_t* kTraceLevelShortLogValue = ELPP_LITERAL("T"); -// Format specifiers - These are used to define log format -static const base::type::char_t* kAppNameFormatSpecifier = ELPP_LITERAL("%app"); -static const base::type::char_t* kLoggerIdFormatSpecifier = ELPP_LITERAL("%logger"); -static const base::type::char_t* kThreadIdFormatSpecifier = ELPP_LITERAL("%thread"); -static const base::type::char_t* kSeverityLevelFormatSpecifier = ELPP_LITERAL("%level"); -static const base::type::char_t* kSeverityLevelShortFormatSpecifier = ELPP_LITERAL("%levshort"); -static const base::type::char_t* kDateTimeFormatSpecifier = ELPP_LITERAL("%datetime"); -static const base::type::char_t* kLogFileFormatSpecifier = ELPP_LITERAL("%file"); -static const base::type::char_t* kLogFileBaseFormatSpecifier = ELPP_LITERAL("%fbase"); -static const base::type::char_t* kLogLineFormatSpecifier = ELPP_LITERAL("%line"); -static const base::type::char_t* kLogLocationFormatSpecifier = ELPP_LITERAL("%loc"); -static const base::type::char_t* kLogFunctionFormatSpecifier = ELPP_LITERAL("%func"); -static const base::type::char_t* kCurrentUserFormatSpecifier = ELPP_LITERAL("%user"); -static const base::type::char_t* kCurrentHostFormatSpecifier = ELPP_LITERAL("%host"); -static const base::type::char_t* kMessageFormatSpecifier = ELPP_LITERAL("%msg"); -static const base::type::char_t* kVerboseLevelFormatSpecifier = ELPP_LITERAL("%vlevel"); -static const char* kDateTimeFormatSpecifierForFilename = "%datetime"; -// Date/time -static const char* kDays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; -static const char* kDaysAbbrev[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -static const char* kMonths[12] = { "January", "February", "March", "April", "May", "June", "July", "August", - "September", "October", "November", "December" - }; -static const char* kMonthsAbbrev[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -static const char* kDefaultDateTimeFormat = "%Y-%M-%d %H:%m:%s,%g"; -static const char* kDefaultDateTimeFormatInFilename = "%Y-%M-%d_%H-%m"; -static const int kYearBase = 1900; -static const char* kAm = "AM"; -static const char* kPm = "PM"; -// Miscellaneous constants - -static const char* kNullPointer = "nullptr"; -#if ELPP_VARIADIC_TEMPLATES_SUPPORTED -#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED -static const base::type::VerboseLevel kMaxVerboseLevel = 9; -static const char* kUnknownUser = "unknown-user"; -static const char* kUnknownHost = "unknown-host"; - - -//---------------- DEFAULT LOG FILE ----------------------- - -#if defined(ELPP_NO_DEFAULT_LOG_FILE) -# if ELPP_OS_UNIX -static const char* kDefaultLogFile = "/dev/null"; -# elif ELPP_OS_WINDOWS -static const char* kDefaultLogFile = "nul"; -# endif // ELPP_OS_UNIX -#elif defined(ELPP_DEFAULT_LOG_FILE) -static const char* kDefaultLogFile = ELPP_DEFAULT_LOG_FILE; -#else -static const char* kDefaultLogFile = "myeasylog.log"; -#endif // defined(ELPP_NO_DEFAULT_LOG_FILE) - - -#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) -static const char* kDefaultLogFileParam = "--default-log-file"; -#endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) -#if defined(ELPP_LOGGING_FLAGS_FROM_ARG) -static const char* kLoggingFlagsParam = "--logging-flags"; -#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG) -static const char* kValidLoggerIdSymbols = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._"; -static const char* kConfigurationComment = "##"; -static const char* kConfigurationLevel = "*"; -static const char* kConfigurationLoggerId = "--"; -} -// el::base::utils -namespace utils { - -/// @brief Aborts application due with user-defined status -static void abort(int status, const std::string& reason) { - // Both status and reason params are there for debugging with tools like gdb etc - ELPP_UNUSED(status); - ELPP_UNUSED(reason); -#if defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG) - // Ignore msvc critical error dialog - break instead (on debug mode) - _asm int 3 -#else - ::abort(); -#endif // defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG) -} - -} // namespace utils -} // namespace base - -// el - -// LevelHelper - -const char* LevelHelper::convertToString(Level level) { - // Do not use switch over strongly typed enums because Intel C++ compilers dont support them yet. - if (level == Level::Global) return "GLOBAL"; - if (level == Level::Debug) return "DEBUG"; - if (level == Level::Info) return "INFO"; - if (level == Level::Warning) return "WARNING"; - if (level == Level::Error) return "ERROR"; - if (level == Level::Fatal) return "FATAL"; - if (level == Level::Verbose) return "VERBOSE"; - if (level == Level::Trace) return "TRACE"; - return "UNKNOWN"; -} - -struct StringToLevelItem { - const char* levelString; - Level level; -}; - -static struct StringToLevelItem stringToLevelMap[] = { - { "global", Level::Global }, - { "debug", Level::Debug }, - { "info", Level::Info }, - { "warning", Level::Warning }, - { "error", Level::Error }, - { "fatal", Level::Fatal }, - { "verbose", Level::Verbose }, - { "trace", Level::Trace } -}; - -Level LevelHelper::convertFromString(const char* levelStr) { - for (auto& item : stringToLevelMap) { - if (base::utils::Str::cStringCaseEq(levelStr, item.levelString)) { - return item.level; - } - } - return Level::Unknown; -} - -void LevelHelper::forEachLevel(base::type::EnumType* startIndex, const std::function& fn) { - base::type::EnumType lIndexMax = LevelHelper::kMaxValid; - do { - if (fn()) { - break; - } - *startIndex = static_cast(*startIndex << 1); - } while (*startIndex <= lIndexMax); -} - -// ConfigurationTypeHelper - -const char* ConfigurationTypeHelper::convertToString(ConfigurationType configurationType) { - // Do not use switch over strongly typed enums because Intel C++ compilers dont support them yet. - if (configurationType == ConfigurationType::Enabled) return "ENABLED"; - if (configurationType == ConfigurationType::Filename) return "FILENAME"; - if (configurationType == ConfigurationType::Format) return "FORMAT"; - if (configurationType == ConfigurationType::ToFile) return "TO_FILE"; - if (configurationType == ConfigurationType::ToStandardOutput) return "TO_STANDARD_OUTPUT"; - if (configurationType == ConfigurationType::SubsecondPrecision) return "SUBSECOND_PRECISION"; - if (configurationType == ConfigurationType::PerformanceTracking) return "PERFORMANCE_TRACKING"; - if (configurationType == ConfigurationType::MaxLogFileSize) return "MAX_LOG_FILE_SIZE"; - if (configurationType == ConfigurationType::LogFlushThreshold) return "LOG_FLUSH_THRESHOLD"; - return "UNKNOWN"; -} - -struct ConfigurationStringToTypeItem { - const char* configString; - ConfigurationType configType; -}; - -static struct ConfigurationStringToTypeItem configStringToTypeMap[] = { - { "enabled", ConfigurationType::Enabled }, - { "to_file", ConfigurationType::ToFile }, - { "to_standard_output", ConfigurationType::ToStandardOutput }, - { "format", ConfigurationType::Format }, - { "filename", ConfigurationType::Filename }, - { "subsecond_precision", ConfigurationType::SubsecondPrecision }, - { "milliseconds_width", ConfigurationType::MillisecondsWidth }, - { "performance_tracking", ConfigurationType::PerformanceTracking }, - { "max_log_file_size", ConfigurationType::MaxLogFileSize }, - { "log_flush_threshold", ConfigurationType::LogFlushThreshold }, -}; - -ConfigurationType ConfigurationTypeHelper::convertFromString(const char* configStr) { - for (auto& item : configStringToTypeMap) { - if (base::utils::Str::cStringCaseEq(configStr, item.configString)) { - return item.configType; - } - } - return ConfigurationType::Unknown; -} - -void ConfigurationTypeHelper::forEachConfigType(base::type::EnumType* startIndex, const std::function& fn) { - base::type::EnumType cIndexMax = ConfigurationTypeHelper::kMaxValid; - do { - if (fn()) { - break; - } - *startIndex = static_cast(*startIndex << 1); - } while (*startIndex <= cIndexMax); -} - -// Configuration - -Configuration::Configuration(const Configuration& c) : - m_level(c.m_level), - m_configurationType(c.m_configurationType), - m_value(c.m_value) { -} - -Configuration& Configuration::operator=(const Configuration& c) { - if (&c != this) { - m_level = c.m_level; - m_configurationType = c.m_configurationType; - m_value = c.m_value; - } - return *this; -} - -/// @brief Full constructor used to sets value of configuration -Configuration::Configuration(Level level, ConfigurationType configurationType, const std::string& value) : - m_level(level), - m_configurationType(configurationType), - m_value(value) { -} - -void Configuration::log(el::base::type::ostream_t& os) const { - os << LevelHelper::convertToString(m_level) - << ELPP_LITERAL(" ") << ConfigurationTypeHelper::convertToString(m_configurationType) - << ELPP_LITERAL(" = ") << m_value.c_str(); -} - -/// @brief Used to find configuration from configuration (pointers) repository. Avoid using it. -Configuration::Predicate::Predicate(Level level, ConfigurationType configurationType) : - m_level(level), - m_configurationType(configurationType) { -} - -bool Configuration::Predicate::operator()(const Configuration* conf) const { - return ((conf != nullptr) && (conf->level() == m_level) && (conf->configurationType() == m_configurationType)); -} - -// Configurations - -Configurations::Configurations(void) : - m_configurationFile(std::string()), - m_isFromFile(false) { -} - -Configurations::Configurations(const std::string& configurationFile, bool useDefaultsForRemaining, - Configurations* base) : - m_configurationFile(configurationFile), - m_isFromFile(false) { - parseFromFile(configurationFile, base); - if (useDefaultsForRemaining) { - setRemainingToDefault(); - } -} - -bool Configurations::parseFromFile(const std::string& configurationFile, Configurations* base) { - // We initial assertion with true because if we have assertion disabled, we want to pass this - // check and if assertion is enabled we will have values re-assigned any way. - bool assertionPassed = true; - ELPP_ASSERT((assertionPassed = base::utils::File::pathExists(configurationFile.c_str(), true)) == true, - "Configuration file [" << configurationFile << "] does not exist!"); - if (!assertionPassed) { - return false; - } - bool success = Parser::parseFromFile(configurationFile, this, base); - m_isFromFile = success; - return success; -} - -bool Configurations::parseFromText(const std::string& configurationsString, Configurations* base) { - bool success = Parser::parseFromText(configurationsString, this, base); - if (success) { - m_isFromFile = false; - } - return success; -} - -void Configurations::setFromBase(Configurations* base) { - if (base == nullptr || base == this) { - return; - } - base::threading::ScopedLock scopedLock(base->lock()); - for (Configuration*& conf : base->list()) { - set(conf); - } -} - -bool Configurations::hasConfiguration(ConfigurationType configurationType) { - base::type::EnumType lIndex = LevelHelper::kMinValid; - bool result = false; - LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { - if (hasConfiguration(LevelHelper::castFromInt(lIndex), configurationType)) { - result = true; - } - return result; - }); - return result; -} - -bool Configurations::hasConfiguration(Level level, ConfigurationType configurationType) { - base::threading::ScopedLock scopedLock(lock()); -#if ELPP_COMPILER_INTEL - // We cant specify template types here, Intel C++ throws compilation error - // "error: type name is not allowed" - return RegistryWithPred::get(level, configurationType) != nullptr; -#else - return RegistryWithPred::get(level, configurationType) != nullptr; -#endif // ELPP_COMPILER_INTEL -} - -void Configurations::set(Level level, ConfigurationType configurationType, const std::string& value) { - base::threading::ScopedLock scopedLock(lock()); - unsafeSet(level, configurationType, value); // This is not unsafe anymore as we have locked mutex - if (level == Level::Global) { - unsafeSetGlobally(configurationType, value, false); // Again this is not unsafe either - } -} - -void Configurations::set(Configuration* conf) { - if (conf == nullptr) { - return; - } - set(conf->level(), conf->configurationType(), conf->value()); -} - -void Configurations::setToDefault(void) { - setGlobally(ConfigurationType::Enabled, std::string("true"), true); - setGlobally(ConfigurationType::Filename, std::string(base::consts::kDefaultLogFile), true); -#if defined(ELPP_NO_LOG_TO_FILE) - setGlobally(ConfigurationType::ToFile, std::string("false"), true); -#else - setGlobally(ConfigurationType::ToFile, std::string("true"), true); -#endif // defined(ELPP_NO_LOG_TO_FILE) - setGlobally(ConfigurationType::ToStandardOutput, std::string("true"), true); - setGlobally(ConfigurationType::SubsecondPrecision, std::string("3"), true); - setGlobally(ConfigurationType::PerformanceTracking, std::string("true"), true); - setGlobally(ConfigurationType::MaxLogFileSize, std::string("0"), true); - setGlobally(ConfigurationType::LogFlushThreshold, std::string("0"), true); - - setGlobally(ConfigurationType::Format, std::string("%datetime %level [%logger] %msg"), true); - set(Level::Debug, ConfigurationType::Format, - std::string("%datetime %level [%logger] [%user@%host] [%func] [%loc] %msg")); - // INFO and WARNING are set to default by Level::Global - set(Level::Error, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); - set(Level::Fatal, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); - set(Level::Verbose, ConfigurationType::Format, std::string("%datetime %level-%vlevel [%logger] %msg")); - set(Level::Trace, ConfigurationType::Format, std::string("%datetime %level [%logger] [%func] [%loc] %msg")); -} - -void Configurations::setRemainingToDefault(void) { - base::threading::ScopedLock scopedLock(lock()); -#if defined(ELPP_NO_LOG_TO_FILE) - unsafeSetIfNotExist(Level::Global, ConfigurationType::Enabled, std::string("false")); -#else - unsafeSetIfNotExist(Level::Global, ConfigurationType::Enabled, std::string("true")); -#endif // defined(ELPP_NO_LOG_TO_FILE) - unsafeSetIfNotExist(Level::Global, ConfigurationType::Filename, std::string(base::consts::kDefaultLogFile)); - unsafeSetIfNotExist(Level::Global, ConfigurationType::ToStandardOutput, std::string("true")); - unsafeSetIfNotExist(Level::Global, ConfigurationType::SubsecondPrecision, std::string("3")); - unsafeSetIfNotExist(Level::Global, ConfigurationType::PerformanceTracking, std::string("true")); - unsafeSetIfNotExist(Level::Global, ConfigurationType::MaxLogFileSize, std::string("0")); - unsafeSetIfNotExist(Level::Global, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); - unsafeSetIfNotExist(Level::Debug, ConfigurationType::Format, - std::string("%datetime %level [%logger] [%user@%host] [%func] [%loc] %msg")); - // INFO and WARNING are set to default by Level::Global - unsafeSetIfNotExist(Level::Error, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); - unsafeSetIfNotExist(Level::Fatal, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); - unsafeSetIfNotExist(Level::Verbose, ConfigurationType::Format, std::string("%datetime %level-%vlevel [%logger] %msg")); - unsafeSetIfNotExist(Level::Trace, ConfigurationType::Format, - std::string("%datetime %level [%logger] [%func] [%loc] %msg")); -} - -bool Configurations::Parser::parseFromFile(const std::string& configurationFile, Configurations* sender, - Configurations* base) { - sender->setFromBase(base); - std::ifstream fileStream_(configurationFile.c_str(), std::ifstream::in); - ELPP_ASSERT(fileStream_.is_open(), "Unable to open configuration file [" << configurationFile << "] for parsing."); - bool parsedSuccessfully = false; - std::string line = std::string(); - Level currLevel = Level::Unknown; - std::string currConfigStr = std::string(); - std::string currLevelStr = std::string(); - while (fileStream_.good()) { - std::getline(fileStream_, line); - parsedSuccessfully = parseLine(&line, &currConfigStr, &currLevelStr, &currLevel, sender); - ELPP_ASSERT(parsedSuccessfully, "Unable to parse configuration line: " << line); - } - return parsedSuccessfully; -} - -bool Configurations::Parser::parseFromText(const std::string& configurationsString, Configurations* sender, - Configurations* base) { - sender->setFromBase(base); - bool parsedSuccessfully = false; - std::stringstream ss(configurationsString); - std::string line = std::string(); - Level currLevel = Level::Unknown; - std::string currConfigStr = std::string(); - std::string currLevelStr = std::string(); - while (std::getline(ss, line)) { - parsedSuccessfully = parseLine(&line, &currConfigStr, &currLevelStr, &currLevel, sender); - ELPP_ASSERT(parsedSuccessfully, "Unable to parse configuration line: " << line); - } - return parsedSuccessfully; -} - -void Configurations::Parser::ignoreComments(std::string* line) { - std::size_t foundAt = 0; - std::size_t quotesStart = line->find("\""); - std::size_t quotesEnd = std::string::npos; - if (quotesStart != std::string::npos) { - quotesEnd = line->find("\"", quotesStart + 1); - while (quotesEnd != std::string::npos && line->at(quotesEnd - 1) == '\\') { - // Do not erase slash yet - we will erase it in parseLine(..) while loop - quotesEnd = line->find("\"", quotesEnd + 2); - } - } - if ((foundAt = line->find(base::consts::kConfigurationComment)) != std::string::npos) { - if (foundAt < quotesEnd) { - foundAt = line->find(base::consts::kConfigurationComment, quotesEnd + 1); - } - *line = line->substr(0, foundAt); - } -} - -bool Configurations::Parser::isLevel(const std::string& line) { - return base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationLevel)); -} - -bool Configurations::Parser::isComment(const std::string& line) { - return base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationComment)); -} - -bool Configurations::Parser::isConfig(const std::string& line) { - std::size_t assignment = line.find('='); - return line != "" && - ((line[0] >= 'A' && line[0] <= 'Z') || (line[0] >= 'a' && line[0] <= 'z')) && - (assignment != std::string::npos) && - (line.size() > assignment); -} - -bool Configurations::Parser::parseLine(std::string* line, std::string* currConfigStr, std::string* currLevelStr, - Level* currLevel, - Configurations* conf) { - ConfigurationType currConfig = ConfigurationType::Unknown; - std::string currValue = std::string(); - *line = base::utils::Str::trim(*line); - if (isComment(*line)) return true; - ignoreComments(line); - *line = base::utils::Str::trim(*line); - if (line->empty()) { - // Comment ignored - return true; - } - if (isLevel(*line)) { - if (line->size() <= 2) { - return true; - } - *currLevelStr = line->substr(1, line->size() - 2); - *currLevelStr = base::utils::Str::toUpper(*currLevelStr); - *currLevelStr = base::utils::Str::trim(*currLevelStr); - *currLevel = LevelHelper::convertFromString(currLevelStr->c_str()); - return true; - } - if (isConfig(*line)) { - std::size_t assignment = line->find('='); - *currConfigStr = line->substr(0, assignment); - *currConfigStr = base::utils::Str::toUpper(*currConfigStr); - *currConfigStr = base::utils::Str::trim(*currConfigStr); - currConfig = ConfigurationTypeHelper::convertFromString(currConfigStr->c_str()); - currValue = line->substr(assignment + 1); - currValue = base::utils::Str::trim(currValue); - std::size_t quotesStart = currValue.find("\"", 0); - std::size_t quotesEnd = std::string::npos; - if (quotesStart != std::string::npos) { - quotesEnd = currValue.find("\"", quotesStart + 1); - while (quotesEnd != std::string::npos && currValue.at(quotesEnd - 1) == '\\') { - currValue = currValue.erase(quotesEnd - 1, 1); - quotesEnd = currValue.find("\"", quotesEnd + 2); - } - } - if (quotesStart != std::string::npos && quotesEnd != std::string::npos) { - // Quote provided - check and strip if valid - ELPP_ASSERT((quotesStart < quotesEnd), "Configuration error - No ending quote found in [" - << currConfigStr << "]"); - ELPP_ASSERT((quotesStart + 1 != quotesEnd), "Empty configuration value for [" << currConfigStr << "]"); - if ((quotesStart != quotesEnd) && (quotesStart + 1 != quotesEnd)) { - // Explicit check in case if assertion is disabled - currValue = currValue.substr(quotesStart + 1, quotesEnd - 1); - } - } - } - ELPP_ASSERT(*currLevel != Level::Unknown, "Unrecognized severity level [" << *currLevelStr << "]"); - ELPP_ASSERT(currConfig != ConfigurationType::Unknown, "Unrecognized configuration [" << *currConfigStr << "]"); - if (*currLevel == Level::Unknown || currConfig == ConfigurationType::Unknown) { - return false; // unrecognizable level or config - } - conf->set(*currLevel, currConfig, currValue); - return true; -} - -void Configurations::unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string& value) { - Configuration* conf = RegistryWithPred::get(level, configurationType); - if (conf == nullptr) { - unsafeSet(level, configurationType, value); - } -} - -void Configurations::unsafeSet(Level level, ConfigurationType configurationType, const std::string& value) { - Configuration* conf = RegistryWithPred::get(level, configurationType); - if (conf == nullptr) { - registerNew(new Configuration(level, configurationType, value)); - } else { - conf->setValue(value); - } - if (level == Level::Global) { - unsafeSetGlobally(configurationType, value, false); - } -} - -void Configurations::setGlobally(ConfigurationType configurationType, const std::string& value, - bool includeGlobalLevel) { - if (includeGlobalLevel) { - set(Level::Global, configurationType, value); - } - base::type::EnumType lIndex = LevelHelper::kMinValid; - LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { - set(LevelHelper::castFromInt(lIndex), configurationType, value); - return false; // Do not break lambda function yet as we need to set all levels regardless - }); -} - -void Configurations::unsafeSetGlobally(ConfigurationType configurationType, const std::string& value, - bool includeGlobalLevel) { - if (includeGlobalLevel) { - unsafeSet(Level::Global, configurationType, value); - } - base::type::EnumType lIndex = LevelHelper::kMinValid; - LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { - unsafeSet(LevelHelper::castFromInt(lIndex), configurationType, value); - return false; // Do not break lambda function yet as we need to set all levels regardless - }); -} - -// LogBuilder - -void LogBuilder::convertToColoredOutput(base::type::string_t* logLine, Level level) { - if (!m_termSupportsColor) return; - const base::type::char_t* resetColor = ELPP_LITERAL("\x1b[0m"); - if (level == Level::Error || level == Level::Fatal) - *logLine = ELPP_LITERAL("\x1b[31m") + *logLine + resetColor; - else if (level == Level::Warning) - *logLine = ELPP_LITERAL("\x1b[33m") + *logLine + resetColor; - else if (level == Level::Debug) - *logLine = ELPP_LITERAL("\x1b[32m") + *logLine + resetColor; - else if (level == Level::Info) - *logLine = ELPP_LITERAL("\x1b[36m") + *logLine + resetColor; - else if (level == Level::Trace) - *logLine = ELPP_LITERAL("\x1b[35m") + *logLine + resetColor; -} - -// Logger - -Logger::Logger(const std::string& id, base::LogStreamsReferenceMapPtr logStreamsReference) : - m_id(id), - m_typedConfigurations(nullptr), - m_parentApplicationName(std::string()), - m_isConfigured(false), - m_logStreamsReference(logStreamsReference) { - initUnflushedCount(); -} - -Logger::Logger(const std::string& id, const Configurations& configurations, - base::LogStreamsReferenceMapPtr logStreamsReference) : - m_id(id), - m_typedConfigurations(nullptr), - m_parentApplicationName(std::string()), - m_isConfigured(false), - m_logStreamsReference(logStreamsReference) { - initUnflushedCount(); - configure(configurations); -} - -Logger::Logger(const Logger& logger) { - base::utils::safeDelete(m_typedConfigurations); - m_id = logger.m_id; - m_typedConfigurations = logger.m_typedConfigurations; - m_parentApplicationName = logger.m_parentApplicationName; - m_isConfigured = logger.m_isConfigured; - m_configurations = logger.m_configurations; - m_unflushedCount = logger.m_unflushedCount; - m_logStreamsReference = logger.m_logStreamsReference; -} - -Logger& Logger::operator=(const Logger& logger) { - if (&logger != this) { - base::utils::safeDelete(m_typedConfigurations); - m_id = logger.m_id; - m_typedConfigurations = logger.m_typedConfigurations; - m_parentApplicationName = logger.m_parentApplicationName; - m_isConfigured = logger.m_isConfigured; - m_configurations = logger.m_configurations; - m_unflushedCount = logger.m_unflushedCount; - m_logStreamsReference = logger.m_logStreamsReference; - } - return *this; -} - -void Logger::configure(const Configurations& configurations) { - m_isConfigured = false; // we set it to false in case if we fail - initUnflushedCount(); - if (m_typedConfigurations != nullptr) { - Configurations* c = const_cast(m_typedConfigurations->configurations()); - if (c->hasConfiguration(Level::Global, ConfigurationType::Filename)) { - flush(); - } - } - base::threading::ScopedLock scopedLock(lock()); - if (m_configurations != configurations) { - m_configurations.setFromBase(const_cast(&configurations)); - } - base::utils::safeDelete(m_typedConfigurations); - m_typedConfigurations = new base::TypedConfigurations(&m_configurations, m_logStreamsReference); - resolveLoggerFormatSpec(); - m_isConfigured = true; -} - -void Logger::reconfigure(void) { - ELPP_INTERNAL_INFO(1, "Reconfiguring logger [" << m_id << "]"); - configure(m_configurations); -} - -bool Logger::isValidId(const std::string& id) { - for (std::string::const_iterator it = id.begin(); it != id.end(); ++it) { - if (!base::utils::Str::contains(base::consts::kValidLoggerIdSymbols, *it)) { - return false; - } - } - return true; -} - -void Logger::flush(void) { - ELPP_INTERNAL_INFO(3, "Flushing logger [" << m_id << "] all levels"); - base::threading::ScopedLock scopedLock(lock()); - base::type::EnumType lIndex = LevelHelper::kMinValid; - LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { - flush(LevelHelper::castFromInt(lIndex), nullptr); - return false; - }); -} - -void Logger::flush(Level level, base::type::fstream_t* fs) { - if (fs == nullptr && m_typedConfigurations->toFile(level)) { - fs = m_typedConfigurations->fileStream(level); - } - if (fs != nullptr) { - fs->flush(); - std::unordered_map::iterator iter = m_unflushedCount.find(level); - if (iter != m_unflushedCount.end()) { - iter->second = 0; - } - Helpers::validateFileRolling(this, level); - } -} - -void Logger::initUnflushedCount(void) { - m_unflushedCount.clear(); - base::type::EnumType lIndex = LevelHelper::kMinValid; - LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { - m_unflushedCount.insert(std::make_pair(LevelHelper::castFromInt(lIndex), 0)); - return false; - }); -} - -void Logger::resolveLoggerFormatSpec(void) const { - base::type::EnumType lIndex = LevelHelper::kMinValid; - LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { - base::LogFormat* logFormat = - const_cast(&m_typedConfigurations->logFormat(LevelHelper::castFromInt(lIndex))); - base::utils::Str::replaceFirstWithEscape(logFormat->m_format, base::consts::kLoggerIdFormatSpecifier, m_id); - return false; - }); -} - -// el::base -namespace base { - -// el::base::utils -namespace utils { - -// File - -base::type::fstream_t* File::newFileStream(const std::string& filename) { - base::type::fstream_t *fs = new base::type::fstream_t(filename.c_str(), - base::type::fstream_t::out -#if !defined(ELPP_FRESH_LOG_FILE) - | base::type::fstream_t::app -#endif - ); -#if defined(ELPP_UNICODE) - std::locale elppUnicodeLocale(""); -# if ELPP_OS_WINDOWS - std::locale elppUnicodeLocaleWindows(elppUnicodeLocale, new std::codecvt_utf8_utf16); - elppUnicodeLocale = elppUnicodeLocaleWindows; -# endif // ELPP_OS_WINDOWS - fs->imbue(elppUnicodeLocale); -#endif // defined(ELPP_UNICODE) - if (fs->is_open()) { - fs->flush(); - } else { - base::utils::safeDelete(fs); - ELPP_INTERNAL_ERROR("Bad file [" << filename << "]", true); - } - return fs; -} - -std::size_t File::getSizeOfFile(base::type::fstream_t* fs) { - if (fs == nullptr) { - return 0; - } - // Since the file stream is appended to or truncated, the current - // offset is the file size. - std::size_t size = static_cast(fs->tellg()); - return size; -} - -bool File::pathExists(const char* path, bool considerFile) { - if (path == nullptr) { - return false; - } -#if ELPP_OS_UNIX - ELPP_UNUSED(considerFile); - struct stat st; - return (stat(path, &st) == 0); -#elif ELPP_OS_WINDOWS - DWORD fileType = GetFileAttributesA(path); - if (fileType == INVALID_FILE_ATTRIBUTES) { - return false; - } - return considerFile ? true : ((fileType & FILE_ATTRIBUTE_DIRECTORY) == 0 ? false : true); -#endif // ELPP_OS_UNIX -} - -bool File::createPath(const std::string& path) { - if (path.empty()) { - return false; - } - if (base::utils::File::pathExists(path.c_str())) { - return true; - } - int status = -1; - - char* currPath = const_cast(path.c_str()); - std::string builtPath = std::string(); -#if ELPP_OS_UNIX - if (path[0] == '/') { - builtPath = "/"; - } - currPath = STRTOK(currPath, base::consts::kFilePathSeparator, 0); -#elif ELPP_OS_WINDOWS - // Use secure functions API - char* nextTok_ = nullptr; - currPath = STRTOK(currPath, base::consts::kFilePathSeparator, &nextTok_); - ELPP_UNUSED(nextTok_); -#endif // ELPP_OS_UNIX - while (currPath != nullptr) { - builtPath.append(currPath); - builtPath.append(base::consts::kFilePathSeparator); -#if ELPP_OS_UNIX - status = mkdir(builtPath.c_str(), ELPP_LOG_PERMS); - currPath = STRTOK(nullptr, base::consts::kFilePathSeparator, 0); -#elif ELPP_OS_WINDOWS - status = _mkdir(builtPath.c_str()); - currPath = STRTOK(nullptr, base::consts::kFilePathSeparator, &nextTok_); -#endif // ELPP_OS_UNIX - } - if (status == -1) { - ELPP_INTERNAL_ERROR("Error while creating path [" << path << "]", true); - return false; - } - return true; -} - -std::string File::extractPathFromFilename(const std::string& fullPath, const char* separator) { - if ((fullPath == "") || (fullPath.find(separator) == std::string::npos)) { - return fullPath; - } - std::size_t lastSlashAt = fullPath.find_last_of(separator); - if (lastSlashAt == 0) { - return std::string(separator); - } - return fullPath.substr(0, lastSlashAt + 1); -} - -void File::buildStrippedFilename(const char* filename, char buff[], std::size_t limit) { - std::size_t sizeOfFilename = strlen(filename); - if (sizeOfFilename >= limit) { - filename += (sizeOfFilename - limit); - if (filename[0] != '.' && filename[1] != '.') { // prepend if not already - filename += 3; // 3 = '..' - STRCAT(buff, "..", limit); - } - } - STRCAT(buff, filename, limit); -} - -void File::buildBaseFilename(const std::string& fullPath, char buff[], std::size_t limit, const char* separator) { - const char *filename = fullPath.c_str(); - std::size_t lastSlashAt = fullPath.find_last_of(separator); - filename += lastSlashAt ? lastSlashAt+1 : 0; - std::size_t sizeOfFilename = strlen(filename); - if (sizeOfFilename >= limit) { - filename += (sizeOfFilename - limit); - if (filename[0] != '.' && filename[1] != '.') { // prepend if not already - filename += 3; // 3 = '..' - STRCAT(buff, "..", limit); - } - } - STRCAT(buff, filename, limit); -} - -// Str - -bool Str::wildCardMatch(const char* str, const char* pattern) { - while (*pattern) { - switch (*pattern) { - case '?': - if (!*str) - return false; - ++str; - ++pattern; - break; - case '*': - if (wildCardMatch(str, pattern + 1)) - return true; - if (*str && wildCardMatch(str + 1, pattern)) - return true; - return false; - default: - if (*str++ != *pattern++) - return false; - break; - } - } - return !*str && !*pattern; -} - -std::string& Str::ltrim(std::string& str) { - str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](char c) { - return !std::isspace(c); - } )); - return str; -} - -std::string& Str::rtrim(std::string& str) { - str.erase(std::find_if(str.rbegin(), str.rend(), [](char c) { - return !std::isspace(c); - }).base(), str.end()); - return str; -} - -std::string& Str::trim(std::string& str) { - return ltrim(rtrim(str)); -} - -bool Str::startsWith(const std::string& str, const std::string& start) { - return (str.length() >= start.length()) && (str.compare(0, start.length(), start) == 0); -} - -bool Str::endsWith(const std::string& str, const std::string& end) { - return (str.length() >= end.length()) && (str.compare(str.length() - end.length(), end.length(), end) == 0); -} - -std::string& Str::replaceAll(std::string& str, char replaceWhat, char replaceWith) { - std::replace(str.begin(), str.end(), replaceWhat, replaceWith); - return str; -} - -std::string& Str::replaceAll(std::string& str, const std::string& replaceWhat, - const std::string& replaceWith) { - if (replaceWhat == replaceWith) - return str; - std::size_t foundAt = std::string::npos; - while ((foundAt = str.find(replaceWhat, foundAt + 1)) != std::string::npos) { - str.replace(foundAt, replaceWhat.length(), replaceWith); - } - return str; -} - -void Str::replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat, - const base::type::string_t& replaceWith) { - std::size_t foundAt = base::type::string_t::npos; - while ((foundAt = str.find(replaceWhat, foundAt + 1)) != base::type::string_t::npos) { - if (foundAt > 0 && str[foundAt - 1] == base::consts::kFormatSpecifierChar) { - str.erase(foundAt - 1, 1); - ++foundAt; - } else { - str.replace(foundAt, replaceWhat.length(), replaceWith); - return; - } - } -} -#if defined(ELPP_UNICODE) -void Str::replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat, - const std::string& replaceWith) { - replaceFirstWithEscape(str, replaceWhat, base::type::string_t(replaceWith.begin(), replaceWith.end())); -} -#endif // defined(ELPP_UNICODE) - -std::string& Str::toUpper(std::string& str) { - std::transform(str.begin(), str.end(), str.begin(), - [](char c) { - return static_cast(::toupper(c)); - }); - return str; -} - -bool Str::cStringEq(const char* s1, const char* s2) { - if (s1 == nullptr && s2 == nullptr) return true; - if (s1 == nullptr || s2 == nullptr) return false; - return strcmp(s1, s2) == 0; -} - -bool Str::cStringCaseEq(const char* s1, const char* s2) { - if (s1 == nullptr && s2 == nullptr) return true; - if (s1 == nullptr || s2 == nullptr) return false; - - // With thanks to cygwin for this code - int d = 0; - - while (true) { - const int c1 = toupper(*s1++); - const int c2 = toupper(*s2++); - - if (((d = c1 - c2) != 0) || (c2 == '\0')) { - break; - } - } - - return d == 0; -} - -bool Str::contains(const char* str, char c) { - for (; *str; ++str) { - if (*str == c) - return true; - } - return false; -} - -char* Str::convertAndAddToBuff(std::size_t n, int len, char* buf, const char* bufLim, bool zeroPadded) { - char localBuff[10] = ""; - char* p = localBuff + sizeof(localBuff) - 2; - if (n > 0) { - for (; n > 0 && p > localBuff && len > 0; n /= 10, --len) - *--p = static_cast(n % 10 + '0'); - } else { - *--p = '0'; - --len; - } - if (zeroPadded) - while (p > localBuff && len-- > 0) *--p = static_cast('0'); - return addToBuff(p, buf, bufLim); -} - -char* Str::addToBuff(const char* str, char* buf, const char* bufLim) { - while ((buf < bufLim) && ((*buf = *str++) != '\0')) - ++buf; - return buf; -} - -char* Str::clearBuff(char buff[], std::size_t lim) { - STRCPY(buff, "", lim); - ELPP_UNUSED(lim); // For *nix we dont have anything using lim in above STRCPY macro - return buff; -} - -/// @brief Converts wchar* to char* -/// NOTE: Need to free return value after use! -char* Str::wcharPtrToCharPtr(const wchar_t* line) { - std::size_t len_ = wcslen(line) + 1; - char* buff_ = static_cast(malloc(len_ + 1)); -# if ELPP_OS_UNIX || (ELPP_OS_WINDOWS && !ELPP_CRT_DBG_WARNINGS) - std::wcstombs(buff_, line, len_); -# elif ELPP_OS_WINDOWS - std::size_t convCount_ = 0; - mbstate_t mbState_; - ::memset(static_cast(&mbState_), 0, sizeof(mbState_)); - wcsrtombs_s(&convCount_, buff_, len_, &line, len_, &mbState_); -# endif // ELPP_OS_UNIX || (ELPP_OS_WINDOWS && !ELPP_CRT_DBG_WARNINGS) - return buff_; -} - -// OS - -#if ELPP_OS_WINDOWS -/// @brief Gets environment variables for Windows based OS. -/// We are not using getenv(const char*) because of CRT deprecation -/// @param varname Variable name to get environment variable value for -/// @return If variable exist the value of it otherwise nullptr -const char* OS::getWindowsEnvironmentVariable(const char* varname) { - const DWORD bufferLen = 50; - static char buffer[bufferLen]; - if (GetEnvironmentVariableA(varname, buffer, bufferLen)) { - return buffer; - } - return nullptr; -} -#endif // ELPP_OS_WINDOWS -#if ELPP_OS_ANDROID -std::string OS::getProperty(const char* prop) { - char propVal[PROP_VALUE_MAX + 1]; - int ret = __system_property_get(prop, propVal); - return ret == 0 ? std::string() : std::string(propVal); -} - -std::string OS::getDeviceName(void) { - std::stringstream ss; - std::string manufacturer = getProperty("ro.product.manufacturer"); - std::string model = getProperty("ro.product.model"); - if (manufacturer.empty() || model.empty()) { - return std::string(); - } - ss << manufacturer << "-" << model; - return ss.str(); -} -#endif // ELPP_OS_ANDROID - -const std::string OS::getBashOutput(const char* command) { -#if (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN) - if (command == nullptr) { - return std::string(); - } - FILE* proc = nullptr; - if ((proc = popen(command, "r")) == nullptr) { - ELPP_INTERNAL_ERROR("\nUnable to run command [" << command << "]", true); - return std::string(); - } - char hBuff[4096]; - if (fgets(hBuff, sizeof(hBuff), proc) != nullptr) { - pclose(proc); - const std::size_t buffLen = strlen(hBuff); - if (buffLen > 0 && hBuff[buffLen - 1] == '\n') { - hBuff[buffLen - 1] = '\0'; - } - return std::string(hBuff); - } else { - pclose(proc); - } - return std::string(); -#else - ELPP_UNUSED(command); - return std::string(); -#endif // (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN) -} - -std::string OS::getEnvironmentVariable(const char* variableName, const char* defaultVal, - const char* alternativeBashCommand) { -#if ELPP_OS_UNIX - const char* val = getenv(variableName); -#elif ELPP_OS_WINDOWS - const char* val = getWindowsEnvironmentVariable(variableName); -#endif // ELPP_OS_UNIX - if ((val == nullptr) || ((strcmp(val, "") == 0))) { -#if ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH) - // Try harder on unix-based systems - std::string valBash = base::utils::OS::getBashOutput(alternativeBashCommand); - if (valBash.empty()) { - return std::string(defaultVal); - } else { - return valBash; - } -#elif ELPP_OS_WINDOWS || ELPP_OS_UNIX - ELPP_UNUSED(alternativeBashCommand); - return std::string(defaultVal); -#endif // ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH) - } - return std::string(val); -} - -std::string OS::currentUser(void) { -#if ELPP_OS_UNIX && !ELPP_OS_ANDROID - return getEnvironmentVariable("USER", base::consts::kUnknownUser, "whoami"); -#elif ELPP_OS_WINDOWS - return getEnvironmentVariable("USERNAME", base::consts::kUnknownUser); -#elif ELPP_OS_ANDROID - ELPP_UNUSED(base::consts::kUnknownUser); - return std::string("android"); -#else - return std::string(); -#endif // ELPP_OS_UNIX && !ELPP_OS_ANDROID -} - -std::string OS::currentHost(void) { -#if ELPP_OS_UNIX && !ELPP_OS_ANDROID - return getEnvironmentVariable("HOSTNAME", base::consts::kUnknownHost, "hostname"); -#elif ELPP_OS_WINDOWS - return getEnvironmentVariable("COMPUTERNAME", base::consts::kUnknownHost); -#elif ELPP_OS_ANDROID - ELPP_UNUSED(base::consts::kUnknownHost); - return getDeviceName(); -#else - return std::string(); -#endif // ELPP_OS_UNIX && !ELPP_OS_ANDROID -} - -bool OS::termSupportsColor(void) { - std::string term = getEnvironmentVariable("TERM", ""); - return term == "xterm" || term == "xterm-color" || term == "xterm-256color" - || term == "screen" || term == "linux" || term == "cygwin" - || term == "screen-256color"; -} - -// DateTime - -void DateTime::gettimeofday(struct timeval* tv) { -#if ELPP_OS_WINDOWS - if (tv != nullptr) { -# if ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS) - const unsigned __int64 delta_ = 11644473600000000Ui64; -# else - const unsigned __int64 delta_ = 11644473600000000ULL; -# endif // ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS) - const double secOffSet = 0.000001; - const unsigned long usecOffSet = 1000000; - FILETIME fileTime; - GetSystemTimeAsFileTime(&fileTime); - unsigned __int64 present = 0; - present |= fileTime.dwHighDateTime; - present = present << 32; - present |= fileTime.dwLowDateTime; - present /= 10; // mic-sec - // Subtract the difference - present -= delta_; - tv->tv_sec = static_cast(present * secOffSet); - tv->tv_usec = static_cast(present % usecOffSet); - } -#else - ::gettimeofday(tv, nullptr); -#endif // ELPP_OS_WINDOWS -} - -std::string DateTime::getDateTime(const char* format, const base::SubsecondPrecision* ssPrec) { - struct timeval currTime; - gettimeofday(&currTime); - return timevalToString(currTime, format, ssPrec); -} - -std::string DateTime::timevalToString(struct timeval tval, const char* format, - const el::base::SubsecondPrecision* ssPrec) { - struct ::tm timeInfo; - buildTimeInfo(&tval, &timeInfo); - const int kBuffSize = 30; - char buff_[kBuffSize] = ""; - parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast(tval.tv_usec / ssPrec->m_offset), - ssPrec); - return std::string(buff_); -} - -base::type::string_t DateTime::formatTime(unsigned long long time, base::TimestampUnit timestampUnit) { - base::type::EnumType start = static_cast(timestampUnit); - const base::type::char_t* unit = base::consts::kTimeFormats[start].unit; - for (base::type::EnumType i = start; i < base::consts::kTimeFormatsCount - 1; ++i) { - if (time <= base::consts::kTimeFormats[i].value) { - break; - } - if (base::consts::kTimeFormats[i].value == 1000.0f && time / 1000.0f < 1.9f) { - break; - } - time /= static_cast(base::consts::kTimeFormats[i].value); - unit = base::consts::kTimeFormats[i + 1].unit; - } - base::type::stringstream_t ss; - ss << time << " " << unit; - return ss.str(); -} - -unsigned long long DateTime::getTimeDifference(const struct timeval& endTime, const struct timeval& startTime, - base::TimestampUnit timestampUnit) { - if (timestampUnit == base::TimestampUnit::Microsecond) { - return static_cast(static_cast(1000000 * endTime.tv_sec + endTime.tv_usec) - - static_cast(1000000 * startTime.tv_sec + startTime.tv_usec)); - } - // milliseconds - auto conv = [](const struct timeval& tim) { - return static_cast((tim.tv_sec * 1000) + (tim.tv_usec / 1000)); - }; - return static_cast(conv(endTime) - conv(startTime)); -} - -struct ::tm* DateTime::buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo) { -#if ELPP_OS_UNIX - time_t rawTime = currTime->tv_sec; - ::elpptime_r(&rawTime, timeInfo); - return timeInfo; -#else -# if ELPP_COMPILER_MSVC - ELPP_UNUSED(currTime); - time_t t; -# if defined(_USE_32BIT_TIME_T) - _time32(&t); -# else - _time64(&t); -# endif - elpptime_s(timeInfo, &t); - return timeInfo; -# else - // For any other compilers that don't have CRT warnings issue e.g, MinGW or TDM GCC- we use different method - time_t rawTime = currTime->tv_sec; - struct tm* tmInf = elpptime(&rawTime); - *timeInfo = *tmInf; - return timeInfo; -# endif // ELPP_COMPILER_MSVC -#endif // ELPP_OS_UNIX -} - -char* DateTime::parseFormat(char* buf, std::size_t bufSz, const char* format, const struct tm* tInfo, - std::size_t msec, const base::SubsecondPrecision* ssPrec) { - const char* bufLim = buf + bufSz; - for (; *format; ++format) { - if (*format == base::consts::kFormatSpecifierChar) { - switch (*++format) { - case base::consts::kFormatSpecifierChar: // Escape - break; - case '\0': // End - --format; - break; - case 'd': // Day - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_mday, 2, buf, bufLim); - continue; - case 'a': // Day of week (short) - buf = base::utils::Str::addToBuff(base::consts::kDaysAbbrev[tInfo->tm_wday], buf, bufLim); - continue; - case 'A': // Day of week (long) - buf = base::utils::Str::addToBuff(base::consts::kDays[tInfo->tm_wday], buf, bufLim); - continue; - case 'M': // month - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_mon + 1, 2, buf, bufLim); - continue; - case 'b': // month (short) - buf = base::utils::Str::addToBuff(base::consts::kMonthsAbbrev[tInfo->tm_mon], buf, bufLim); - continue; - case 'B': // month (long) - buf = base::utils::Str::addToBuff(base::consts::kMonths[tInfo->tm_mon], buf, bufLim); - continue; - case 'y': // year (two digits) - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_year + base::consts::kYearBase, 2, buf, bufLim); - continue; - case 'Y': // year (four digits) - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_year + base::consts::kYearBase, 4, buf, bufLim); - continue; - case 'h': // hour (12-hour) - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_hour % 12, 2, buf, bufLim); - continue; - case 'H': // hour (24-hour) - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_hour, 2, buf, bufLim); - continue; - case 'm': // minute - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_min, 2, buf, bufLim); - continue; - case 's': // second - buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_sec, 2, buf, bufLim); - continue; - case 'z': // subsecond part - case 'g': - buf = base::utils::Str::convertAndAddToBuff(msec, ssPrec->m_width, buf, bufLim); - continue; - case 'F': // AM/PM - buf = base::utils::Str::addToBuff((tInfo->tm_hour >= 12) ? base::consts::kPm : base::consts::kAm, buf, bufLim); - continue; - default: - continue; - } - } - if (buf == bufLim) break; - *buf++ = *format; - } - return buf; -} - -// CommandLineArgs - -void CommandLineArgs::setArgs(int argc, char** argv) { - m_params.clear(); - m_paramsWithValue.clear(); - if (argc == 0 || argv == nullptr) { - return; - } - m_argc = argc; - m_argv = argv; - for (int i = 1; i < m_argc; ++i) { - const char* v = (strstr(m_argv[i], "=")); - if (v != nullptr && strlen(v) > 0) { - std::string key = std::string(m_argv[i]); - key = key.substr(0, key.find_first_of('=')); - if (hasParamWithValue(key.c_str())) { - ELPP_INTERNAL_INFO(1, "Skipping [" << key << "] arg since it already has value [" - << getParamValue(key.c_str()) << "]"); - } else { - m_paramsWithValue.insert(std::make_pair(key, std::string(v + 1))); - } - } - if (v == nullptr) { - if (hasParam(m_argv[i])) { - ELPP_INTERNAL_INFO(1, "Skipping [" << m_argv[i] << "] arg since it already exists"); - } else { - m_params.push_back(std::string(m_argv[i])); - } - } - } -} - -bool CommandLineArgs::hasParamWithValue(const char* paramKey) const { - return m_paramsWithValue.find(std::string(paramKey)) != m_paramsWithValue.end(); -} - -const char* CommandLineArgs::getParamValue(const char* paramKey) const { - std::unordered_map::const_iterator iter = m_paramsWithValue.find(std::string(paramKey)); - return iter != m_paramsWithValue.end() ? iter->second.c_str() : ""; -} - -bool CommandLineArgs::hasParam(const char* paramKey) const { - return std::find(m_params.begin(), m_params.end(), std::string(paramKey)) != m_params.end(); -} - -bool CommandLineArgs::empty(void) const { - return m_params.empty() && m_paramsWithValue.empty(); -} - -std::size_t CommandLineArgs::size(void) const { - return m_params.size() + m_paramsWithValue.size(); -} - -base::type::ostream_t& operator<<(base::type::ostream_t& os, const CommandLineArgs& c) { - for (int i = 1; i < c.m_argc; ++i) { - os << ELPP_LITERAL("[") << c.m_argv[i] << ELPP_LITERAL("]"); - if (i < c.m_argc - 1) { - os << ELPP_LITERAL(" "); - } - } - return os; -} - -} // namespace utils - -// el::base::threading -namespace threading { - -#if ELPP_THREADING_ENABLED -# if ELPP_USE_STD_THREADING -# if ELPP_ASYNC_LOGGING -static void msleep(int ms) { - // Only when async logging enabled - this is because async is strict on compiler -# if defined(ELPP_NO_SLEEP_FOR) - usleep(ms * 1000); -# else - std::this_thread::sleep_for(std::chrono::milliseconds(ms)); -# endif // defined(ELPP_NO_SLEEP_FOR) -} -# endif // ELPP_ASYNC_LOGGING -# endif // !ELPP_USE_STD_THREADING -#endif // ELPP_THREADING_ENABLED - -} // namespace threading - -// el::base - -// SubsecondPrecision - -void SubsecondPrecision::init(int width) { - if (width < 1 || width > 6) { - width = base::consts::kDefaultSubsecondPrecision; - } - m_width = width; - switch (m_width) { - case 3: - m_offset = 1000; - break; - case 4: - m_offset = 100; - break; - case 5: - m_offset = 10; - break; - case 6: - m_offset = 1; - break; - default: - m_offset = 1000; - break; - } -} - -// LogFormat - -LogFormat::LogFormat(void) : - m_level(Level::Unknown), - m_userFormat(base::type::string_t()), - m_format(base::type::string_t()), - m_dateTimeFormat(std::string()), - m_flags(0x0), - m_currentUser(base::utils::OS::currentUser()), - m_currentHost(base::utils::OS::currentHost()) { -} - -LogFormat::LogFormat(Level level, const base::type::string_t& format) - : m_level(level), m_userFormat(format), m_currentUser(base::utils::OS::currentUser()), - m_currentHost(base::utils::OS::currentHost()) { - parseFromFormat(m_userFormat); -} - -LogFormat::LogFormat(const LogFormat& logFormat): - m_level(logFormat.m_level), - m_userFormat(logFormat.m_userFormat), - m_format(logFormat.m_format), - m_dateTimeFormat(logFormat.m_dateTimeFormat), - m_flags(logFormat.m_flags), - m_currentUser(logFormat.m_currentUser), - m_currentHost(logFormat.m_currentHost) { -} - -LogFormat::LogFormat(LogFormat&& logFormat) { - m_level = std::move(logFormat.m_level); - m_userFormat = std::move(logFormat.m_userFormat); - m_format = std::move(logFormat.m_format); - m_dateTimeFormat = std::move(logFormat.m_dateTimeFormat); - m_flags = std::move(logFormat.m_flags); - m_currentUser = std::move(logFormat.m_currentUser); - m_currentHost = std::move(logFormat.m_currentHost); -} - -LogFormat& LogFormat::operator=(const LogFormat& logFormat) { - if (&logFormat != this) { - m_level = logFormat.m_level; - m_userFormat = logFormat.m_userFormat; - m_dateTimeFormat = logFormat.m_dateTimeFormat; - m_flags = logFormat.m_flags; - m_currentUser = logFormat.m_currentUser; - m_currentHost = logFormat.m_currentHost; - } - return *this; -} - -bool LogFormat::operator==(const LogFormat& other) { - return m_level == other.m_level && m_userFormat == other.m_userFormat && m_format == other.m_format && - m_dateTimeFormat == other.m_dateTimeFormat && m_flags == other.m_flags; -} - -/// @brief Updates format to be used while logging. -/// @param userFormat User provided format -void LogFormat::parseFromFormat(const base::type::string_t& userFormat) { - // We make copy because we will be changing the format - // i.e, removing user provided date format from original format - // and then storing it. - base::type::string_t formatCopy = userFormat; - m_flags = 0x0; - auto conditionalAddFlag = [&](const base::type::char_t* specifier, base::FormatFlags flag) { - std::size_t foundAt = base::type::string_t::npos; - while ((foundAt = formatCopy.find(specifier, foundAt + 1)) != base::type::string_t::npos) { - if (foundAt > 0 && formatCopy[foundAt - 1] == base::consts::kFormatSpecifierChar) { - if (hasFlag(flag)) { - // If we already have flag we remove the escape chars so that '%%' is turned to '%' - // even after specifier resolution - this is because we only replaceFirst specifier - formatCopy.erase(foundAt - 1, 1); - ++foundAt; - } - } else { - if (!hasFlag(flag)) addFlag(flag); - } - } - }; - conditionalAddFlag(base::consts::kAppNameFormatSpecifier, base::FormatFlags::AppName); - conditionalAddFlag(base::consts::kSeverityLevelFormatSpecifier, base::FormatFlags::Level); - conditionalAddFlag(base::consts::kSeverityLevelShortFormatSpecifier, base::FormatFlags::LevelShort); - conditionalAddFlag(base::consts::kLoggerIdFormatSpecifier, base::FormatFlags::LoggerId); - conditionalAddFlag(base::consts::kThreadIdFormatSpecifier, base::FormatFlags::ThreadId); - conditionalAddFlag(base::consts::kLogFileFormatSpecifier, base::FormatFlags::File); - conditionalAddFlag(base::consts::kLogFileBaseFormatSpecifier, base::FormatFlags::FileBase); - conditionalAddFlag(base::consts::kLogLineFormatSpecifier, base::FormatFlags::Line); - conditionalAddFlag(base::consts::kLogLocationFormatSpecifier, base::FormatFlags::Location); - conditionalAddFlag(base::consts::kLogFunctionFormatSpecifier, base::FormatFlags::Function); - conditionalAddFlag(base::consts::kCurrentUserFormatSpecifier, base::FormatFlags::User); - conditionalAddFlag(base::consts::kCurrentHostFormatSpecifier, base::FormatFlags::Host); - conditionalAddFlag(base::consts::kMessageFormatSpecifier, base::FormatFlags::LogMessage); - conditionalAddFlag(base::consts::kVerboseLevelFormatSpecifier, base::FormatFlags::VerboseLevel); - // For date/time we need to extract user's date format first - std::size_t dateIndex = std::string::npos; - if ((dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier)) != std::string::npos) { - while (dateIndex != std::string::npos && dateIndex > 0 && formatCopy[dateIndex - 1] == base::consts::kFormatSpecifierChar) { - dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier, dateIndex + 1); - } - if (dateIndex != std::string::npos) { - addFlag(base::FormatFlags::DateTime); - updateDateFormat(dateIndex, formatCopy); - } - } - m_format = formatCopy; - updateFormatSpec(); -} - -void LogFormat::updateDateFormat(std::size_t index, base::type::string_t& currFormat) { - if (hasFlag(base::FormatFlags::DateTime)) { - index += ELPP_STRLEN(base::consts::kDateTimeFormatSpecifier); - } - const base::type::char_t* ptr = currFormat.c_str() + index; - if ((currFormat.size() > index) && (ptr[0] == '{')) { - // User has provided format for date/time - ++ptr; - int count = 1; // Start by 1 in order to remove starting brace - std::stringstream ss; - for (; *ptr; ++ptr, ++count) { - if (*ptr == '}') { - ++count; // In order to remove ending brace - break; - } - ss << static_cast(*ptr); - } - currFormat.erase(index, count); - m_dateTimeFormat = ss.str(); - } else { - // No format provided, use default - if (hasFlag(base::FormatFlags::DateTime)) { - m_dateTimeFormat = std::string(base::consts::kDefaultDateTimeFormat); - } - } -} - -void LogFormat::updateFormatSpec(void) { - // Do not use switch over strongly typed enums because Intel C++ compilers dont support them yet. - if (m_level == Level::Debug) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kDebugLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kDebugLevelShortLogValue); - } else if (m_level == Level::Info) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kInfoLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kInfoLevelShortLogValue); - } else if (m_level == Level::Warning) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kWarningLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kWarningLevelShortLogValue); - } else if (m_level == Level::Error) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kErrorLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kErrorLevelShortLogValue); - } else if (m_level == Level::Fatal) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kFatalLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kFatalLevelShortLogValue); - } else if (m_level == Level::Verbose) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kVerboseLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kVerboseLevelShortLogValue); - } else if (m_level == Level::Trace) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, - base::consts::kTraceLevelLogValue); - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, - base::consts::kTraceLevelShortLogValue); - } - if (hasFlag(base::FormatFlags::User)) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kCurrentUserFormatSpecifier, - m_currentUser); - } - if (hasFlag(base::FormatFlags::Host)) { - base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kCurrentHostFormatSpecifier, - m_currentHost); - } - // Ignore Level::Global and Level::Unknown -} - -// TypedConfigurations - -TypedConfigurations::TypedConfigurations(Configurations* configurations, - LogStreamsReferenceMapPtr logStreamsReference) { - m_configurations = configurations; - m_logStreamsReference = logStreamsReference; - build(m_configurations); -} - -TypedConfigurations::TypedConfigurations(const TypedConfigurations& other) { - this->m_configurations = other.m_configurations; - this->m_logStreamsReference = other.m_logStreamsReference; - build(m_configurations); -} - -bool TypedConfigurations::enabled(Level level) { - return getConfigByVal(level, &m_enabledMap, "enabled"); -} - -bool TypedConfigurations::toFile(Level level) { - return getConfigByVal(level, &m_toFileMap, "toFile"); -} - -const std::string& TypedConfigurations::filename(Level level) { - return getConfigByRef(level, &m_filenameMap, "filename"); -} - -bool TypedConfigurations::toStandardOutput(Level level) { - return getConfigByVal(level, &m_toStandardOutputMap, "toStandardOutput"); -} - -const base::LogFormat& TypedConfigurations::logFormat(Level level) { - return getConfigByRef(level, &m_logFormatMap, "logFormat"); -} - -const base::SubsecondPrecision& TypedConfigurations::subsecondPrecision(Level level) { - return getConfigByRef(level, &m_subsecondPrecisionMap, "subsecondPrecision"); -} - -const base::MillisecondsWidth& TypedConfigurations::millisecondsWidth(Level level) { - return getConfigByRef(level, &m_subsecondPrecisionMap, "millisecondsWidth"); -} - -bool TypedConfigurations::performanceTracking(Level level) { - return getConfigByVal(level, &m_performanceTrackingMap, "performanceTracking"); -} - -base::type::fstream_t* TypedConfigurations::fileStream(Level level) { - return getConfigByRef(level, &m_fileStreamMap, "fileStream").get(); -} - -std::size_t TypedConfigurations::maxLogFileSize(Level level) { - return getConfigByVal(level, &m_maxLogFileSizeMap, "maxLogFileSize"); -} - -std::size_t TypedConfigurations::logFlushThreshold(Level level) { - return getConfigByVal(level, &m_logFlushThresholdMap, "logFlushThreshold"); -} - -void TypedConfigurations::build(Configurations* configurations) { - base::threading::ScopedLock scopedLock(lock()); - auto getBool = [] (std::string boolStr) -> bool { // Pass by value for trimming - base::utils::Str::trim(boolStr); - return (boolStr == "TRUE" || boolStr == "true" || boolStr == "1"); - }; - std::vector withFileSizeLimit; - for (Configurations::const_iterator it = configurations->begin(); it != configurations->end(); ++it) { - Configuration* conf = *it; - // We cannot use switch on strong enums because Intel C++ dont support them yet - if (conf->configurationType() == ConfigurationType::Enabled) { - setValue(conf->level(), getBool(conf->value()), &m_enabledMap); - } else if (conf->configurationType() == ConfigurationType::ToFile) { - setValue(conf->level(), getBool(conf->value()), &m_toFileMap); - } else if (conf->configurationType() == ConfigurationType::ToStandardOutput) { - setValue(conf->level(), getBool(conf->value()), &m_toStandardOutputMap); - } else if (conf->configurationType() == ConfigurationType::Filename) { - // We do not yet configure filename but we will configure in another - // loop. This is because if file cannot be created, we will force ToFile - // to be false. Because configuring logger is not necessarily performance - // sensitive operation, we can live with another loop; (by the way this loop - // is not very heavy either) - } else if (conf->configurationType() == ConfigurationType::Format) { - setValue(conf->level(), base::LogFormat(conf->level(), - base::type::string_t(conf->value().begin(), conf->value().end())), &m_logFormatMap); - } else if (conf->configurationType() == ConfigurationType::SubsecondPrecision) { - setValue(Level::Global, - base::SubsecondPrecision(static_cast(getULong(conf->value()))), &m_subsecondPrecisionMap); - } else if (conf->configurationType() == ConfigurationType::PerformanceTracking) { - setValue(Level::Global, getBool(conf->value()), &m_performanceTrackingMap); - } else if (conf->configurationType() == ConfigurationType::MaxLogFileSize) { - auto v = getULong(conf->value()); - setValue(conf->level(), static_cast(v), &m_maxLogFileSizeMap); - if (v != 0) { - withFileSizeLimit.push_back(conf); - } - } else if (conf->configurationType() == ConfigurationType::LogFlushThreshold) { - setValue(conf->level(), static_cast(getULong(conf->value())), &m_logFlushThresholdMap); - } - } - // As mentioned earlier, we will now set filename configuration in separate loop to deal with non-existent files - for (Configurations::const_iterator it = configurations->begin(); it != configurations->end(); ++it) { - Configuration* conf = *it; - if (conf->configurationType() == ConfigurationType::Filename) { - insertFile(conf->level(), conf->value()); - } - } - for (std::vector::iterator conf = withFileSizeLimit.begin(); - conf != withFileSizeLimit.end(); ++conf) { - // This is not unsafe as mutex is locked in currect scope - unsafeValidateFileRolling((*conf)->level(), base::defaultPreRollOutCallback); - } -} - -unsigned long TypedConfigurations::getULong(std::string confVal) { - bool valid = true; - base::utils::Str::trim(confVal); - valid = !confVal.empty() && std::find_if(confVal.begin(), confVal.end(), - [](char c) { - return !base::utils::Str::isDigit(c); - }) == confVal.end(); - if (!valid) { - valid = false; - ELPP_ASSERT(valid, "Configuration value not a valid integer [" << confVal << "]"); - return 0; - } - return atol(confVal.c_str()); -} - -std::string TypedConfigurations::resolveFilename(const std::string& filename) { - std::string resultingFilename = filename; - std::size_t dateIndex = std::string::npos; - std::string dateTimeFormatSpecifierStr = std::string(base::consts::kDateTimeFormatSpecifierForFilename); - if ((dateIndex = resultingFilename.find(dateTimeFormatSpecifierStr.c_str())) != std::string::npos) { - while (dateIndex > 0 && resultingFilename[dateIndex - 1] == base::consts::kFormatSpecifierChar) { - dateIndex = resultingFilename.find(dateTimeFormatSpecifierStr.c_str(), dateIndex + 1); - } - if (dateIndex != std::string::npos) { - const char* ptr = resultingFilename.c_str() + dateIndex; - // Goto end of specifier - ptr += dateTimeFormatSpecifierStr.size(); - std::string fmt; - if ((resultingFilename.size() > dateIndex) && (ptr[0] == '{')) { - // User has provided format for date/time - ++ptr; - int count = 1; // Start by 1 in order to remove starting brace - std::stringstream ss; - for (; *ptr; ++ptr, ++count) { - if (*ptr == '}') { - ++count; // In order to remove ending brace - break; - } - ss << *ptr; - } - resultingFilename.erase(dateIndex + dateTimeFormatSpecifierStr.size(), count); - fmt = ss.str(); - } else { - fmt = std::string(base::consts::kDefaultDateTimeFormatInFilename); - } - base::SubsecondPrecision ssPrec(3); - std::string now = base::utils::DateTime::getDateTime(fmt.c_str(), &ssPrec); - base::utils::Str::replaceAll(now, '/', '-'); // Replace path element since we are dealing with filename - base::utils::Str::replaceAll(resultingFilename, dateTimeFormatSpecifierStr, now); - } - } - return resultingFilename; -} - -void TypedConfigurations::insertFile(Level level, const std::string& fullFilename) { - std::string resolvedFilename = resolveFilename(fullFilename); - if (resolvedFilename.empty()) { - std::cerr << "Could not load empty file for logging, please re-check your configurations for level [" - << LevelHelper::convertToString(level) << "]"; - } - std::string filePath = base::utils::File::extractPathFromFilename(resolvedFilename, base::consts::kFilePathSeparator); - if (filePath.size() < resolvedFilename.size()) { - base::utils::File::createPath(filePath); - } - auto create = [&](Level level) { - base::LogStreamsReferenceMap::iterator filestreamIter = m_logStreamsReference->find(resolvedFilename); - base::type::fstream_t* fs = nullptr; - if (filestreamIter == m_logStreamsReference->end()) { - // We need a completely new stream, nothing to share with - fs = base::utils::File::newFileStream(resolvedFilename); - m_filenameMap.insert(std::make_pair(level, resolvedFilename)); - m_fileStreamMap.insert(std::make_pair(level, base::FileStreamPtr(fs))); - m_logStreamsReference->insert(std::make_pair(resolvedFilename, base::FileStreamPtr(m_fileStreamMap.at(level)))); - } else { - // Woops! we have an existing one, share it! - m_filenameMap.insert(std::make_pair(level, filestreamIter->first)); - m_fileStreamMap.insert(std::make_pair(level, base::FileStreamPtr(filestreamIter->second))); - fs = filestreamIter->second.get(); - } - if (fs == nullptr) { - // We display bad file error from newFileStream() - ELPP_INTERNAL_ERROR("Setting [TO_FILE] of [" - << LevelHelper::convertToString(level) << "] to FALSE", false); - setValue(level, false, &m_toFileMap); - } - }; - // If we dont have file conf for any level, create it for Level::Global first - // otherwise create for specified level - create(m_filenameMap.empty() && m_fileStreamMap.empty() ? Level::Global : level); -} - -bool TypedConfigurations::unsafeValidateFileRolling(Level level, const PreRollOutCallback& preRollOutCallback) { - base::type::fstream_t* fs = unsafeGetConfigByRef(level, &m_fileStreamMap, "fileStream").get(); - if (fs == nullptr) { - return true; - } - std::size_t maxLogFileSize = unsafeGetConfigByVal(level, &m_maxLogFileSizeMap, "maxLogFileSize"); - std::size_t currFileSize = base::utils::File::getSizeOfFile(fs); - if (maxLogFileSize != 0 && currFileSize >= maxLogFileSize) { - std::string fname = unsafeGetConfigByRef(level, &m_filenameMap, "filename"); - ELPP_INTERNAL_INFO(1, "Truncating log file [" << fname << "] as a result of configurations for level [" - << LevelHelper::convertToString(level) << "]"); - fs->close(); - preRollOutCallback(fname.c_str(), currFileSize); - fs->open(fname, std::fstream::out | std::fstream::trunc); - return true; - } - return false; -} - -// RegisteredHitCounters - -bool RegisteredHitCounters::validateEveryN(const char* filename, base::type::LineNumber lineNumber, std::size_t n) { - base::threading::ScopedLock scopedLock(lock()); - base::HitCounter* counter = get(filename, lineNumber); - if (counter == nullptr) { - registerNew(counter = new base::HitCounter(filename, lineNumber)); - } - counter->validateHitCounts(n); - bool result = (n >= 1 && counter->hitCounts() != 0 && counter->hitCounts() % n == 0); - return result; -} - -/// @brief Validates counter for hits >= N, i.e, registers new if does not exist otherwise updates original one -/// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned -bool RegisteredHitCounters::validateAfterN(const char* filename, base::type::LineNumber lineNumber, std::size_t n) { - base::threading::ScopedLock scopedLock(lock()); - base::HitCounter* counter = get(filename, lineNumber); - if (counter == nullptr) { - registerNew(counter = new base::HitCounter(filename, lineNumber)); - } - // Do not use validateHitCounts here since we do not want to reset counter here - // Note the >= instead of > because we are incrementing - // after this check - if (counter->hitCounts() >= n) - return true; - counter->increment(); - return false; -} - -/// @brief Validates counter for hits are <= n, i.e, registers new if does not exist otherwise updates original one -/// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned -bool RegisteredHitCounters::validateNTimes(const char* filename, base::type::LineNumber lineNumber, std::size_t n) { - base::threading::ScopedLock scopedLock(lock()); - base::HitCounter* counter = get(filename, lineNumber); - if (counter == nullptr) { - registerNew(counter = new base::HitCounter(filename, lineNumber)); - } - counter->increment(); - // Do not use validateHitCounts here since we do not want to reset counter here - if (counter->hitCounts() <= n) - return true; - return false; -} - -// RegisteredLoggers - -RegisteredLoggers::RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder) : - m_defaultLogBuilder(defaultLogBuilder) { - m_defaultConfigurations.setToDefault(); - m_logStreamsReference = std::make_shared(); -} - -Logger* RegisteredLoggers::get(const std::string& id, bool forceCreation) { - base::threading::ScopedLock scopedLock(lock()); - Logger* logger_ = base::utils::Registry::get(id); - if (logger_ == nullptr && forceCreation) { - bool validId = Logger::isValidId(id); - if (!validId) { - ELPP_ASSERT(validId, "Invalid logger ID [" << id << "]. Not registering this logger."); - return nullptr; - } - logger_ = new Logger(id, m_defaultConfigurations, m_logStreamsReference); - logger_->m_logBuilder = m_defaultLogBuilder; - registerNew(id, logger_); - LoggerRegistrationCallback* callback = nullptr; - for (const std::pair& h - : m_loggerRegistrationCallbacks) { - callback = h.second.get(); - if (callback != nullptr && callback->enabled()) { - callback->handle(logger_); - } - } - } - return logger_; -} - -bool RegisteredLoggers::remove(const std::string& id) { - if (id == base::consts::kDefaultLoggerId) { - return false; - } - // get has internal lock - Logger* logger = base::utils::Registry::get(id); - if (logger != nullptr) { - // unregister has internal lock - unregister(logger); - } - return true; -} - -void RegisteredLoggers::unsafeFlushAll(void) { - ELPP_INTERNAL_INFO(1, "Flushing all log files"); - for (base::LogStreamsReferenceMap::iterator it = m_logStreamsReference->begin(); - it != m_logStreamsReference->end(); ++it) { - if (it->second.get() == nullptr) continue; - it->second->flush(); - } -} - -// VRegistry - -VRegistry::VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags) : m_level(level), m_pFlags(pFlags) { -} - -/// @brief Sets verbose level. Accepted range is 0-9 -void VRegistry::setLevel(base::type::VerboseLevel level) { - base::threading::ScopedLock scopedLock(lock()); - if (level > 9) - m_level = base::consts::kMaxVerboseLevel; - else - m_level = level; -} - -void VRegistry::setModules(const char* modules) { - base::threading::ScopedLock scopedLock(lock()); - auto addSuffix = [](std::stringstream& ss, const char* sfx, const char* prev) { - if (prev != nullptr && base::utils::Str::endsWith(ss.str(), std::string(prev))) { - std::string chr(ss.str().substr(0, ss.str().size() - strlen(prev))); - ss.str(std::string("")); - ss << chr; - } - if (base::utils::Str::endsWith(ss.str(), std::string(sfx))) { - std::string chr(ss.str().substr(0, ss.str().size() - strlen(sfx))); - ss.str(std::string("")); - ss << chr; - } - ss << sfx; - }; - auto insert = [&](std::stringstream& ss, base::type::VerboseLevel level) { - if (!base::utils::hasFlag(LoggingFlag::DisableVModulesExtensions, *m_pFlags)) { - addSuffix(ss, ".h", nullptr); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".c", ".h"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".cpp", ".c"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".cc", ".cpp"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".cxx", ".cc"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".-inl.h", ".cxx"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".hxx", ".-inl.h"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".hpp", ".hxx"); - m_modules.insert(std::make_pair(ss.str(), level)); - addSuffix(ss, ".hh", ".hpp"); - } - m_modules.insert(std::make_pair(ss.str(), level)); - }; - bool isMod = true; - bool isLevel = false; - std::stringstream ss; - int level = -1; - for (; *modules; ++modules) { - switch (*modules) { - case '=': - isLevel = true; - isMod = false; - break; - case ',': - isLevel = false; - isMod = true; - if (!ss.str().empty() && level != -1) { - insert(ss, static_cast(level)); - ss.str(std::string("")); - level = -1; - } - break; - default: - if (isMod) { - ss << *modules; - } else if (isLevel) { - if (isdigit(*modules)) { - level = static_cast(*modules) - 48; - } - } - break; - } - } - if (!ss.str().empty() && level != -1) { - insert(ss, static_cast(level)); - } -} - -bool VRegistry::allowed(base::type::VerboseLevel vlevel, const char* file) { - base::threading::ScopedLock scopedLock(lock()); - if (m_modules.empty() || file == nullptr) { - return vlevel <= m_level; - } else { - char baseFilename[base::consts::kSourceFilenameMaxLength] = ""; - base::utils::File::buildBaseFilename(file, baseFilename); - std::unordered_map::iterator it = m_modules.begin(); - for (; it != m_modules.end(); ++it) { - if (base::utils::Str::wildCardMatch(baseFilename, it->first.c_str())) { - return vlevel <= it->second; - } - } - if (base::utils::hasFlag(LoggingFlag::AllowVerboseIfModuleNotSpecified, *m_pFlags)) { - return true; - } - return false; - } -} - -void VRegistry::setFromArgs(const base::utils::CommandLineArgs* commandLineArgs) { - if (commandLineArgs->hasParam("-v") || commandLineArgs->hasParam("--verbose") || - commandLineArgs->hasParam("-V") || commandLineArgs->hasParam("--VERBOSE")) { - setLevel(base::consts::kMaxVerboseLevel); - } else if (commandLineArgs->hasParamWithValue("--v")) { - setLevel(static_cast(atoi(commandLineArgs->getParamValue("--v")))); - } else if (commandLineArgs->hasParamWithValue("--V")) { - setLevel(static_cast(atoi(commandLineArgs->getParamValue("--V")))); - } else if ((commandLineArgs->hasParamWithValue("-vmodule")) && vModulesEnabled()) { - setModules(commandLineArgs->getParamValue("-vmodule")); - } else if (commandLineArgs->hasParamWithValue("-VMODULE") && vModulesEnabled()) { - setModules(commandLineArgs->getParamValue("-VMODULE")); - } -} - -#if !defined(ELPP_DEFAULT_LOGGING_FLAGS) -# define ELPP_DEFAULT_LOGGING_FLAGS 0x0 -#endif // !defined(ELPP_DEFAULT_LOGGING_FLAGS) -// Storage -#if ELPP_ASYNC_LOGGING -Storage::Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker) : -#else -Storage::Storage(const LogBuilderPtr& defaultLogBuilder) : -#endif // ELPP_ASYNC_LOGGING - m_registeredHitCounters(new base::RegisteredHitCounters()), - m_registeredLoggers(new base::RegisteredLoggers(defaultLogBuilder)), - m_flags(ELPP_DEFAULT_LOGGING_FLAGS), - m_vRegistry(new base::VRegistry(0, &m_flags)), - -#if ELPP_ASYNC_LOGGING - m_asyncLogQueue(new base::AsyncLogQueue()), - m_asyncDispatchWorker(asyncDispatchWorker), -#endif // ELPP_ASYNC_LOGGING - - m_preRollOutCallback(base::defaultPreRollOutCallback) { - // Register default logger - m_registeredLoggers->get(std::string(base::consts::kDefaultLoggerId)); - // We register default logger anyway (worse case it's not going to register) just in case - m_registeredLoggers->get("default"); - -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - // Register performance logger and reconfigure format - Logger* performanceLogger = m_registeredLoggers->get(std::string(base::consts::kPerformanceLoggerId)); - m_registeredLoggers->get("performance"); - performanceLogger->configurations()->setGlobally(ConfigurationType::Format, std::string("%datetime %level %msg")); - performanceLogger->reconfigure(); -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - -#if defined(ELPP_SYSLOG) - // Register syslog logger and reconfigure format - Logger* sysLogLogger = m_registeredLoggers->get(std::string(base::consts::kSysLogLoggerId)); - sysLogLogger->configurations()->setGlobally(ConfigurationType::Format, std::string("%level: %msg")); - sysLogLogger->reconfigure(); -#endif // defined(ELPP_SYSLOG) - addFlag(LoggingFlag::AllowVerboseIfModuleNotSpecified); -#if ELPP_ASYNC_LOGGING - installLogDispatchCallback(std::string("AsyncLogDispatchCallback")); -#else - installLogDispatchCallback(std::string("DefaultLogDispatchCallback")); -#endif // ELPP_ASYNC_LOGGING -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - installPerformanceTrackingCallback - (std::string("DefaultPerformanceTrackingCallback")); -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - ELPP_INTERNAL_INFO(1, "Easylogging++ has been initialized"); -#if ELPP_ASYNC_LOGGING - m_asyncDispatchWorker->start(); -#endif // ELPP_ASYNC_LOGGING -} - -Storage::~Storage(void) { - ELPP_INTERNAL_INFO(4, "Destroying storage"); -#if ELPP_ASYNC_LOGGING - ELPP_INTERNAL_INFO(5, "Replacing log dispatch callback to synchronous"); - uninstallLogDispatchCallback(std::string("AsyncLogDispatchCallback")); - installLogDispatchCallback(std::string("DefaultLogDispatchCallback")); - ELPP_INTERNAL_INFO(5, "Destroying asyncDispatchWorker"); - base::utils::safeDelete(m_asyncDispatchWorker); - ELPP_INTERNAL_INFO(5, "Destroying asyncLogQueue"); - base::utils::safeDelete(m_asyncLogQueue); -#endif // ELPP_ASYNC_LOGGING - ELPP_INTERNAL_INFO(5, "Destroying registeredHitCounters"); - base::utils::safeDelete(m_registeredHitCounters); - ELPP_INTERNAL_INFO(5, "Destroying registeredLoggers"); - base::utils::safeDelete(m_registeredLoggers); - ELPP_INTERNAL_INFO(5, "Destroying vRegistry"); - base::utils::safeDelete(m_vRegistry); -} - -bool Storage::hasCustomFormatSpecifier(const char* formatSpecifier) { - base::threading::ScopedLock scopedLock(customFormatSpecifiersLock()); - return std::find(m_customFormatSpecifiers.begin(), m_customFormatSpecifiers.end(), - formatSpecifier) != m_customFormatSpecifiers.end(); -} - -void Storage::installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) { - if (hasCustomFormatSpecifier(customFormatSpecifier.formatSpecifier())) { - return; - } - base::threading::ScopedLock scopedLock(customFormatSpecifiersLock()); - m_customFormatSpecifiers.push_back(customFormatSpecifier); -} - -bool Storage::uninstallCustomFormatSpecifier(const char* formatSpecifier) { - base::threading::ScopedLock scopedLock(customFormatSpecifiersLock()); - std::vector::iterator it = std::find(m_customFormatSpecifiers.begin(), - m_customFormatSpecifiers.end(), formatSpecifier); - if (it != m_customFormatSpecifiers.end() && strcmp(formatSpecifier, it->formatSpecifier()) == 0) { - m_customFormatSpecifiers.erase(it); - return true; - } - return false; -} - -void Storage::setApplicationArguments(int argc, char** argv) { - m_commandLineArgs.setArgs(argc, argv); - m_vRegistry->setFromArgs(commandLineArgs()); - // default log file -#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) - if (m_commandLineArgs.hasParamWithValue(base::consts::kDefaultLogFileParam)) { - Configurations c; - c.setGlobally(ConfigurationType::Filename, - std::string(m_commandLineArgs.getParamValue(base::consts::kDefaultLogFileParam))); - registeredLoggers()->setDefaultConfigurations(c); - for (base::RegisteredLoggers::iterator it = registeredLoggers()->begin(); - it != registeredLoggers()->end(); ++it) { - it->second->configure(c); - } - } -#endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) -#if defined(ELPP_LOGGING_FLAGS_FROM_ARG) - if (m_commandLineArgs.hasParamWithValue(base::consts::kLoggingFlagsParam)) { - int userInput = atoi(m_commandLineArgs.getParamValue(base::consts::kLoggingFlagsParam)); - if (ELPP_DEFAULT_LOGGING_FLAGS == 0x0) { - m_flags = userInput; - } else { - base::utils::addFlag(userInput, &m_flags); - } - } -#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG) -} - -} // namespace base - -// LogDispatchCallback -#if defined(ELPP_THREAD_SAFE) -void LogDispatchCallback::handle(const LogDispatchData* data) { - base::threading::ScopedLock scopedLock(m_fileLocksMapLock); - std::string filename = data->logMessage()->logger()->typedConfigurations()->filename(data->logMessage()->level()); - auto lock = m_fileLocks.find(filename); - if (lock == m_fileLocks.end()) { - m_fileLocks.emplace(std::make_pair(filename, std::unique_ptr(new base::threading::Mutex))); - } -} -#else -void LogDispatchCallback::handle(const LogDispatchData* /*data*/) {} -#endif - -base::threading::Mutex& LogDispatchCallback::fileHandle(const LogDispatchData* data) { - auto it = m_fileLocks.find(data->logMessage()->logger()->typedConfigurations()->filename(data->logMessage()->level())); - return *(it->second.get()); -} - -namespace base { -// DefaultLogDispatchCallback - -void DefaultLogDispatchCallback::handle(const LogDispatchData* data) { -#if defined(ELPP_THREAD_SAFE) - LogDispatchCallback::handle(data); - base::threading::ScopedLock scopedLock(fileHandle(data)); -#endif - m_data = data; - dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(), - m_data->dispatchAction() == base::DispatchAction::NormalLog)); -} - -void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) { - if (m_data->dispatchAction() == base::DispatchAction::NormalLog) { - if (m_data->logMessage()->logger()->m_typedConfigurations->toFile(m_data->logMessage()->level())) { - base::type::fstream_t* fs = m_data->logMessage()->logger()->m_typedConfigurations->fileStream( - m_data->logMessage()->level()); - if (fs != nullptr) { - fs->write(logLine.c_str(), logLine.size()); - if (fs->fail()) { - ELPP_INTERNAL_ERROR("Unable to write log to file [" - << m_data->logMessage()->logger()->m_typedConfigurations->filename(m_data->logMessage()->level()) << "].\n" - << "Few possible reasons (could be something else):\n" << " * Permission denied\n" - << " * Disk full\n" << " * Disk is not writable", true); - } else { - if (ELPP->hasFlag(LoggingFlag::ImmediateFlush) - || (m_data->logMessage()->logger()->isFlushNeeded(m_data->logMessage()->level()))) { - m_data->logMessage()->logger()->flush(m_data->logMessage()->level(), fs); - } - } - } else { - ELPP_INTERNAL_ERROR("Log file for [" << LevelHelper::convertToString(m_data->logMessage()->level()) << "] " - << "has not been configured but [TO_FILE] is configured to TRUE. [Logger ID: " - << m_data->logMessage()->logger()->id() << "]", false); - } - } - if (m_data->logMessage()->logger()->m_typedConfigurations->toStandardOutput(m_data->logMessage()->level())) { - if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) - m_data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, m_data->logMessage()->level()); - ELPP_COUT << ELPP_COUT_LINE(logLine); - } - } -#if defined(ELPP_SYSLOG) - else if (m_data->dispatchAction() == base::DispatchAction::SysLog) { - // Determine syslog priority - int sysLogPriority = 0; - if (m_data->logMessage()->level() == Level::Fatal) - sysLogPriority = LOG_EMERG; - else if (m_data->logMessage()->level() == Level::Error) - sysLogPriority = LOG_ERR; - else if (m_data->logMessage()->level() == Level::Warning) - sysLogPriority = LOG_WARNING; - else if (m_data->logMessage()->level() == Level::Info) - sysLogPriority = LOG_INFO; - else if (m_data->logMessage()->level() == Level::Debug) - sysLogPriority = LOG_DEBUG; - else - sysLogPriority = LOG_NOTICE; -# if defined(ELPP_UNICODE) - char* line = base::utils::Str::wcharPtrToCharPtr(logLine.c_str()); - syslog(sysLogPriority, "%s", line); - free(line); -# else - syslog(sysLogPriority, "%s", logLine.c_str()); -# endif - } -#endif // defined(ELPP_SYSLOG) -} - -#if ELPP_ASYNC_LOGGING - -// AsyncLogDispatchCallback - -void AsyncLogDispatchCallback::handle(const LogDispatchData* data) { - base::type::string_t logLine = data->logMessage()->logger()->logBuilder()->build(data->logMessage(), - data->dispatchAction() == base::DispatchAction::NormalLog); - if (data->dispatchAction() == base::DispatchAction::NormalLog - && data->logMessage()->logger()->typedConfigurations()->toStandardOutput(data->logMessage()->level())) { - if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) - data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, data->logMessage()->level()); - ELPP_COUT << ELPP_COUT_LINE(logLine); - } - // Save resources and only queue if we want to write to file otherwise just ignore handler - if (data->logMessage()->logger()->typedConfigurations()->toFile(data->logMessage()->level())) { - ELPP->asyncLogQueue()->push(AsyncLogItem(*(data->logMessage()), *data, logLine)); - } -} - -// AsyncDispatchWorker -AsyncDispatchWorker::AsyncDispatchWorker() { - setContinueRunning(false); -} - -AsyncDispatchWorker::~AsyncDispatchWorker() { - setContinueRunning(false); - ELPP_INTERNAL_INFO(6, "Stopping dispatch worker - Cleaning log queue"); - clean(); - ELPP_INTERNAL_INFO(6, "Log queue cleaned"); -} - -bool AsyncDispatchWorker::clean(void) { - std::mutex m; - std::unique_lock lk(m); - cv.wait(lk, [] { return !ELPP->asyncLogQueue()->empty(); }); - emptyQueue(); - lk.unlock(); - cv.notify_one(); - return ELPP->asyncLogQueue()->empty(); -} - -void AsyncDispatchWorker::emptyQueue(void) { - while (!ELPP->asyncLogQueue()->empty()) { - AsyncLogItem data = ELPP->asyncLogQueue()->next(); - handle(&data); - base::threading::msleep(100); - } -} - -void AsyncDispatchWorker::start(void) { - base::threading::msleep(5000); // 5s (why?) - setContinueRunning(true); - std::thread t1(&AsyncDispatchWorker::run, this); - t1.join(); -} - -void AsyncDispatchWorker::handle(AsyncLogItem* logItem) { - LogDispatchData* data = logItem->data(); - LogMessage* logMessage = logItem->logMessage(); - Logger* logger = logMessage->logger(); - base::TypedConfigurations* conf = logger->typedConfigurations(); - base::type::string_t logLine = logItem->logLine(); - if (data->dispatchAction() == base::DispatchAction::NormalLog) { - if (conf->toFile(logMessage->level())) { - base::type::fstream_t* fs = conf->fileStream(logMessage->level()); - if (fs != nullptr) { - fs->write(logLine.c_str(), logLine.size()); - if (fs->fail()) { - ELPP_INTERNAL_ERROR("Unable to write log to file [" - << conf->filename(logMessage->level()) << "].\n" - << "Few possible reasons (could be something else):\n" << " * Permission denied\n" - << " * Disk full\n" << " * Disk is not writable", true); - } else { - if (ELPP->hasFlag(LoggingFlag::ImmediateFlush) || (logger->isFlushNeeded(logMessage->level()))) { - logger->flush(logMessage->level(), fs); - } - } - } else { - ELPP_INTERNAL_ERROR("Log file for [" << LevelHelper::convertToString(logMessage->level()) << "] " - << "has not been configured but [TO_FILE] is configured to TRUE. [Logger ID: " << logger->id() << "]", false); - } - } - } -# if defined(ELPP_SYSLOG) - else if (data->dispatchAction() == base::DispatchAction::SysLog) { - // Determine syslog priority - int sysLogPriority = 0; - if (logMessage->level() == Level::Fatal) - sysLogPriority = LOG_EMERG; - else if (logMessage->level() == Level::Error) - sysLogPriority = LOG_ERR; - else if (logMessage->level() == Level::Warning) - sysLogPriority = LOG_WARNING; - else if (logMessage->level() == Level::Info) - sysLogPriority = LOG_INFO; - else if (logMessage->level() == Level::Debug) - sysLogPriority = LOG_DEBUG; - else - sysLogPriority = LOG_NOTICE; -# if defined(ELPP_UNICODE) - char* line = base::utils::Str::wcharPtrToCharPtr(logLine.c_str()); - syslog(sysLogPriority, "%s", line); - free(line); -# else - syslog(sysLogPriority, "%s", logLine.c_str()); -# endif - } -# endif // defined(ELPP_SYSLOG) -} - -void AsyncDispatchWorker::run(void) { - while (continueRunning()) { - emptyQueue(); - base::threading::msleep(10); // 10ms - } -} -#endif // ELPP_ASYNC_LOGGING - -// DefaultLogBuilder - -base::type::string_t DefaultLogBuilder::build(const LogMessage* logMessage, bool appendNewLine) const { - base::TypedConfigurations* tc = logMessage->logger()->typedConfigurations(); - const base::LogFormat* logFormat = &tc->logFormat(logMessage->level()); - base::type::string_t logLine = logFormat->format(); - char buff[base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength] = ""; - const char* bufLim = buff + sizeof(buff); - if (logFormat->hasFlag(base::FormatFlags::AppName)) { - // App name - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kAppNameFormatSpecifier, - logMessage->logger()->parentApplicationName()); - } - if (logFormat->hasFlag(base::FormatFlags::ThreadId)) { - // Thread ID - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kThreadIdFormatSpecifier, - ELPP->getThreadName(base::threading::getCurrentThreadId())); - } - if (logFormat->hasFlag(base::FormatFlags::DateTime)) { - // DateTime - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kDateTimeFormatSpecifier, - base::utils::DateTime::getDateTime(logFormat->dateTimeFormat().c_str(), - &tc->subsecondPrecision(logMessage->level()))); - } - if (logFormat->hasFlag(base::FormatFlags::Function)) { - // Function - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFunctionFormatSpecifier, logMessage->func()); - } - if (logFormat->hasFlag(base::FormatFlags::File)) { - // File - base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength); - base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff); - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFileFormatSpecifier, std::string(buff)); - } - if (logFormat->hasFlag(base::FormatFlags::FileBase)) { - // FileBase - base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength); - base::utils::File::buildBaseFilename(logMessage->file(), buff); - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFileBaseFormatSpecifier, std::string(buff)); - } - if (logFormat->hasFlag(base::FormatFlags::Line)) { - // Line - char* buf = base::utils::Str::clearBuff(buff, base::consts::kSourceLineMaxLength); - buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), base::consts::kSourceLineMaxLength, buf, bufLim, false); - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogLineFormatSpecifier, std::string(buff)); - } - if (logFormat->hasFlag(base::FormatFlags::Location)) { - // Location - char* buf = base::utils::Str::clearBuff(buff, - base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength); - base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff); - buf = base::utils::Str::addToBuff(buff, buf, bufLim); - buf = base::utils::Str::addToBuff(":", buf, bufLim); - buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), base::consts::kSourceLineMaxLength, buf, bufLim, - false); - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogLocationFormatSpecifier, std::string(buff)); - } - if (logMessage->level() == Level::Verbose && logFormat->hasFlag(base::FormatFlags::VerboseLevel)) { - // Verbose level - char* buf = base::utils::Str::clearBuff(buff, 1); - buf = base::utils::Str::convertAndAddToBuff(logMessage->verboseLevel(), 1, buf, bufLim, false); - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kVerboseLevelFormatSpecifier, std::string(buff)); - } - if (logFormat->hasFlag(base::FormatFlags::LogMessage)) { - // Log message - base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kMessageFormatSpecifier, logMessage->message()); - } -#if !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS) - el::base::threading::ScopedLock lock_(ELPP->customFormatSpecifiersLock()); - ELPP_UNUSED(lock_); - for (std::vector::const_iterator it = ELPP->customFormatSpecifiers()->begin(); - it != ELPP->customFormatSpecifiers()->end(); ++it) { - std::string fs(it->formatSpecifier()); - base::type::string_t wcsFormatSpecifier(fs.begin(), fs.end()); - base::utils::Str::replaceFirstWithEscape(logLine, wcsFormatSpecifier, it->resolver()(logMessage)); - } -#endif // !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS) - if (appendNewLine) logLine += ELPP_LITERAL("\n"); - return logLine; -} - -// LogDispatcher - -void LogDispatcher::dispatch(void) { - if (m_proceed && m_dispatchAction == base::DispatchAction::None) { - m_proceed = false; - } - if (!m_proceed) { - return; - } -#ifndef ELPP_NO_GLOBAL_LOCK - // see https://github.com/muflihun/easyloggingpp/issues/580 - // global lock is turned on by default unless - // ELPP_NO_GLOBAL_LOCK is defined - base::threading::ScopedLock scopedLock(ELPP->lock()); -#endif - base::TypedConfigurations* tc = m_logMessage->logger()->m_typedConfigurations; - if (ELPP->hasFlag(LoggingFlag::StrictLogFileSizeCheck)) { - tc->validateFileRolling(m_logMessage->level(), ELPP->preRollOutCallback()); - } - LogDispatchCallback* callback = nullptr; - LogDispatchData data; - for (const std::pair& h - : ELPP->m_logDispatchCallbacks) { - callback = h.second.get(); - if (callback != nullptr && callback->enabled()) { - data.setLogMessage(m_logMessage); - data.setDispatchAction(m_dispatchAction); - callback->handle(&data); - } - } -} - -// MessageBuilder - -void MessageBuilder::initialize(Logger* logger) { - m_logger = logger; - m_containerLogSeparator = ELPP->hasFlag(LoggingFlag::NewLineForContainer) ? - ELPP_LITERAL("\n ") : ELPP_LITERAL(", "); -} - -MessageBuilder& MessageBuilder::operator<<(const wchar_t* msg) { - if (msg == nullptr) { - m_logger->stream() << base::consts::kNullPointer; - return *this; - } -# if defined(ELPP_UNICODE) - m_logger->stream() << msg; -# else - char* buff_ = base::utils::Str::wcharPtrToCharPtr(msg); - m_logger->stream() << buff_; - free(buff_); -# endif - if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) { - m_logger->stream() << " "; - } - return *this; -} - -// Writer - -Writer& Writer::construct(Logger* logger, bool needLock) { - m_logger = logger; - initializeLogger(logger->id(), false, needLock); - m_messageBuilder.initialize(m_logger); - return *this; -} - -Writer& Writer::construct(int count, const char* loggerIds, ...) { - if (ELPP->hasFlag(LoggingFlag::MultiLoggerSupport)) { - va_list loggersList; - va_start(loggersList, loggerIds); - const char* id = loggerIds; - m_loggerIds.reserve(count); - for (int i = 0; i < count; ++i) { - m_loggerIds.push_back(std::string(id)); - id = va_arg(loggersList, const char*); - } - va_end(loggersList); - initializeLogger(m_loggerIds.at(0)); - } else { - initializeLogger(std::string(loggerIds)); - } - m_messageBuilder.initialize(m_logger); - return *this; -} - -void Writer::initializeLogger(const std::string& loggerId, bool lookup, bool needLock) { - if (lookup) { - m_logger = ELPP->registeredLoggers()->get(loggerId, ELPP->hasFlag(LoggingFlag::CreateLoggerAutomatically)); - } - if (m_logger == nullptr) { - { - if (!ELPP->registeredLoggers()->has(std::string(base::consts::kDefaultLoggerId))) { - // Somehow default logger has been unregistered. Not good! Register again - ELPP->registeredLoggers()->get(std::string(base::consts::kDefaultLoggerId)); - } - } - Writer(Level::Debug, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId) - << "Logger [" << loggerId << "] is not registered yet!"; - m_proceed = false; - } else { - if (needLock) { - m_logger->acquireLock(); // This should not be unlocked by checking m_proceed because - // m_proceed can be changed by lines below - } - if (ELPP->hasFlag(LoggingFlag::HierarchicalLogging)) { - m_proceed = m_level == Level::Verbose ? m_logger->enabled(m_level) : - LevelHelper::castToInt(m_level) >= LevelHelper::castToInt(ELPP->m_loggingLevel); - } else { - m_proceed = m_logger->enabled(m_level); - } - } -} - -void Writer::processDispatch() { -#if ELPP_LOGGING_ENABLED - if (ELPP->hasFlag(LoggingFlag::MultiLoggerSupport)) { - bool firstDispatched = false; - base::type::string_t logMessage; - std::size_t i = 0; - do { - if (m_proceed) { - if (firstDispatched) { - m_logger->stream() << logMessage; - } else { - firstDispatched = true; - if (m_loggerIds.size() > 1) { - logMessage = m_logger->stream().str(); - } - } - triggerDispatch(); - } else if (m_logger != nullptr) { - m_logger->stream().str(ELPP_LITERAL("")); - m_logger->releaseLock(); - } - if (i + 1 < m_loggerIds.size()) { - initializeLogger(m_loggerIds.at(i + 1)); - } - } while (++i < m_loggerIds.size()); - } else { - if (m_proceed) { - triggerDispatch(); - } else if (m_logger != nullptr) { - m_logger->stream().str(ELPP_LITERAL("")); - m_logger->releaseLock(); - } - } -#else - if (m_logger != nullptr) { - m_logger->stream().str(ELPP_LITERAL("")); - m_logger->releaseLock(); - } -#endif // ELPP_LOGGING_ENABLED -} - -void Writer::triggerDispatch(void) { - try { - if (m_proceed) { - if (m_msg == nullptr) { - LogMessage msg(m_level, m_file, m_line, m_func, m_verboseLevel, - m_logger); - base::LogDispatcher(m_proceed, &msg, m_dispatchAction).dispatch(); - } else { - base::LogDispatcher(m_proceed, m_msg, m_dispatchAction).dispatch(); - } - } - if (m_logger != nullptr) { - m_logger->stream().str(ELPP_LITERAL("")); - m_logger->releaseLock(); - } - if (m_proceed && m_level == Level::Fatal - && !ELPP->hasFlag(LoggingFlag::DisableApplicationAbortOnFatalLog)) { - base::Writer(Level::Warning, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId) - << "Aborting application. Reason: Fatal log at [" << m_file << ":" << m_line << "]"; - std::stringstream reasonStream; - reasonStream << "Fatal log at [" << m_file << ":" << m_line << "]" - << " If you wish to disable 'abort on fatal log' please use " - << "el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog)"; - base::utils::abort(1, reasonStream.str()); - } - m_proceed = false; - } - catch(std::exception & ex){ - // Extremely low memory situation; don't let exception be unhandled. - } -} - -// PErrorWriter - -PErrorWriter::~PErrorWriter(void) { - if (m_proceed) { -#if ELPP_COMPILER_MSVC - char buff[256]; - strerror_s(buff, 256, errno); - m_logger->stream() << ": " << buff << " [" << errno << "]"; -#else - m_logger->stream() << ": " << strerror(errno) << " [" << errno << "]"; -#endif - } -} - -// PerformanceTracker - -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - -PerformanceTracker::PerformanceTracker(const std::string& blockName, - base::TimestampUnit timestampUnit, - const std::string& loggerId, - bool scopedLog, Level level) : - m_blockName(blockName), m_timestampUnit(timestampUnit), m_loggerId(loggerId), m_scopedLog(scopedLog), - m_level(level), m_hasChecked(false), m_lastCheckpointId(std::string()), m_enabled(false) { -#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED - // We store it locally so that if user happen to change configuration by the end of scope - // or before calling checkpoint, we still depend on state of configuration at time of construction - el::Logger* loggerPtr = ELPP->registeredLoggers()->get(loggerId, false); - m_enabled = loggerPtr != nullptr && loggerPtr->m_typedConfigurations->performanceTracking(m_level); - if (m_enabled) { - base::utils::DateTime::gettimeofday(&m_startTime); - } -#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED -} - -PerformanceTracker::~PerformanceTracker(void) { -#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED - if (m_enabled) { - base::threading::ScopedLock scopedLock(lock()); - if (m_scopedLog) { - base::utils::DateTime::gettimeofday(&m_endTime); - base::type::string_t formattedTime = getFormattedTimeTaken(); - PerformanceTrackingData data(PerformanceTrackingData::DataType::Complete); - data.init(this); - data.m_formattedTimeTaken = formattedTime; - PerformanceTrackingCallback* callback = nullptr; - for (const std::pair& h - : ELPP->m_performanceTrackingCallbacks) { - callback = h.second.get(); - if (callback != nullptr && callback->enabled()) { - callback->handle(&data); - } - } - } - } -#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) -} - -void PerformanceTracker::checkpoint(const std::string& id, const char* file, base::type::LineNumber line, - const char* func) { -#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED - if (m_enabled) { - base::threading::ScopedLock scopedLock(lock()); - base::utils::DateTime::gettimeofday(&m_endTime); - base::type::string_t formattedTime = m_hasChecked ? getFormattedTimeTaken(m_lastCheckpointTime) : ELPP_LITERAL(""); - PerformanceTrackingData data(PerformanceTrackingData::DataType::Checkpoint); - data.init(this); - data.m_checkpointId = id; - data.m_file = file; - data.m_line = line; - data.m_func = func; - data.m_formattedTimeTaken = formattedTime; - PerformanceTrackingCallback* callback = nullptr; - for (const std::pair& h - : ELPP->m_performanceTrackingCallbacks) { - callback = h.second.get(); - if (callback != nullptr && callback->enabled()) { - callback->handle(&data); - } - } - base::utils::DateTime::gettimeofday(&m_lastCheckpointTime); - m_hasChecked = true; - m_lastCheckpointId = id; - } -#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED - ELPP_UNUSED(id); - ELPP_UNUSED(file); - ELPP_UNUSED(line); - ELPP_UNUSED(func); -} - -const base::type::string_t PerformanceTracker::getFormattedTimeTaken(struct timeval startTime) const { - if (ELPP->hasFlag(LoggingFlag::FixedTimeFormat)) { - base::type::stringstream_t ss; - ss << base::utils::DateTime::getTimeDifference(m_endTime, - startTime, m_timestampUnit) << " " << base::consts::kTimeFormats[static_cast - (m_timestampUnit)].unit; - return ss.str(); - } - return base::utils::DateTime::formatTime(base::utils::DateTime::getTimeDifference(m_endTime, - startTime, m_timestampUnit), m_timestampUnit); -} - -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING) - -namespace debug { -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) - -// StackTrace - -StackTrace::StackTraceEntry::StackTraceEntry(std::size_t index, const std::string& loc, const std::string& demang, - const std::string& hex, - const std::string& addr) : - m_index(index), - m_location(loc), - m_demangled(demang), - m_hex(hex), - m_addr(addr) { -} - -std::ostream& operator<<(std::ostream& ss, const StackTrace::StackTraceEntry& si) { - ss << "[" << si.m_index << "] " << si.m_location << (si.m_hex.empty() ? "" : "+") << si.m_hex << " " << si.m_addr << - (si.m_demangled.empty() ? "" : ":") << si.m_demangled; - return ss; -} - -std::ostream& operator<<(std::ostream& os, const StackTrace& st) { - std::vector::const_iterator it = st.m_stack.begin(); - while (it != st.m_stack.end()) { - os << " " << *it++ << "\n"; - } - return os; -} - -void StackTrace::generateNew(void) { -#ifdef HAVE_EXECINFO - m_stack.clear(); - void* stack[kMaxStack]; - unsigned int size = backtrace(stack, kMaxStack); - char** strings = backtrace_symbols(stack, size); - if (size > kStackStart) { // Skip StackTrace c'tor and generateNew - for (std::size_t i = kStackStart; i < size; ++i) { - std::string mangName; - std::string location; - std::string hex; - std::string addr; - - // entry: 2 crash.cpp.bin 0x0000000101552be5 _ZN2el4base5debug10StackTraceC1Ev + 21 - const std::string line(strings[i]); - auto p = line.find("_"); - if (p != std::string::npos) { - mangName = line.substr(p); - mangName = mangName.substr(0, mangName.find(" +")); - } - p = line.find("0x"); - if (p != std::string::npos) { - addr = line.substr(p); - addr = addr.substr(0, addr.find("_")); - } - // Perform demangling if parsed properly - if (!mangName.empty()) { - int status = 0; - char* demangName = abi::__cxa_demangle(mangName.data(), 0, 0, &status); - // if demangling is successful, output the demangled function name - if (status == 0) { - // Success (see http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html) - StackTraceEntry entry(i - 1, location, demangName, hex, addr); - m_stack.push_back(entry); - } else { - // Not successful - we will use mangled name - StackTraceEntry entry(i - 1, location, mangName, hex, addr); - m_stack.push_back(entry); - } - free(demangName); - } else { - StackTraceEntry entry(i - 1, line); - m_stack.push_back(entry); - } - } - } - free(strings); -#else - ELPP_INTERNAL_INFO(1, "Stacktrace generation not supported for selected compiler"); -#endif // ELPP_STACKTRACE -} - -// Static helper functions - -static std::string crashReason(int sig) { - std::stringstream ss; - bool foundReason = false; - for (int i = 0; i < base::consts::kCrashSignalsCount; ++i) { - if (base::consts::kCrashSignals[i].numb == sig) { - ss << "Application has crashed due to [" << base::consts::kCrashSignals[i].name << "] signal"; - if (ELPP->hasFlag(el::LoggingFlag::LogDetailedCrashReason)) { - ss << std::endl << - " " << base::consts::kCrashSignals[i].brief << std::endl << - " " << base::consts::kCrashSignals[i].detail; - } - foundReason = true; - } - } - if (!foundReason) { - ss << "Application has crashed due to unknown signal [" << sig << "]"; - } - return ss.str(); -} -/// @brief Logs reason of crash from sig -static void logCrashReason(int sig, bool stackTraceIfAvailable, Level level, const char* logger) { - if (sig == SIGINT && ELPP->hasFlag(el::LoggingFlag::IgnoreSigInt)) { - return; - } - std::stringstream ss; - ss << "CRASH HANDLED; "; - ss << crashReason(sig); -#if ELPP_STACKTRACE - if (stackTraceIfAvailable) { - ss << std::endl << " ======= Backtrace: =========" << std::endl << base::debug::StackTrace(); - } -#else - ELPP_UNUSED(stackTraceIfAvailable); -#endif // ELPP_STACKTRACE - ELPP_WRITE_LOG(el::base::Writer, level, base::DispatchAction::NormalLog, logger) << ss.str(); -} - -static inline void crashAbort(int sig) { - base::utils::abort(sig, std::string()); -} - -/// @brief Default application crash handler -/// -/// @detail This function writes log using 'default' logger, prints stack trace for GCC based compilers and aborts program. -static inline void defaultCrashHandler(int sig) { - base::debug::logCrashReason(sig, true, Level::Fatal, base::consts::kDefaultLoggerId); - base::debug::crashAbort(sig); -} - -// CrashHandler - -CrashHandler::CrashHandler(bool useDefault) { - if (useDefault) { - setHandler(defaultCrashHandler); - } -} - -void CrashHandler::setHandler(const Handler& cHandler) { - m_handler = cHandler; -#if defined(ELPP_HANDLE_SIGABRT) - int i = 0; // SIGABRT is at base::consts::kCrashSignals[0] -#else - int i = 1; -#endif // defined(ELPP_HANDLE_SIGABRT) - for (; i < base::consts::kCrashSignalsCount; ++i) { - m_handler = signal(base::consts::kCrashSignals[i].numb, cHandler); - } -} - -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) -} // namespace debug -} // namespace base - -// el - -// Helpers - -#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) - -void Helpers::crashAbort(int sig, const char* sourceFile, unsigned int long line) { - std::stringstream ss; - ss << base::debug::crashReason(sig).c_str(); - ss << " - [Called el::Helpers::crashAbort(" << sig << ")]"; - if (sourceFile != nullptr && strlen(sourceFile) > 0) { - ss << " - Source: " << sourceFile; - if (line > 0) - ss << ":" << line; - else - ss << " (line number not specified)"; - } - base::utils::abort(sig, ss.str()); -} - -void Helpers::logCrashReason(int sig, bool stackTraceIfAvailable, Level level, const char* logger) { - el::base::debug::logCrashReason(sig, stackTraceIfAvailable, level, logger); -} - -#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_CRASH_LOG) - -// Loggers - -Logger* Loggers::getLogger(const std::string& identity, bool registerIfNotAvailable) { - return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable); -} - -void Loggers::setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr) { - ELPP->registeredLoggers()->setDefaultLogBuilder(logBuilderPtr); -} - -bool Loggers::unregisterLogger(const std::string& identity) { - return ELPP->registeredLoggers()->remove(identity); -} - -bool Loggers::hasLogger(const std::string& identity) { - return ELPP->registeredLoggers()->has(identity); -} - -Logger* Loggers::reconfigureLogger(Logger* logger, const Configurations& configurations) { - if (!logger) return nullptr; - logger->configure(configurations); - return logger; -} - -Logger* Loggers::reconfigureLogger(const std::string& identity, const Configurations& configurations) { - return Loggers::reconfigureLogger(Loggers::getLogger(identity), configurations); -} - -Logger* Loggers::reconfigureLogger(const std::string& identity, ConfigurationType configurationType, - const std::string& value) { - Logger* logger = Loggers::getLogger(identity); - if (logger == nullptr) { - return nullptr; - } - logger->configurations()->set(Level::Global, configurationType, value); - logger->reconfigure(); - return logger; -} - -void Loggers::reconfigureAllLoggers(const Configurations& configurations) { - for (base::RegisteredLoggers::iterator it = ELPP->registeredLoggers()->begin(); - it != ELPP->registeredLoggers()->end(); ++it) { - Loggers::reconfigureLogger(it->second, configurations); - } -} - -void Loggers::reconfigureAllLoggers(Level level, ConfigurationType configurationType, - const std::string& value) { - for (base::RegisteredLoggers::iterator it = ELPP->registeredLoggers()->begin(); - it != ELPP->registeredLoggers()->end(); ++it) { - Logger* logger = it->second; - logger->configurations()->set(level, configurationType, value); - logger->reconfigure(); - } -} - -void Loggers::setDefaultConfigurations(const Configurations& configurations, bool reconfigureExistingLoggers) { - ELPP->registeredLoggers()->setDefaultConfigurations(configurations); - if (reconfigureExistingLoggers) { - Loggers::reconfigureAllLoggers(configurations); - } -} - -const Configurations* Loggers::defaultConfigurations(void) { - return ELPP->registeredLoggers()->defaultConfigurations(); -} - -const base::LogStreamsReferenceMapPtr Loggers::logStreamsReference(void) { - return ELPP->registeredLoggers()->logStreamsReference(); -} - -base::TypedConfigurations Loggers::defaultTypedConfigurations(void) { - return base::TypedConfigurations( - ELPP->registeredLoggers()->defaultConfigurations(), - ELPP->registeredLoggers()->logStreamsReference()); -} - -std::vector* Loggers::populateAllLoggerIds(std::vector* targetList) { - targetList->clear(); - for (base::RegisteredLoggers::iterator it = ELPP->registeredLoggers()->list().begin(); - it != ELPP->registeredLoggers()->list().end(); ++it) { - targetList->push_back(it->first); - } - return targetList; -} - -void Loggers::configureFromGlobal(const char* globalConfigurationFilePath) { - std::ifstream gcfStream(globalConfigurationFilePath, std::ifstream::in); - ELPP_ASSERT(gcfStream.is_open(), "Unable to open global configuration file [" << globalConfigurationFilePath - << "] for parsing."); - std::string line = std::string(); - std::stringstream ss; - Logger* logger = nullptr; - auto configure = [&](void) { - ELPP_INTERNAL_INFO(8, "Configuring logger: '" << logger->id() << "' with configurations \n" << ss.str() - << "\n--------------"); - Configurations c; - c.parseFromText(ss.str()); - logger->configure(c); - }; - while (gcfStream.good()) { - std::getline(gcfStream, line); - ELPP_INTERNAL_INFO(1, "Parsing line: " << line); - base::utils::Str::trim(line); - if (Configurations::Parser::isComment(line)) continue; - Configurations::Parser::ignoreComments(&line); - base::utils::Str::trim(line); - if (line.size() > 2 && base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationLoggerId))) { - if (!ss.str().empty() && logger != nullptr) { - configure(); - } - ss.str(std::string("")); - line = line.substr(2); - base::utils::Str::trim(line); - if (line.size() > 1) { - ELPP_INTERNAL_INFO(1, "Getting logger: '" << line << "'"); - logger = getLogger(line); - } - } else { - ss << line << "\n"; - } - } - if (!ss.str().empty() && logger != nullptr) { - configure(); - } -} - -bool Loggers::configureFromArg(const char* argKey) { -#if defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS) - ELPP_UNUSED(argKey); -#else - if (!Helpers::commandLineArgs()->hasParamWithValue(argKey)) { - return false; - } - configureFromGlobal(Helpers::commandLineArgs()->getParamValue(argKey)); -#endif // defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS) - return true; -} - -void Loggers::flushAll(void) { - ELPP->registeredLoggers()->flushAll(); -} - -void Loggers::setVerboseLevel(base::type::VerboseLevel level) { - ELPP->vRegistry()->setLevel(level); -} - -base::type::VerboseLevel Loggers::verboseLevel(void) { - return ELPP->vRegistry()->level(); -} - -void Loggers::setVModules(const char* modules) { - if (ELPP->vRegistry()->vModulesEnabled()) { - ELPP->vRegistry()->setModules(modules); - } -} - -void Loggers::clearVModules(void) { - ELPP->vRegistry()->clearModules(); -} - -// VersionInfo - -const std::string VersionInfo::version(void) { - return std::string("9.96.7"); -} -/// @brief Release date of current version -const std::string VersionInfo::releaseDate(void) { - return std::string("24-11-2018 0728hrs"); -} - -} // namespace el diff --git a/hnurm_camera/README.md b/hnurm_camera/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ff79fe3b5e294de61f8136007ee239814e588cc2 --- /dev/null +++ b/hnurm_camera/README.md @@ -0,0 +1,10 @@ +# Pixel Type Map + +| **Pixel Type** | **Dec** | **Hex** | | +|----------------|----------|-----------|-----| +| Bayer GR8 | 17301512 | 0x1080008 | | +| Bayer RG8 | 17301513 | 0x1080009 | 016 | +| Bayer GB8 | 17301514 | 0x108000A | 013 | +| Bayer BG8 | 17301515 | 0x108000B | | +| BGR8 Packed | 35127317 | 0x2180015 | | + diff --git a/hnurm_camera/include/hnurm_camera/Camera.h b/hnurm_camera/include/hnurm_camera/Camera.h index e7c8bce2972154886219ab88a76f9cc9a3efcb56..dee232a884b57f99de0a1352f579e4545c0dc4ce 100755 --- a/hnurm_camera/include/hnurm_camera/Camera.h +++ b/hnurm_camera/include/hnurm_camera/Camera.h @@ -17,7 +17,7 @@ class HKcam { public: - explicit HKcam(std::shared_ptr node); + explicit HKcam(const std::shared_ptr &node); ~HKcam(); @@ -27,10 +27,12 @@ public: bool CloseCam(); - bool GetFrame(cv::Mat &img); + bool GetFrame(std::vector &img); void SetParam(); + void prepare_convert(uint8_t *dstData); + private: // state num int nRet; @@ -45,13 +47,15 @@ private: unsigned char *pData; // format of frame ,read from camera - MV_FRAME_OUT_INFO_EX stImageInfo {}; + MV_FRAME_OUT_INFO_EX stImageInfo {}; + MV_CC_PIXEL_CONVERT_PARAM_EX stConvertParam {}; rclcpp::Node::SharedPtr _node; rclcpp::Logger _logger; std::string _id = "none"; +public: int _nImageOrientation = 0; int _nWidth = 1'280; int _nHeight = 720; @@ -67,6 +71,7 @@ private: float _fGain = 8; int _nBlackLevelValue = 30; bool _bEnableBlackLevel = false; + int _nBayerCvtQuality = 3; }; // HKcam diff --git a/hnurm_camera/include/hnurm_camera/CameraParams.h b/hnurm_camera/include/hnurm_camera/CameraParams.h index b11fb3e0d02597cd6c59ee98a37c453f0b0e13c1..853c96f75926202864743cd1ce4dc352a338ea82 100755 --- a/hnurm_camera/include/hnurm_camera/CameraParams.h +++ b/hnurm_camera/include/hnurm_camera/CameraParams.h @@ -2,966 +2,1221 @@ #ifndef _MV_CAMERA_PARAMS_H_ #define _MV_CAMERA_PARAMS_H_ -#include "hnurm_camera/PixelType.h" +#include "PixelType.h" #ifndef __cplusplus -typedef char bool; -#define true 1 -#define false 0 +typedef char bool; +#define true 1 +#define false 0 #endif -/// \~chinese -/// 设备类型定义 -/// \~english -/// Device Type Definition -#define MV_UNKNOW_DEVICE 0x00000000 ///< \~chinese 未知设备类型,保留意义 \~english Unknown Device Type, Reserved -#define MV_GIGE_DEVICE 0x00000001 ///< \~chinese GigE设备 \~english GigE Device -#define MV_1394_DEVICE 0x00000002 ///< \~chinese 1394-a/b 设备 \~english 1394-a/b Device -#define MV_USB_DEVICE 0x00000004 ///< \~chinese USB 设备 \~english USB Device -#define MV_CAMERALINK_DEVICE 0x00000008 ///< \~chinese CamLink设备 \~english CamLink Device - -/// \~chinese GigE设备信息 \~english GigE device info +/// \~chinese ʽ \~english The Method of Sorting +typedef enum _MV_SORT_METHOD_ +{ + SortMethod_SerialNumber = 0, ///< \~chinese к \~english Sorting by SerialNumber + SortMethod_UserID = 1, ///< \~chinese ûԶ \~english Sorting by UserID + SortMethod_CurrentIP_ASC = 2, ///< \~chinese ǰIPַ \~english Sorting by current IPAscending + SortMethod_CurrentIP_DESC = 3, ///< \~chinese ǰIPַ򣨽 \~english Sorting by current IPDescending + +}MV_SORT_METHOD; + + +/// \~chinese GigE豸Ϣ \~english GigE device info typedef struct _MV_GIGE_DEVICE_INFO_ { - unsigned int nIpCfgOption; - unsigned int nIpCfgCurrent; ///< \~chinese \~english IP configuration:bit31-static bit30-dhcp bit29-lla - unsigned int nCurrentIp; - unsigned int nCurrentSubNetMask; ///< \~chinese \~english curtent subnet mask - unsigned int nDefultGateWay; ///< \~chinese \~english current gateway - unsigned char chManufacturerName[32]; - unsigned char chModelName[32]; - unsigned char chDeviceVersion[32]; - unsigned char chManufacturerSpecificInfo[48]; - unsigned char chSerialNumber[16]; - unsigned char chUserDefinedName[16]; - unsigned int nNetExport; ///< \~chinese 网口IP地址 \~english NetWork IP Address - - unsigned int nReserved[4]; -} MV_GIGE_DEVICE_INFO; - -#define INFO_MAX_BUFFER_SIZE 64 - -/// \~chinese USB设备信息 \~english USB device info + unsigned int nIpCfgOption; ///< [OUT] \~chinese IPѡ \~english IP Configuration Options + unsigned int nIpCfgCurrent; ///< [OUT] \~chinese ǰIP \~english IP Configuration + unsigned int nCurrentIp; ///< [OUT] \~chinese ǰIPַ \~english Current Ip + unsigned int nCurrentSubNetMask; ///< [OUT] \~chinese ǰ \~english Curtent Subnet Mask + unsigned int nDefultGateWay; ///< [OUT] \~chinese ǰ \~english Current Gateway + unsigned char chManufacturerName[32]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chModelName[32]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chDeviceVersion[32]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerSpecificInfo[48]; ///< [OUT] \~chinese ̵ľϢ \~english Manufacturer Specific Information + unsigned char chSerialNumber[16]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chUserDefinedName[16]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned int nNetExport; ///< [OUT] \~chinese IPַ \~english NetWork IP Address + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved + +}MV_GIGE_DEVICE_INFO; + +///< \~chinese ϢС \~english Maximum data information size +#define INFO_MAX_BUFFER_SIZE 64 + +/// \~chinese USB豸Ϣ \~english USB device info typedef struct _MV_USB3_DEVICE_INFO_ { - unsigned char CrtlInEndPoint; ///< \~chinese 控制输入端点 \~english Control input endpoint - unsigned char CrtlOutEndPoint; ///< \~chinese 控制输出端点 \~english Control output endpoint - unsigned char StreamEndPoint; ///< \~chinese 流端点 \~english Flow endpoint - unsigned char EventEndPoint; ///< \~chinese 事件端点 \~english Event endpoint - unsigned short idVendor; ///< \~chinese 供应商ID号 \~english Vendor ID Number - unsigned short idProduct; ///< \~chinese 产品ID号 \~english Device ID Number - unsigned int nDeviceNumber; ///< \~chinese 设备序列号 \~english Device Serial Number - unsigned char chDeviceGUID[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 设备GUID号 \~english Device GUID Number - unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 供应商名字 \~english Vendor Name - unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 型号名字 \~english Model Name - unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 家族名字 \~english Family Name - unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 设备版本号 \~english Device Version - unsigned char - chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 制造商名字 \~english Manufacturer Name - unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 序列号 \~english Serial Number - unsigned char - chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 用户自定义名字 \~english User Defined Name - unsigned int nbcdUSB; ///< \~chinese 支持的USB协议 \~english Support USB Protocol - - unsigned int nReserved[3]; ///< \~chinese 保留字节 \~english Reserved bytes -} MV_USB3_DEVICE_INFO; - -/// \~chinese -/// \brief CamLink设备信息 -/// \~english -/// \brief CamLink device info + unsigned char CrtlInEndPoint; ///< [OUT] \~chinese ˵ \~english Control input endpoint + unsigned char CrtlOutEndPoint; ///< [OUT] \~chinese ˵ \~english Control output endpoint + unsigned char StreamEndPoint; ///< [OUT] \~chinese ˵ \~english Flow endpoint + unsigned char EventEndPoint; ///< [OUT] \~chinese ¼˵ \~english Event endpoint + unsigned short idVendor; ///< [OUT] \~chinese ӦID \~english Vendor ID Number + unsigned short idProduct; ///< [OUT] \~chinese ƷID \~english Device ID Number + unsigned int nDeviceNumber; ///< [OUT] \~chinese 豸 \~english Device Number + unsigned char chDeviceGUID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸GUID \~english Device GUID Number + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Ӧ \~english Vendor Name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Family Name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned int nbcdUSB; ///< [OUT] \~chinese ֵ֧USBЭ \~english Support USB Protocol + unsigned int nDeviceAddress; ///< [OUT] \~chinese 豸ַ \~english Device Address + unsigned int nReserved[2]; ///< \~chinese Ԥ \~english Reserved + +}MV_USB3_DEVICE_INFO; + +/// \~chinese CameraLink豸Ϣ \~english CameraLink device info typedef struct _MV_CamL_DEV_INFO_ { - unsigned char chPortID[INFO_MAX_BUFFER_SIZE]; - unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; - unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; - unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; - unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; - unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; + unsigned char chPortID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ں \~english Port ID + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Family Name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number - unsigned int nReserved[38]; -} MV_CamL_DEV_INFO; + unsigned int nReserved[38]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese -/// \brief 设备信息 -/// \~english -/// \brief Device info -typedef struct _MV_CC_DEVICE_INFO_ -{ - unsigned short nMajorVer; - unsigned short nMinorVer; - unsigned int nMacAddrHigh; ///< \~chinese MAC 地址\~english MAC Address - unsigned int nMacAddrLow; +}MV_CamL_DEV_INFO; - unsigned int nTLayerType; ///< \~chinese 设备传输层协议类型,e.g. MV_GIGE_DEVICE\~english Device Transport Layer - ///< Protocol Type, e.g. MV_GIGE_DEVICE - unsigned int nReserved[4]; + +///< \~chinese CoaXPressϢ \~english CoaXPress device information +typedef struct _MV_CXP_DEVICE_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; /// \~chinese ɼID \~english Interface ID of Frame Grabber + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese Ӧ \~english Vendor name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ͺ \~english Model name + unsigned char chManufacturerInfo[INFO_MAX_BUFFER_SIZE];///< \~chinese Ϣ \~english Manufacturer information + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 汾 \~english Device version + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< \~chinese к \~english Serial number + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ûԶ \~english User defined name + unsigned char chDeviceID[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ID \~english Device ID + unsigned int nReserved[7]; ///< \~chinese ֶ \~english Reserved +}MV_CXP_DEVICE_INFO; + +///< \~chinese ɼCamera LinkϢ \~english Camera Link device information on frame grabber +typedef struct _MV_CML_DEVICE_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; /// \~chinese ɼID \~english Interface ID of Frame Grabber + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese Ӧ \~english Vendor name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ͺ \~english Model name + unsigned char chManufacturerInfo[INFO_MAX_BUFFER_SIZE];///< \~chinese Ϣ \~english Manufacturer information + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 汾 \~english Device version + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< \~chinese к \~english Serial number + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ûԶ \~english User defined name + unsigned char chDeviceID[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ID \~english Device ID + unsigned int nReserved[7]; ///< \~chinese ֶ \~english Reserved +}MV_CML_DEVICE_INFO; + +///< \~chinese XoFLinkϢ \~english XoFLink device information +typedef struct _MV_XOF_DEVICE_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; /// \~chinese ɼID \~english Interface ID of Frame Grabber + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese Ӧ \~english Vendor name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ͺ \~english Model name + unsigned char chManufacturerInfo[INFO_MAX_BUFFER_SIZE];///< \~chinese Ϣ \~english Manufacturer information + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< \~chinese 汾 \~english Device version + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< \~chinese к \~english Serial number + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ûԶ \~english User defined name + unsigned char chDeviceID[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ID \~english Device ID + unsigned int nReserved[7]; ///< \~chinese ֶ \~english Reserved +}MV_XOF_DEVICE_INFO; + +///< \~chinese 豸Э \~english Device Transport Layer Protocol Type +#define MV_UNKNOW_DEVICE 0x00000000 ///< \~chinese δ֪豸ͣ \~english Unknown Device Type, Reserved +#define MV_GIGE_DEVICE 0x00000001 ///< \~chinese GigE豸 \~english GigE Device +#define MV_1394_DEVICE 0x00000002 ///< \~chinese 1394-a/b 豸 \~english 1394-a/b Device +#define MV_USB_DEVICE 0x00000004 ///< \~chinese USB 豸 \~english USB Device +#define MV_CAMERALINK_DEVICE 0x00000008 ///< \~chinese CameraLink豸 \~english CameraLink Device +#define MV_VIR_GIGE_DEVICE 0x00000010 ///< \~chinese GigE豸 \~english Virtual GigE Device +#define MV_VIR_USB_DEVICE 0x00000020 ///< \~chinese USB豸 \~english Virtual USB Device +#define MV_GENTL_GIGE_DEVICE 0x00000040 ///< \~chinese GigE豸 \~english GenTL GigE Device +#define MV_GENTL_CAMERALINK_DEVICE 0x00000080 ///< \~chinese CameraLink豸 \~english GenTL CameraLink Device +#define MV_GENTL_CXP_DEVICE 0x00000100 ///< \~chinese CoaXPress豸 \~english GenTL CoaXPress Device +#define MV_GENTL_XOF_DEVICE 0x00000200 ///< \~chinese XoF豸 \~english GenTL XoF Device + +/// \~chinese 豸Ϣ \~english Device info +typedef struct _MV_CC_DEVICE_INFO_ +{ + unsigned short nMajorVer; ///< [OUT] \~chinese Ҫ汾 \~english Major Version + unsigned short nMinorVer; ///< [OUT] \~chinese Ҫ汾 \~english Minor Version + unsigned int nMacAddrHigh; ///< [OUT] \~chinese MACַ \~english High MAC Address + unsigned int nMacAddrLow; ///< [OUT] \~chinese MACַ \~english Low MAC Address + unsigned int nTLayerType; ///< [OUT] \~chinese 豸Э \~english Device Transport Layer Protocol Type + + unsigned int nDevTypeInfo; ///< [OUT] \~chinese 豸Ϣ \~english Device Type Info + ///< \~chinese 豸͹ \~english Device Type Rules + ///< 7 - 0 bit: \~chinese Ԥ \~english Reserved + ///< 15 - 8 bit \~chinese Ʒ \~english Product subtype + ///< 23 - 16 bit \~chinese Ʒ \~english product type + ///< 31 - 24bit \~chinese Ʒ \~english Product Line Ʒ //eg: 0x01 ׼Ʒ/2D Produces; 0x02 3DƷ/3D Produces ; 0x03 IDƷ/Intelligent ID products + unsigned int nReserved[3]; ///< \~chinese Ԥ \~english Reserved union { - MV_GIGE_DEVICE_INFO stGigEInfo; - MV_USB3_DEVICE_INFO stUsb3VInfo; - MV_CamL_DEV_INFO stCamLInfo; - // more ... - } SpecialInfo; + MV_GIGE_DEVICE_INFO stGigEInfo; ///< [OUT] \~chinese GigE豸Ϣ \~english GigE Device Info + MV_USB3_DEVICE_INFO stUsb3VInfo; ///< [OUT] \~chinese USB豸Ϣ \~english USB Device Info + MV_CamL_DEV_INFO stCamLInfo; ///< [OUT] \~chinese CameraLink豸Ϣ \~english CameraLink Device Info + MV_CML_DEVICE_INFO stCMLInfo; ///< [OUT] \~chinese ɼCameraLink豸Ϣ \~english CameraLink Device Info On Frame Grabber + MV_CXP_DEVICE_INFO stCXPInfo; ///< [OUT] \~chinese ɼCoaXPress豸Ϣ \~english CoaXPress Device Info On Frame Grabber + MV_XOF_DEVICE_INFO stXoFInfo; ///< [OUT] \~chinese ɼXoF豸Ϣ \~english XoF Device Info On Frame Grabber + }SpecialInfo; + +}MV_CC_DEVICE_INFO; + +///< \~chinese ֵ֧Ĵʵ \~english The maximum number of supported transport layer instances +#define MV_MAX_TLS_NUM 8 +///< \~chinese ֵ֧豸 \~english The maximum number of supported devices +#define MV_MAX_DEVICE_NUM 256 + +/// \~chinese 豸Ϣб \~english Device Information List +typedef struct _MV_CC_DEVICE_INFO_LIST_ +{ + unsigned int nDeviceNum; ///< [OUT] \~chinese 豸 \~english Online Device Number + MV_CC_DEVICE_INFO* pDeviceInfo[MV_MAX_DEVICE_NUM]; ///< [OUT] \~chinese ֧256豸 \~english Support up to 256 devices -} MV_CC_DEVICE_INFO; +}MV_CC_DEVICE_INFO_LIST; -/// \~chinese 网络传输的相关信息\~english Network transmission information -typedef struct _MV_NETTRANS_INFO_ + +///< \~chinese ɼ \~english Interface type +#define MV_GIGE_INTERFACE 0x00000001 ///< \~chinese GigE Visionɼ \~english GigE Vision interface +#define MV_CAMERALINK_INTERFACE 0x00000004 ///< \~chinese Camera Linkɼ \~english Camera Link interface +#define MV_CXP_INTERFACE 0x00000008 ///< \~chinese CoaXPressɼ \~english CoaXPress interface +#define MV_XOF_INTERFACE 0x00000010 ///< \~chinese XoFLinkɼ \~english XoFLink interface + +///< \~chinese ֵ֧IJɼ \~english The maximum number of Frame Grabber interface supported +#define MV_MAX_INTERFACE_NUM 64 + +///< \~chinese ɼϢ \~english Interface information +typedef struct _MV_INTERFACE_INFO_ +{ + unsigned int nTLayerType; ///< \~chinese ɼ \~english Interface type + // 16λЧ: bits(0~2), bits(3~7), bits(8-15) + // The lower 16 bits are valid: bits (0~2) represents the function, bits (3~7) represents the device, and bits (8~15) represents the bus + // |15 14 13 12 11 10 9 8 | 7 6 5 4 3 | 2 1 0 | + // +-----------------------------+---------------+---------+ + // | bus | device | func | + unsigned int nPCIEInfo; ///< \~chinese ɼPCIEϢ \~english PCIe slot information of interface + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ɼID \~english Interface ID + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< \~chinese ʾ \~english Display name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< \~chinese к \~english Serial number + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english model name + unsigned char chManufacturer[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english manufacturer name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 汾 \~english device version + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Զ \~english user defined name + unsigned int nReserved[64]; ///< \~chinese ֶ \~english Reserved +}MV_INTERFACE_INFO; + +///< \~chinese ɼϢб \~english Interface Information List +typedef struct _MV_INTERFACE_INFO_LIST_ { - int64_t nReviceDataSize; ///< \~chinese 已接收数据大小 [统计StartGrabbing和StopGrabbing之间的数据量]\~english - ///< Received Data Size [Calculate the Data Size between StartGrabbing and StopGrabbing] - int nThrowFrameCount; ///< \~chinese 丢帧数量\~english Throw frame number - unsigned int nNetRecvFrameCount; - int64_t nRequestResendPacketCount; ///< \~chinese 请求重发包数 - int64_t nResendPacketCount; ///< \~chinese 重发包数 + unsigned int nInterfaceNum; ///< [OUT] \~chinese ɼ \~english Interface Number + MV_INTERFACE_INFO* pInterfaceInfos[MV_MAX_INTERFACE_NUM]; ///< [OUT] \~chinese ɼϢ, ֧64豸 \~english Information of interfaces, support up to 64 interfaces +}MV_INTERFACE_INFO_LIST; -} MV_NETTRANS_INFO; -#define MV_MAX_TLS_NUM \ - 8 ///< \~chinese 最多支持的传输层实例个数\~english The maximum number of supported transport layer instances -#define MV_MAX_DEVICE_NUM 256 ///< \~chinese 最大支持的设备个数\~english The maximum number of supported devices -/// \~chinese -/// \brief 设备信息列表 -/// \~english -/// \brief Device Information List -typedef struct _MV_CC_DEVICE_INFO_LIST_ +/// \~chinese ͨGenTLöٵĽӿϢ \~english Interface Information with GenTL +typedef struct _MV_GENTL_IF_INFO_ { - unsigned int nDeviceNum; ///< \~chinese 在线设备数量\~english Online Device Number - MV_CC_DEVICE_INFO - *pDeviceInfo[MV_MAX_DEVICE_NUM]; ///< \~chinese 支持最多256个设备\~english Support up to 256 devices + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese GenTLӿID \~english Interface ID + unsigned char chTLType[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english GenTL Type + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Interfaceʾ \~english Display Name + unsigned int nCtiIndex; ///< [OUT] \~chinese GenTLctiļ \~english The Index of Cti Files -} MV_CC_DEVICE_INFO_LIST; + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese Chunk内容 \~english The content of ChunkData -typedef struct _MV_CHUNK_DATA_CONTENT_ +}MV_GENTL_IF_INFO; + +///< \~chinese ֵ֧GenTLӿ \~english The maximum number of GenTL interface supported +#define MV_MAX_GENTL_IF_NUM 256 + +/// \~chinese ͨGenTLöٵĽӿϢб \~english Inferface Information List with GenTL +typedef struct _MV_GENTL_IF_INFO_LIST_ { - unsigned char *pChunkData; - unsigned int nChunkID; - unsigned int nChunkLen; + unsigned int nInterfaceNum; ///< [OUT] \~chinese ߽ӿ \~english Online Inferface Number + MV_GENTL_IF_INFO* pIFInfo[MV_MAX_GENTL_IF_NUM]; ///< [OUT] \~chinese ֧256ӿ \~english Support up to 256 inferfaces - unsigned int nReserved[8]; // 保留 +}MV_GENTL_IF_INFO_LIST; -} MV_CHUNK_DATA_CONTENT; +/// \~chinese ͨGenTLöٵ豸Ϣ \~english Device Information with GenTL +typedef struct _MV_GENTL_DEV_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese GenTLӿID \~english Interface ID + unsigned char chDeviceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸ID \~english Device ID + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Ӧ \~english Vendor Name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chTLType[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english GenTL Type + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸ʾ \~english Display Name + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned int nCtiIndex; ///< [OUT] \~chinese GenTLctiļ \~english The Index of Cti Files + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_GENTL_DEV_INFO; + +///< \~chinese ֵ֧GenTL豸 \~english The maximum number of GenTL devices supported +#define MV_MAX_GENTL_DEV_NUM 256 + +/// \~chinese ͨGenTLöٵ豸Ϣб \~english Device Information List with GenTL +typedef struct _MV_GENTL_DEV_INFO_LIST_ +{ + unsigned int nDeviceNum; ///< [OUT] \~chinese 豸 \~english Online Device Number + MV_GENTL_DEV_INFO* pDeviceInfo[MV_MAX_GENTL_DEV_NUM]; ///< [OUT] \~chinese ֧256豸 \~english Support up to 256 devices -/// \~chinese 输出帧的信息\~english Output Frame Information -typedef struct _MV_FRAME_OUT_INFO_ +}MV_GENTL_DEV_INFO_LIST; + +/// \~chinese 豸ķģʽ \~english Device Access Mode +#define MV_ACCESS_Exclusive 1 /// \~chinese ռȨޣAPPֻCCPĴ \~english Exclusive authority, other APP is only allowed to read the CCP register +#define MV_ACCESS_ExclusiveWithSwitch 2 /// \~chinese Դ5ģʽռȨޣȻԶռȨ޴ \~english You can seize the authority from the 5 mode, and then open with exclusive authority +#define MV_ACCESS_Control 3 /// \~chinese ȨޣAPPмĴ \~english Control authority, allows other APP reading all registers +#define MV_ACCESS_ControlWithSwitch 4 /// \~chinese Դ5ģʽռȨޣȻԿȨ޴ \~english You can seize the authority from the 5 mode, and then open with control authority +#define MV_ACCESS_ControlSwitchEnable 5 /// \~chinese ԿɱռĿȨ޴ \~english Open with seized control authority +#define MV_ACCESS_ControlSwitchEnableWithKey 6 /// \~chinese Դ5ģʽռȨޣȻԿɱռĿȨ޴ \~english You can seize the authority from the 5 mode, and then open with seized control authority +#define MV_ACCESS_Monitor 7 /// \~chinese ģʽ豸ڿȨ \~english Open with read mode and is available under control authority + +/// \~chinese Chunk \~english The content of ChunkData +typedef struct _MV_CHUNK_DATA_CONTENT_ { - unsigned short nWidth; ///< \~chinese 图像宽 \~english Image Width - unsigned short nHeight; ///< \~chinese 图像高 \~english Image Height - enum MvGvspPixelType enPixelType; ///< \~chinese 像素格式 \~english Pixel Type + unsigned char* pChunkData; ///< [OUT] \~chinese Chunk \~english Chunk Data + unsigned int nChunkID; ///< [OUT] \~chinese Chunk ID \~english Chunk ID + unsigned int nChunkLen; ///< [OUT] \~chinese Chunkij \~english Chunk Length - unsigned int nFrameNum; ///< \~chinese 帧号 \~english Frame Number - unsigned int nDevTimeStampHigh; ///< \~chinese 时间戳高32位\~english Timestamp high 32 bits - unsigned int nDevTimeStampLow; ///< \~chinese 时间戳低32位\~english Timestamp low 32 bits - unsigned int nReserved0; ///< \~chinese 保留,8字节对齐\~english Reserved, 8-byte aligned - int64_t nHostTimeStamp; ///< \~chinese 主机生成的时间戳\~english Host-generated timestamp + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved - unsigned int nFrameLen; +}MV_CHUNK_DATA_CONTENT; - unsigned int nLostPacket; ///< \~chinese 本帧丢包数\~english Lost Pacekt Number In This Frame - unsigned int nReserved[2]; -} MV_FRAME_OUT_INFO; -/// \~chinese 输出帧的信息\~english Output Frame Information +/// \~chinese ֡Ϣ \~english Output Frame Information typedef struct _MV_FRAME_OUT_INFO_EX_ { - unsigned short nWidth; ///< \~chinese 图像宽 \~english Image Width - unsigned short nHeight; ///< \~chinese 图像高 \~english Image Height - enum MvGvspPixelType enPixelType; ///< \~chinese 像素格式 \~english Pixel Type + unsigned short nWidth; ///< [OUT] \~chinese ͼ(65535nExtendWidth) \~english Image Width (over 65535, use nExtendWidth) + unsigned short nHeight; ///< [OUT] \~chinese ͼ(65535nExtendHeight) \~english Image Height(over 65535, use nExtendHeight) + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel Type - unsigned int nFrameNum; ///< \~chinese 帧号 \~english Frame Number - unsigned int nDevTimeStampHigh; ///< \~chinese 时间戳高32位\~english Timestamp high 32 bits - unsigned int nDevTimeStampLow; ///< \~chinese 时间戳低32位\~english Timestamp low 32 bits - unsigned int nReserved0; ///< \~chinese 保留,8字节对齐\~english Reserved, 8-byte aligned - int64_t nHostTimeStamp; ///< \~chinese 主机生成的时间戳\~english Host-generated timestamp + unsigned int nFrameNum; ///< [OUT] \~chinese ֡ \~english Frame Number + unsigned int nDevTimeStampHigh; ///< [OUT] \~chinese ʱ32λ \~english Timestamp high 32 bits + unsigned int nDevTimeStampLow; ///< [OUT] \~chinese ʱ32λ \~english Timestamp low 32 bits + unsigned int nReserved0; ///< [OUT] \~chinese 8ֽڶ \~english Reserved, 8-byte aligned + int64_t nHostTimeStamp; ///< [OUT] \~chinese ɵʱ \~english Host-generated timestamp - unsigned int nFrameLen; + unsigned int nFrameLen; ///< [OUT] \~chinese ֡ij \~english The Length of Frame - /// \~chinese 设备水印时标\~english Device frame-specific time scale - unsigned int nSecondCount; - unsigned int nCycleCount; - unsigned int nCycleOffset; + /// \~chinese 豸ˮӡʱ \~english Device frame-specific time scale + unsigned int nSecondCount; ///< [OUT] \~chinese \~english The Seconds + unsigned int nCycleCount; ///< [OUT] \~chinese \~english The Count of Cycle + unsigned int nCycleOffset; ///< [OUT] \~chinese ƫ \~english The Offset of Cycle - float fGain; - float fExposureTime; - unsigned int nAverageBrightness; ///< \~chinese 平均亮度\~english Average brightness + float fGain; ///< [OUT] \~chinese \~english Gain + float fExposureTime; ///< [OUT] \~chinese عʱ \~english Exposure Time + unsigned int nAverageBrightness; ///< [OUT] \~chinese ƽ \~english Average brightness - /// \~chinese 白平衡相关\~english White balance - unsigned int nRed; - unsigned int nGreen; - unsigned int nBlue; + /// \~chinese ƽ \~english White balance + unsigned int nRed; ///< [OUT] \~chinese ɫ \~english Red + unsigned int nGreen; ///< [OUT] \~chinese ɫ \~english Green + unsigned int nBlue; ///< [OUT] \~chinese ɫ \~english Blue - unsigned int nFrameCounter; - unsigned int nTriggerIndex; ///< \~chinese 触发计数\~english Trigger Counting + unsigned int nFrameCounter; ///< [OUT] \~chinese ֡ \~english Frame Counter + unsigned int nTriggerIndex; ///< [OUT] \~chinese \~english Trigger Counting - unsigned int nInput; ///< \~chinese 输入\~english Input - unsigned int nOutput; ///< \~chinese 输出\~english Output + unsigned int nInput; ///< [OUT] \~chinese \~english Input + unsigned int nOutput; ///< [OUT] \~chinese \~english Output - /// \~chinese ROI区域\~english ROI Region - unsigned short nOffsetX; - unsigned short nOffsetY; - unsigned short nChunkWidth; - unsigned short nChunkHeight; + /// \~chinese ROI \~english ROI Region + unsigned short nOffsetX; ///< [OUT] \~chinese ˮƽƫ \~english OffsetX + unsigned short nOffsetY; ///< [OUT] \~chinese ֱƫ \~english OffsetY + unsigned short nChunkWidth; ///< [OUT] \~chinese Chunk \~english The Width of Chunk + unsigned short nChunkHeight; ///< [OUT] \~chinese Chunk \~english The Height of Chunk - unsigned int nLostPacket; ///< \~chinese 本帧丢包数\~english Lost Pacekt Number In This Frame - - unsigned int nUnparsedChunkNum; ///< \~chinese 未解析的Chunkdata个数 + unsigned int nLostPacket; ///< [OUT] \~chinese ֡ \~english Lost Packet Number In This Frame + unsigned int nUnparsedChunkNum; ///< [OUT] \~chinese δChunkdata \~english Unparsed Chunk Number union { - MV_CHUNK_DATA_CONTENT *pUnparsedChunkContent; - int64_t nAligning; - } UnparsedChunkList; + MV_CHUNK_DATA_CONTENT* pUnparsedChunkContent; ///< [OUT] \~chinese δChunk \~english Unparsed Chunk Content + int64_t nAligning; ///< [OUT] \~chinese У׼ \~english Aligning + }UnparsedChunkList; + + unsigned int nExtendWidth; ///< [OUT] \~chinese ͼ(չ) \~english Image Width + unsigned int nExtendHeight; ///< [OUT] \~chinese ͼ(չ) \~english Image Height + + unsigned int nReserved[34]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[36]; // 保留 -} MV_FRAME_OUT_INFO_EX; +}MV_FRAME_OUT_INFO_EX; -/// \~chinese 图像结构体,输出图像指针地址及图像信息\~english Image Struct, output the pointer of Image and the -/// information of the specific image +/// \~chinese ͼṹ壬ͼַͼϢ \~english Image Struct, output the pointer of Image and the information of the specific image typedef struct _MV_FRAME_OUT_ { - unsigned char *pBufAddr; ///< \~chinese 图像指针地址\~english pointer of image - MV_FRAME_OUT_INFO_EX stFrameInfo; ///< \~chinese 图像信息\~english information of the specific image + unsigned char* pBufAddr; ///< [OUT] \~chinese ͼַָ \~english pointer of image + MV_FRAME_OUT_INFO_EX stFrameInfo; ///< [OUT] \~chinese ͼϢ \~english information of the specific image + + unsigned int nRes[16]; ///< \~chinese Ԥ \~english Reserved + +}MV_FRAME_OUT; + +/// \~chinese ȡ \~english The strategy of Grabbing +typedef enum _MV_GRAB_STRATEGY_ +{ + MV_GrabStrategy_OneByOne = 0, ///< \~chinese Ӿɵһ֡һ֡Ļȡͼ \~english Grab One By One + MV_GrabStrategy_LatestImagesOnly = 1, ///< \~chinese ȡбµһ֡ͼ \~english Grab The Latest Image + MV_GrabStrategy_LatestImages = 2, ///< \~chinese ȡбµͼ \~english Grab The Latest Images + MV_GrabStrategy_UpcomingImage = 3, ///< \~chinese ȴһ֡ͼ \~english Grab The Upcoming Image + +}MV_GRAB_STRATEGY; + +/// \~chinese 紫Ϣ \~english Network transmission information +typedef struct _MV_NETTRANS_INFO_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС[StartStop֮] \~english Received Data Size + int nThrowFrameCount; ///< [OUT] \~chinese ֡ \~english Throw frame number + unsigned int nNetRecvFrameCount; ///< [OUT] \~chinese ѽյ֡ \~english Received Frame Count + int64_t nRequestResendPacketCount; ///< [OUT] \~chinese ط \~english Request Resend Packet Count + int64_t nResendPacketCount; ///< [OUT] \~chinese ط \~english Resend Packet Count + +}MV_NETTRANS_INFO; + +/// \~chinese Ϣ \~english Information Type +#define MV_MATCH_TYPE_NET_DETECT 0x00000001 ///< \~chinese ͶϢ \~english Network traffic and packet loss information +#define MV_MATCH_TYPE_USB_DETECT 0x00000002 ///< \~chinese hostյU3V豸ֽ \~english The total number of bytes host received from U3V device + +/// \~chinese ȫƥһϢṹ \~english A fully matched information structure +typedef struct _MV_ALL_MATCH_INFO_ +{ + unsigned int nType; ///< [IN] \~chinese ҪϢͣe.g. MV_MATCH_TYPE_NET_DETECT \~english Information type need to output ,e.g. MV_MATCH_TYPE_NET_DETECT + void* pInfo; ///< [OUT] \~chinese Ϣ棬ɵ߷ \~english Output information cache, which is allocated by the caller + unsigned int nInfoSize; ///< [IN] \~chinese ϢĴС \~english Information cache size + +}MV_ALL_MATCH_INFO; + +/// \~chinese ͶϢṹ壬ӦΪ MV_MATCH_TYPE_NET_DETECT \~english Network traffic and packet loss feedback structure, the corresponding type is MV_MATCH_TYPE_NET_DETECT +typedef struct _MV_MATCH_INFO_NET_DETECT_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС[StartStop֮] \~english Received data size + int64_t nLostPacketCount; ///< [OUT] \~chinese ʧİ \~english Number of packets lost + unsigned int nLostFrameCount; ///< [OUT] \~chinese ֡ \~english Number of frames lost + unsigned int nNetRecvFrameCount; ///< [OUT] \~chinese \~english Received Frame Count + int64_t nRequestResendPacketCount; ///< [OUT] \~chinese ط \~english Request Resend Packet Count + int64_t nResendPacketCount; ///< [OUT] \~chinese ط \~english Resend Packet Count - unsigned int nRes[16]; ///< \~chinese 保留\~english reserved -} MV_FRAME_OUT; +}MV_MATCH_INFO_NET_DETECT; +/// \~chinese hostյu3v豸˵ֽӦΪ MV_MATCH_TYPE_USB_DETECT \~english The total number of bytes host received from the u3v device side, the corresponding type is MV_MATCH_TYPE_USB_DETECT +typedef struct _MV_MATCH_INFO_USB_DETECT_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [OpenClose֮] \~english Received data size + unsigned int nReceivedFrameCount; ///< [OUT] \~chinese յ֡ \~english Number of frames received + unsigned int nErrorFrameCount; ///< [OUT] \~chinese ֡ \~english Number of error frames + + unsigned int nReserved[2]; ///< \~chinese \~english Reserved + +}MV_MATCH_INFO_USB_DETECT; + +/// \~chinese ʾ֡Ϣ \~english Display frame information typedef struct _MV_DISPLAY_FRAME_INFO_ { - void *hWnd; ///< \~chinese 窗口句柄\~english HWND - unsigned char *pData; ///< \~chinese 显示的数据\~english Data Buffer - unsigned int nDataLen; ///< \~chinese 数据长度\~english Data Size - unsigned short nWidth; ///< \~chinese 图像宽\~english Width - unsigned short nHeight; ///< \~chinese 图像高\~english Height - enum MvGvspPixelType enPixelType; ///< \~chinese 像素格式\~english Pixel format - unsigned int nRes[4]; + void* hWnd; ///< [IN] \~chinese ھ \~english HWND + unsigned char* pData; ///< [IN] \~chinese ʾ \~english Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݳ \~english Data Size + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned int enRenderMode; /// [IN] \~chinese ͼȾʽ 0-Ĭģʽ(Windows GDI/Linux OPENGL), 1-D3Dģʽ(WindowsЧ) \~english Render mode 0-Default Mode 1-D3D Mode + unsigned int nRes[3]; ///< \~chinese \~english Reserved + +}MV_DISPLAY_FRAME_INFO; + + +typedef struct _MV_DISPLAY_FRAME_INFO_EX_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel type + + unsigned char* pImageBuf; ///< [IN] \~chinese ͼ񻺴 \~english Input image buffer + unsigned int nImageBufLen; ///< [IN] \~chinese ͼ񳤶 \~english Input image length + + unsigned int enRenderMode; /// [IN] \~chinese ͼȾʽ 0-Ĭģʽ(Windows GDI/Linux OPENGL), 1-D3Dģʽ(WindowsЧ) \~english Render mode 0-Default Mode 1-D3D Mode + unsigned int nRes[3]; ///< \~chinese \~english Reserved + +}MV_DISPLAY_FRAME_INFO_EX; + +/// \~chinese 3Dݸʽ \~english The saved format for 3D data +enum MV_SAVE_POINT_CLOUD_FILE_TYPE +{ + MV_PointCloudFile_Undefined = 0, ///< \~chinese δĵƸʽ \~english Undefined point cloud format + MV_PointCloudFile_PLY = 1, ///< \~chinese PLYƸʽ \~english The point cloud format named PLY + MV_PointCloudFile_CSV = 2, ///< \~chinese CSVƸʽ \~english The point cloud format named CSV + MV_PointCloudFile_OBJ = 3, ///< \~chinese OBJƸʽ \~english The point cloud format named OBJ + +}; + +/// \~chinese 3Dݵ \~english Save 3D data to buffer +typedef struct _MV_SAVE_POINT_CLOUD_PARAM_ +{ + unsigned int nLinePntNum; ///< [IN] \~chinese еͼ \~english The number of points in each row,which is the width of the image + unsigned int nLineNum; ///< [IN] \~chinese ͼ \~english The number of rows,which is the height of the image -} MV_DISPLAY_FRAME_INFO; + enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese ݵظʽ \~english The pixel format of the input data + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݳ \~english Input data length -/// \~chinese 保存图片格式\~english Save image type + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output pixel data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС(nLinePntNum * nLineNum * (16*3 + 4) + 2048) \~english Output buffer size provided(nLinePntNum * nLineNum * (16*3 + 4) + 2048) + unsigned int nDstBufLen; ///< [OUT] \~chinese ݻ泤 \~english Output pixel data buffer size + MV_SAVE_POINT_CLOUD_FILE_TYPE enPointCloudFileType; ///< [IN] \~chinese ṩĵļ \~english Output point data file type provided + + unsigned int nReserved[8]; ///< \~chinese ֶ \~english Reserved + +}MV_SAVE_POINT_CLOUD_PARAM; + +/// \~chinese ͼƬʽ \~english Save image type enum MV_SAVE_IAMGE_TYPE { - MV_Image_Undefined = 0, - MV_Image_Bmp = 1, - MV_Image_Jpeg = 2, - MV_Image_Png = 3, - MV_Image_Tif = 4, + MV_Image_Undefined = 0, ///< \~chinese δͼʽ \~english Undefined Image Type + MV_Image_Bmp = 1, ///< \~chinese BMPͼʽ \~english BMP Image Type + MV_Image_Jpeg = 2, ///< \~chinese JPEGͼʽ \~english Jpeg Image Type + MV_Image_Png = 3, ///< \~chinese PNGͼʽ \~english Png Image Type + MV_Image_Tif = 4, ///< \~chinese TIFFͼʽ \~english TIFF Image Type + }; -/// \~chinese 图片保存参数\~english Save Image Parameters -typedef struct _MV_SAVE_IMAGE_PARAM_T_ +/// \~chinese ͼƬ \~english Save Image Parameters +typedef struct _MV_SAVE_IMAGE_PARAM_EX3_ { - unsigned char *pData; ///< [IN] \~chinese 输入数据缓存\~english Input Data Buffer - unsigned int nDataLen; ///< [IN] \~chinese 输入数据大小\~english Input Data Size - enum MvGvspPixelType enPixelType; ///< [IN] \~chinese 输入数据的像素格式\~english Input Data Pixel Format - unsigned short nWidth; ///< [IN] \~chinese 图像宽\~english Image Width - unsigned short nHeight; ///< [IN] \~chinese 图像高\~english Image Height + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݳ \~english Input Data length + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Input Data Pixel Format + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬ \~english Output Image length + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + unsigned int nJpgQuality; ///< [IN] \~chinese JPG(50-99]ʽЧ \~english Encoding quality(50-99]Other formats are invalid + - unsigned char *pImageBuffer; ///< [OUT] \~chinese 输出图片缓存\~english Output Image Buffer - unsigned int nImageLen; ///< [OUT] \~chinese 输出图片大小\~english Output Image Size - unsigned int nBufferSize; ///< [IN] \~chinese 提供的输出缓冲区大小\~english Output buffer size provided - enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese 输出图片格式\~english Output Image Format + unsigned int iMethodValue; ///< [IN] \~chinese ֵ 0- 1- 2-ţֵĬΪţ 3-+ \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal 3-Optimal+ -} MV_SAVE_IMAGE_PARAM; + unsigned int nReserved[3]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese 图片保存参数\~english Save Image Parameters -typedef struct _MV_SAVE_IMAGE_PARAM_T_EX_ +}MV_SAVE_IMAGE_PARAM_EX3; + + +// ͼƬļ +typedef struct _MV_SAVE_IMAGE_TO_FILE_PARAM_EX_ { - unsigned char *pData; ///< [IN] \~chinese 输入数据缓存\~english Input Data Buffer - unsigned int nDataLen; ///< [IN] \~chinese 输入数据大小\~english Input Data Size - enum MvGvspPixelType enPixelType; ///< [IN] \~chinese 输入数据的像素格式\~english Input Data Pixel Format - unsigned short nWidth; ///< [IN] \~chinese 图像宽\~english Image Width - unsigned short nHeight; ///< [IN] \~chinese 图像高\~english Image Height + unsigned int nWidth; // [IN] ͼ + unsigned int nHeight; // [IN] ͼ + MvGvspPixelType enPixelType; // [IN] ݵظʽ + unsigned char* pData; // [IN] ݻ + unsigned int nDataLen; // [IN] ݴС + + MV_SAVE_IAMGE_TYPE enImageType; // [IN] ͼƬʽ + char* pcImagePath; // [IN] ļ· - unsigned char *pImageBuffer; ///< [OUT] \~chinese 输出图片缓存\~english Output Image Buffer - unsigned int nImageLen; ///< [OUT] \~chinese 输出图片大小\~english Output Image Size - unsigned int nBufferSize; ///< [IN] \~chinese 提供的输出缓冲区大小\~english Output buffer size provided - enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese 输出图片格式\~english Output Image Format - unsigned int nJpgQuality; ///< [IN] \~chinese JPG编码质量(50-99],其它格式无效\~english Encoding - ///< quality(50-99],Other formats are invalid + unsigned int nQuality; // [IN] JPG(50-99]ʽЧ + int iMethodValue; // [IN] ֵ 0- 1- 2-ţֵĬΪţ 3-+ + unsigned int nReserved[8]; - ///< [IN] \~chinese Bayer格式转为RGB24的插值方法 0-最近邻 1-双线性 2-Hamilton (如果传入其它值则默认为最近邻) - ///< [IN] \~english Interpolation method of convert Bayer to RGB24 0-nearest neighbour 1-bilinearity 2-Hamilton - unsigned int iMethodValue; - unsigned int nReserved[3]; +}MV_SAVE_IMAGE_TO_FILE_PARAM_EX; -} MV_SAVE_IMAGE_PARAM_EX; -/// \~chinese 图像转换结构体 \~english Pixel convert structure -typedef struct _MV_PIXEL_CONVERT_PARAM_T_ +/// \~chinese תǶ \~english Rotation angle +typedef enum _MV_IMG_ROTATION_ANGLE_ { - unsigned short nWidth; ///< [IN] \~chinese 图像宽 \~english Width - unsigned short nHeight; ///< [IN] \~chinese 图像高\~english Height + MV_IMAGE_ROTATE_90 = 1, + MV_IMAGE_ROTATE_180 = 2, + MV_IMAGE_ROTATE_270 = 3, - enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese 源像素格式\~english Source pixel format - unsigned char *pSrcData; ///< [IN] \~chinese 输入数据缓存\~english Input data buffer - unsigned int nSrcDataLen; ///< [IN] \~chinese 输入数据大小\~english Input data size +}MV_IMG_ROTATION_ANGLE; - enum MvGvspPixelType enDstPixelType; ///< [IN] \~chinese 目标像素格式\~english Destination pixel format - unsigned char *pDstBuffer; ///< [OUT] \~chinese 输出数据缓存\~english Output data buffer - unsigned int nDstLen; ///< [OUT] \~chinese 输出数据大小\~english Output data size - unsigned int nDstBufferSize; ///< [IN] \~chinese 提供的输出缓冲区大小\~english Provided outbut buffer size +/// \~chinese ͼתṹ \~english Rotate image structure +typedef struct _MV_CC_ROTATE_IMAGE_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned int nWidth; ///< [IN][OUT] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN][OUT] \~chinese ͼ \~english Height - unsigned int nRes[4]; -} MV_CC_PIXEL_CONVERT_PARAM; + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݳ \~english Input data length -/// \~chinese 录像格式定义\~english Record Format Type -typedef enum _MV_RECORD_FORMAT_TYPE_ + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + + MV_IMG_ROTATION_ANGLE enRotationAngle; ///< [IN] \~chinese תǶ \~english Rotation angle + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_ROTATE_IMAGE_PARAM; + +/// \~chinese ת \~english Flip type +typedef enum _MV_IMG_FLIP_TYPE_ { - MV_FormatType_Undefined = 0, - MV_FormatType_AVI = 1, + MV_FLIP_VERTICAL = 1, + MV_FLIP_HORIZONTAL = 2, -} MV_RECORD_FORMAT_TYPE; +}MV_IMG_FLIP_TYPE; -/// \~chinese 录像参数\~english Record Parameters -typedef struct _MV_CC_RECORD_PARAM_T_ +/// \~chinese ͼתṹ \~english Flip image structure +typedef struct _MV_CC_FLIP_IMAGE_PARAM_T_ { - enum MvGvspPixelType enPixelType; ///< [IN] \~chinese 输入数据的像素格式 + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ \~english Height - unsigned short nWidth; ///< [IN] \~chinese 图像宽(指定目标参数时需为2的倍数) - unsigned short nHeight; ///< [IN] \~chinese 图像高(指定目标参数时需为2的倍数) + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݳ \~english Input data length - float fFrameRate; ///< [IN] \~chinese 帧率fps(1/16-120) - unsigned int nBitRate; ///< [IN] \~chinese 码率kbps(128kbps-16Mbps) + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size - MV_RECORD_FORMAT_TYPE enRecordFmtType; ///< [IN] \~chinese 录像格式 + MV_IMG_FLIP_TYPE enFlipType; ///< [IN] \~chinese ת \~english Flip type - char *strFilePath; ///< [IN] \~chinese 录像文件存放路径(如果路径中存在中文,需转成utf-8) + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved - unsigned int nRes[8]; +}MV_CC_FLIP_IMAGE_PARAM; -} MV_CC_RECORD_PARAM; -/// \~chinese 录像数据\~english Record Data -typedef struct _MV_CC_INPUT_FRAME_INFO_T_ +/// \~chinese תṹ \~english Pixel convert structure +typedef struct _MV_CC_PIXEL_CONVERT_PARAM_EX_ { - unsigned char *pData; ///< [IN] \~chinese 图像数据指针 - unsigned int nDataLen; ///< [IN] \~chinese 图像大小 + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ \~english Height - unsigned int nRes[8]; + enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese Դظʽ \~english Source pixel format + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݳ \~english Input data length -} MV_CC_INPUT_FRAME_INFO; + enum MvGvspPixelType enDstPixelType; ///< [IN] \~chinese Ŀظʽ \~english Destination pixel format + unsigned char* pDstBuffer; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstLen; ///< [OUT] \~chinese ݳ \~english Output data length + unsigned int nDstBufferSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size -/// \~chinese 采集模式\~english Acquisition mode -typedef enum _MV_CAM_ACQUISITION_MODE_ + unsigned int nRes[4]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_PIXEL_CONVERT_PARAM_EX; + + + + + +/// \~chinese Gamma \~english Gamma type +typedef enum _MV_CC_GAMMA_TYPE_ { - MV_ACQ_MODE_SINGLE = 0, ///< \~chinese 单帧模式\~english Single Mode - MV_ACQ_MODE_MUTLI = 1, ///< \~chinese 多帧模式\~english Multi Mode - MV_ACQ_MODE_CONTINUOUS = 2, ///< \~chinese 持续采集模式\~english Continuous Mode + MV_CC_GAMMA_TYPE_NONE = 0, ///< \~chinese \~english Disable + MV_CC_GAMMA_TYPE_VALUE = 1, ///< \~chinese Gammaֵ \~english Gamma value + MV_CC_GAMMA_TYPE_USER_CURVE = 2, ///< \~chinese Gamma \~english Gamma curve + ///< \~chinese 8λ,ȣ256*sizeof(unsigned char) \~english 8bit,length:256*sizeof(unsigned char) + ///< \~chinese 10λ,ȣ1024*sizeof(unsigned short) \~english 10bit,length:1024*sizeof(unsigned short) + ///< \~chinese 12λ,ȣ4096*sizeof(unsigned short) \~english 12bit,length:4096*sizeof(unsigned short) + ///< \~chinese 16λ,ȣ65536*sizeof(unsigned short) \~english 16bit,length:65536*sizeof(unsigned short) + MV_CC_GAMMA_TYPE_LRGB2SRGB = 3, ///< \~chinese linear RGB to sRGB \~english linear RGB to sRGB + MV_CC_GAMMA_TYPE_SRGB2LRGB = 4, ///< \~chinese sRGB to linear RGB(ɫʲֵʱ֧֣ɫУʱЧ) \~english sRGB to linear RGB + +}MV_CC_GAMMA_TYPE; + +// GammaϢ +/// \~chinese GammaϢṹ \~english Gamma info structure +typedef struct _MV_CC_GAMMA_PARAM_T_ +{ + MV_CC_GAMMA_TYPE enGammaType; ///< [IN] \~chinese Gamma \~english Gamma type + float fGammaValue; ///< [IN] \~chinese Gammaֵ:0.1 ~ 4.0 \~english Gamma value:0.1 ~ 4.0 + unsigned char* pGammaCurveBuf; ///< [IN] \~chinese Gamma߻ \~english Gamma curve buffer + unsigned int nGammaCurveBufLen; ///< [IN] \~chinese Gamma߳ \~english Gamma curve buffer size -} MV_CAM_ACQUISITION_MODE; + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese 增益模式\~english Gain Mode -typedef enum _MV_CAM_GAIN_MODE_ +}MV_CC_GAMMA_PARAM; + +/// \~chinese CCM \~english CCM param +typedef struct _MV_CC_CCM_PARAM_T_ { - MV_GAIN_MODE_OFF = 0, ///< \~chinese 关闭\~english Single Mode - MV_GAIN_MODE_ONCE = 1, ///< \~chinese 一次\~english Multi Mode - MV_GAIN_MODE_CONTINUOUS = 2, ///< \~chinese 连续\~english Continuous Mode + bool bCCMEnable; ///< [IN] \~chinese ǷCCM \~english CCM enable + int nCCMat[9]; ///< [IN] \~chinese CCM[-8192~8192] \~english Color correction matrix[-8192~8192] -} MV_CAM_GAIN_MODE; + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese 曝光模式\~english Exposure Mode -typedef enum _MV_CAM_EXPOSURE_MODE_ +}MV_CC_CCM_PARAM; + +/// \~chinese CCM \~english CCM param +typedef struct _MV_CC_CCM_PARAM_EX_T_ { - MV_EXPOSURE_MODE_TIMED = 0, ///< Timed - MV_EXPOSURE_MODE_TRIGGER_WIDTH = 1, ///< TriggerWidth -} MV_CAM_EXPOSURE_MODE; + bool bCCMEnable; ///< [IN] \~chinese ǷCCM \~english CCM enable + int nCCMat[9]; ///< [IN] \~chinese CCM[-65536~65536] \~english Color correction matrix[-65536~65536] + unsigned int nCCMScale; ///< [IN] \~chinese ϵ2,65536 \~english Quantitative scale(Integer power of 2, <= 65536) -/// \~chinese 自动曝光模式 \~english Auto Exposure Mode -typedef enum _MV_CAM_EXPOSURE_AUTO_MODE_ + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_CCM_PARAM_EX; + +/// \~chinese Աȶȵڽṹ \~english Contrast structure +typedef struct _MV_CC_CONTRAST_PARAM_T_ { - MV_EXPOSURE_AUTO_MODE_OFF = 0, ///< \~chinese 关闭\~english Off - MV_EXPOSURE_AUTO_MODE_ONCE = 1, ///< \~chinese 一次\~english Once - MV_EXPOSURE_AUTO_MODE_CONTINUOUS = 2, ///< \~chinese 连续\~english Continuous + unsigned int nWidth; ///< [IN] \~chinese ͼ(С8) \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶(С8) \~english Image Height + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݴС \~english Input data length + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format -} MV_CAM_EXPOSURE_AUTO_MODE; + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length -/// \~chinese 触发模式 \~english Trigger Mode -typedef enum _MV_CAM_TRIGGER_MODE_ + unsigned int nContrastFactor; ///< [IN] \~chinese Աȶֵ[1,10000] \~english Contrast factor,[1,10000] + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_CONTRAST_PARAM; + +/// \~chinese ˮӡϢ \~english Frame-specific information +typedef struct _MV_CC_FRAME_SPEC_INFO_ { - MV_TRIGGER_MODE_OFF = 0, ///< \~chinese 关闭\~english Off - MV_TRIGGER_MODE_ON = 1, ///< \~chinese 打开\~english ON + /// \~chinese 豸ˮӡʱ \~english Device frame-specific time scale + unsigned int nSecondCount; ///< [OUT] \~chinese \~english The Seconds + unsigned int nCycleCount; ///< [OUT] \~chinese \~english The Count of Cycle + unsigned int nCycleOffset; ///< [OUT] \~chinese ƫ \~english The Offset of Cycle -} MV_CAM_TRIGGER_MODE; + float fGain; ///< [OUT] \~chinese \~english Gain + float fExposureTime; ///< [OUT] \~chinese عʱ \~english Exposure Time + unsigned int nAverageBrightness; ///< [OUT] \~chinese ƽ \~english Average brightness -typedef enum _MV_CAM_GAMMA_SELECTOR_ + /// \~chinese ƽ \~english White balance + unsigned int nRed; ///< [OUT] \~chinese ɫ \~english Red + unsigned int nGreen; ///< [OUT] \~chinese ɫ \~english Green + unsigned int nBlue; ///< [OUT] \~chinese ɫ \~english Blue + + unsigned int nFrameCounter; ///< [OUT] \~chinese ֡ \~english Frame Counter + unsigned int nTriggerIndex; ///< [OUT] \~chinese \~english Trigger Counting + + unsigned int nInput; ///< [OUT] \~chinese \~english Input + unsigned int nOutput; ///< [OUT] \~chinese \~english Output + + /// \~chinese ROI \~english ROI Region + unsigned short nOffsetX; ///< [OUT] \~chinese ˮƽƫ \~english OffsetX + unsigned short nOffsetY; ///< [OUT] \~chinese ֱƫ \~english OffsetY + unsigned short nFrameWidth; ///< [OUT] \~chinese ˮӡ \~english The Width of Chunk + unsigned short nFrameHeight; ///< [OUT] \~chinese ˮӡ \~english The Height of Chunk + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_FRAME_SPEC_INFO; + +/// \~chinese \~english High Bandwidth decode structure +typedef struct _MV_CC_HB_DECODE_PARAM_T_ { - MV_GAMMA_SELECTOR_USER = 1, - MV_GAMMA_SELECTOR_SRGB = 2, + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcLen; ///< [IN] \~chinese ݴС \~english Input data size -} MV_CAM_GAMMA_SELECTOR; + unsigned int nWidth; ///< [OUT] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [OUT] \~chinese ͼ \~english Height + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + enum MvGvspPixelType enDstPixelType; ///< [OUT] \~chinese ظʽ \~english Output pixel format -typedef enum _MV_CAM_BALANCEWHITE_AUTO_ + MV_CC_FRAME_SPEC_INFO stFrameSpecInfo; ///< [OUT] \~chinese ˮӡϢ \~english Frame Spec Info + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_HB_DECODE_PARAM; + +/// \~chinese ¼ʽ \~english Record Format Type +typedef enum _MV_RECORD_FORMAT_TYPE_ { - MV_BALANCEWHITE_AUTO_OFF = 0, - MV_BALANCEWHITE_AUTO_ONCE = 2, - MV_BALANCEWHITE_AUTO_CONTINUOUS = 1, ///< \~chinese 连续\~english Continuous + MV_FormatType_Undefined = 0, ///< \~chinese δ¼ʽ \~english Undefined Recode Format Type + MV_FormatType_AVI = 1, ///< \~chinese AVI¼ʽ \~english AVI Recode Format Type -} MV_CAM_BALANCEWHITE_AUTO; +}MV_RECORD_FORMAT_TYPE; -typedef enum _MV_CAM_TRIGGER_SOURCE_ +/// \~chinese ¼ \~english Record Parameters +typedef struct _MV_CC_RECORD_PARAM_T_ { - MV_TRIGGER_SOURCE_LINE0 = 0, - MV_TRIGGER_SOURCE_LINE1 = 1, - MV_TRIGGER_SOURCE_LINE2 = 2, - MV_TRIGGER_SOURCE_LINE3 = 3, - MV_TRIGGER_SOURCE_COUNTER0 = 4, + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Pixel Type - MV_TRIGGER_SOURCE_SOFTWARE = 7, - MV_TRIGGER_SOURCE_FrequencyConverter = 8, + unsigned short nWidth; ///< [IN] \~chinese ͼ(2ı) \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ(2ı) \~english Height -} MV_CAM_TRIGGER_SOURCE; + float fFrameRate; ///< [IN] \~chinese ֡fps(1/16) \~english The Rate of Frame + unsigned int nBitRate; ///< [IN] \~chinese kbps(128-16*1024) \~english The Rate of Bitrate -typedef enum _MV_GIGE_TRANSMISSION_TYPE_ + MV_RECORD_FORMAT_TYPE enRecordFmtType; ///< [IN] \~chinese ¼ʽ \~english Recode Format Type + + char* strFilePath; ///< [IN] \~chinese ¼ļ·(·дģתutf-8) \~english File Path + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_RECORD_PARAM; + +/// \~chinese ͼ \~english Input Data +typedef struct _MV_CC_INPUT_FRAME_INFO_T_ { - MV_GIGE_TRANSTYPE_UNICAST = 0x0, ///< \~chinese 表示单播(默认)\~english Unicast mode - MV_GIGE_TRANSTYPE_MULTICAST = 0x1, ///< \~chinese 表示组播\~english Multicast mode - MV_GIGE_TRANSTYPE_LIMITEDBROADCAST - = 0x2, ///< \~chinese 表示局域网内广播,暂不支持\~english Limited broadcast mode,not support - MV_GIGE_TRANSTYPE_SUBNETBROADCAST - = 0x3, ///< \~chinese 表示子网内广播,暂不支持\~english Subnet broadcast mode,not support - MV_GIGE_TRANSTYPE_CAMERADEFINED - = 0x4, ///< \~chinese 表示从相机获取,暂不支持\~english Transtype from camera,not support - MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT - = 0x5, ///< \~chinese 表示用户自定义应用端接收图像数据Port号\~english User Defined Receive Data Port - MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV - = 0x00010000, ///< \~chinese 表示设置了单播,但本实例不接收图像数据\~english Unicast without receive data - MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV - = 0x00010001, ///< \~chinese 表示组播模式,但本实例不接收图像数据\~english Multicast without receive data -} MV_GIGE_TRANSMISSION_TYPE; - -// GigEVision IP Configuration -#define MV_IP_CFG_STATIC 0x05000000 -#define MV_IP_CFG_DHCP 0x06000000 -#define MV_IP_CFG_LLA 0x04000000 - -// GigEVision Net Transfer Mode -#define MV_NET_TRANS_DRIVER 0x00000001 -#define MV_NET_TRANS_SOCKET 0x00000002 - -// CameraLink Baud Rates (CLUINT32) -#define MV_CAML_BAUDRATE_9600 0x00000001 -#define MV_CAML_BAUDRATE_19200 0x00000002 -#define MV_CAML_BAUDRATE_38400 0x00000004 -#define MV_CAML_BAUDRATE_57600 0x00000008 -#define MV_CAML_BAUDRATE_115200 0x00000010 -#define MV_CAML_BAUDRATE_230400 0x00000020 -#define MV_CAML_BAUDRATE_460800 0x00000040 -#define MV_CAML_BAUDRATE_921600 0x00000080 -#define MV_CAML_BAUDRATE_AUTOMAX 0x40000000 - -/// \~chinese 信息类型\~english Information Type -#define MV_MATCH_TYPE_NET_DETECT \ - 0x00000001 ///< \~chinese 网络流量和丢包信息\~english Network traffic and packet loss information -#define MV_MATCH_TYPE_USB_DETECT \ - 0x00000002 ///< \~chinese host接收到来自U3V设备的字节总数\~english The total number of bytes host received from U3V - ///< device - -/// \~chinese 某个节点对应的子节点个数最大值\~english The maximum number of child nodes corresponding to a node -#define MV_MAX_XML_NODE_NUM_C 128 - -/// \~chinese 节点名称字符串最大长度\~english The maximum length of node name string -#define MV_MAX_XML_NODE_STRLEN_C 64 - -/// \~chinese 节点String值最大长度\~english The maximum length of Node String -#define MV_MAX_XML_STRVALUE_STRLEN_C 64 - -/// \~chinese 节点描述字段最大长度\~english The maximum length of the node description field -#define MV_MAX_XML_DISC_STRLEN_C 512 - -/// \~chinese 最多的单元数\~englishThe maximum number of units -#define MV_MAX_XML_ENTRY_NUM 10 - -/// \~chinese 父节点个数上限\~english The maximum number of parent nodes -#define MV_MAX_XML_PARENTS_NUM 8 - -/// \~chinese 每个已经实现单元的名称长度\~english The length of the name of each unit that has been implemented -#define MV_MAX_XML_SYMBOLIC_STRLEN_C 64 - -#define MV_MAX_XML_SYMBOLIC_NUM 64 - -/// \~chinese 全匹配的一种信息结构体\~english A fully matched information structure -typedef struct _MV_ALL_MATCH_INFO_ + unsigned char* pData; ///< [IN] \~chinese ͼָ \~english Record Data + unsigned int nDataLen; ///< [IN] \~chinese ͼС \~english The Length of Record Data + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_INPUT_FRAME_INFO; + +/// \~chinese ɼģʽ \~english Acquisition mode +typedef enum _MV_CAM_ACQUISITION_MODE_ { - unsigned int nType; ///< \~chinese 需要输出的信息类型,e.g. MV_MATCH_TYPE_NET_DETECT\~english Information type need - ///< to output ,e.g. MV_MATCH_TYPE_NET_DETECT - void *pInfo; ///< \~chinese 输出的信息缓存,由调用者分配\~english Output information cache, which is allocated by - ///< the caller - unsigned int nInfoSize; ///< \~chinese 信息缓存的大小\~english Information cache size + MV_ACQ_MODE_SINGLE = 0, ///< \~chinese ֡ģʽ \~english Single Mode + MV_ACQ_MODE_MUTLI = 1, ///< \~chinese ֡ģʽ \~english Multi Mode + MV_ACQ_MODE_CONTINUOUS = 2, ///< \~chinese ɼģʽ \~english Continuous Mode -} MV_ALL_MATCH_INFO; +}MV_CAM_ACQUISITION_MODE; -/// \~chinese 网络流量和丢包信息反馈结构体,对应类型为 MV_MATCH_TYPE_NET_DETECT -/// \~en:Network traffic and packet loss feedback structure, the corresponding type is MV_MATCH_TYPE_NET_DETECT -typedef struct _MV_MATCH_INFO_NET_DETECT_ +/// \~chinese ģʽ \~english Gain Mode +typedef enum _MV_CAM_GAIN_MODE_ { - int64_t nReviceDataSize; ///< \~chinese 已接收数据大小 [统计StartGrabbing和StopGrabbing之间的数据量]\~english - ///< Received data size - int64_t nLostPacketCount; ///< \~chinese 丢失的包数量\~english Number of packets lost - unsigned int nLostFrameCount; ///< \~chinese 丢帧数量\~english Number of frames lost - unsigned int nNetRecvFrameCount; ///< \~chinese 保留\~english Reserved - int64_t nRequestResendPacketCount; ///< \~chinese 请求重发包数 - int64_t nResendPacketCount; ///< \~chinese 重发包数 -} MV_MATCH_INFO_NET_DETECT; - -/// \~chinese host收到从u3v设备端的总字节数,对应类型为 MV_MATCH_TYPE_USB_DETECT\~english The total number of bytes host -/// received from the u3v device side, the corresponding type is MV_MATCH_TYPE_USB_DETECT -typedef struct _MV_MATCH_INFO_USB_DETECT_ + MV_GAIN_MODE_OFF = 0, ///< \~chinese ر \~english Single Mode + MV_GAIN_MODE_ONCE = 1, ///< \~chinese һ \~english Multi Mode + MV_GAIN_MODE_CONTINUOUS = 2, ///< \~chinese \~english Continuous Mode + +}MV_CAM_GAIN_MODE; + +/// \~chinese عģʽ \~english Exposure Mode +typedef enum _MV_CAM_EXPOSURE_MODE_ { - int64_t nReviceDataSize; ///< \~chinese 已接收数据大小 [统计OpenDevicce和CloseDevice之间的数据量]\~english - ///< Received data size - unsigned int nRevicedFrameCount; ///< \~chinese 已收到的帧数\~english Number of frames received - unsigned int nErrorFrameCount; ///< \~chinese 错误帧数\~english Number of error frames - unsigned int nReserved[2]; ///< \~chinese 保留\~english Reserved -} MV_MATCH_INFO_USB_DETECT; - -typedef struct _MV_IMAGE_BASIC_INFO_ -{ - // width - unsigned short nWidthValue; - unsigned short nWidthMin; - unsigned int nWidthMax; - unsigned int nWidthInc; - - // height - unsigned int nHeightValue; - unsigned int nHeightMin; - unsigned int nHeightMax; - unsigned int nHeightInc; - - // framerate - float fFrameRateValue; - float fFrameRateMin; - float fFrameRateMax; - - /// \~chinese 像素格式\~english pixel format - unsigned int enPixelType; ///< \~chinese 当前的像素格式\~english Current pixel format - unsigned int nSupportedPixelFmtNum; ///< \~chinese 支持的像素格式种类\~english Support pixel format - unsigned int enPixelList[MV_MAX_XML_SYMBOLIC_NUM]; - unsigned int nReserved[8]; - -} MV_IMAGE_BASIC_INFO; - -/// \~chinese 异常消息类型\~english Exception message type -#define MV_EXCEPTION_DEV_DISCONNECT 0x00008001 ///< \~chinese 设备断开连接\~english The device is disconnected -#define MV_EXCEPTION_VERSION_CHECK \ - 0x00008002 ///< \~chinese SDK与驱动版本不匹配\~english SDK does not match the driver version -/// \~chinese 设备的访问模式\~english Device Access Mode -/// \~chinese 独占权限,其他APP只允许读CCP寄存器\~english Exclusive authority, other APP is only allowed to read the CCP -/// register -#define MV_ACCESS_Exclusive 1 -/// \~chinese 可以从5模式下抢占权限,然后以独占权限打开\~english You can seize the authority from the 5 mode, and then -/// open with exclusive authority -#define MV_ACCESS_ExclusiveWithSwitch 2 -/// \~chinese 控制权限,其他APP允许读所有寄存器\~english Control authority, allows other APP reading all registers -#define MV_ACCESS_Control 3 -/// \~chinese 可以从5的模式下抢占权限,然后以控制权限打开\~english You can seize the authority from the 5 mode, and then -/// open with control authority -#define MV_ACCESS_ControlWithSwitch 4 -/// \~chinese 以可被抢占的控制权限打开\~english Open with seized control authority -#define MV_ACCESS_ControlSwitchEnable 5 -/// \~chinese 可以从5的模式下抢占权限,然后以可被抢占的控制权限打开\~english You can seize the authority from the 5 -/// mode, and then open with seized control authority -#define MV_ACCESS_ControlSwitchEnableWithKey 6 -/// \~chinese 读模式打开设备,适用于控制权限下\~english Open with read mode and is available under control authority -#define MV_ACCESS_Monitor 7 - -/************************************************************************/ -/* 封装了GenICam的C接口相关参数定义 */ -/* Package of GenICam C interface-related parameters definition */ -/************************************************************************/ - -/// \~chinese 每个节点对应的接口类型\~english Interface type corresponds to each node -enum MV_XML_InterfaceType + MV_EXPOSURE_MODE_TIMED = 0, ///< \~chinese ʱ \~english Timed + MV_EXPOSURE_MODE_TRIGGER_WIDTH = 1, ///< \~chinese \~english TriggerWidth +}MV_CAM_EXPOSURE_MODE; + +/// \~chinese Զعģʽ \~english Auto Exposure Mode +typedef enum _MV_CAM_EXPOSURE_AUTO_MODE_ { - IFT_IValue, //!> IValue interface - IFT_IBase, //!> IBase interface - IFT_IInteger, //!> IInteger interface - IFT_IBoolean, //!> IBoolean interface - IFT_ICommand, //!> ICommand interface - IFT_IFloat, //!> IFloat interface - IFT_IString, //!> IString interface - IFT_IRegister, //!> IRegister interface - IFT_ICategory, //!> ICategory interface - IFT_IEnumeration, //!> IEnumeration interface - IFT_IEnumEntry, //!> IEnumEntry interface - IFT_IPort, //!> IPort interface -}; + MV_EXPOSURE_AUTO_MODE_OFF = 0, ///< \~chinese ر \~english Off + MV_EXPOSURE_AUTO_MODE_ONCE = 1, ///< \~chinese һ \~english Once + MV_EXPOSURE_AUTO_MODE_CONTINUOUS = 2, ///< \~chinese \~english Continuous -/// \~chinese 节点的访问模式\~english Node Access Mode -enum MV_XML_AccessMode +}MV_CAM_EXPOSURE_AUTO_MODE; + +/// \~chinese ģʽ \~english Trigger Mode +typedef enum _MV_CAM_TRIGGER_MODE_ { - AM_NI, //!< Not implemented - AM_NA, //!< Not available - AM_WO, //!< Write Only - AM_RO, //!< Read Only - AM_RW, //!< Read and Write - AM_Undefined, //!< Object is not yet initialized - AM_CycleDetect, //!< used internally for AccessMode cycle detection -}; + MV_TRIGGER_MODE_OFF = 0, ///< \~chinese ر \~english Off + MV_TRIGGER_MODE_ON = 1, ///< \~chinese \~english ON -/// \~chinese 节点的可见性权限\~english Node Visible Permission -enum MV_XML_Visibility +}MV_CAM_TRIGGER_MODE; + +/// \~chinese Gammaѡ \~english Gamma Selector +typedef enum _MV_CAM_GAMMA_SELECTOR_ { - V_Beginner = 0, //!< Always visible - V_Expert = 1, //!< Visible for experts or Gurus - V_Guru = 2, //!< Visible for Gurus - V_Invisible = 3, //!< Not Visible - V_Undefined = 99 //!< Object is not yet initialized -}; + MV_GAMMA_SELECTOR_USER = 1, ///< \~chinese û \~english Gamma Selector User + MV_GAMMA_SELECTOR_SRGB = 2, ///< \~chinese sRGB \~english Gamma Selector sRGB -/// \~chinese Event事件回调信息\~english Event callback infomation -#define MAX_EVENT_NAME_SIZE 128 // 相机Event事件名称最大长度\~english Max length of event name +}MV_CAM_GAMMA_SELECTOR; +/// \~chinese ƽ \~english White Balance +typedef enum _MV_CAM_BALANCEWHITE_AUTO_ +{ + MV_BALANCEWHITE_AUTO_OFF = 0, ///< \~chinese ر \~english Off + MV_BALANCEWHITE_AUTO_ONCE = 2, ///< \~chinese һ \~english Once + MV_BALANCEWHITE_AUTO_CONTINUOUS = 1, ///< \~chinese \~english Continuous + +}MV_CAM_BALANCEWHITE_AUTO; + +/// \~chinese Դ \~english Trigger Source +typedef enum _MV_CAM_TRIGGER_SOURCE_ +{ + MV_TRIGGER_SOURCE_LINE0 = 0, ///< \~chinese Line0 \~english Line0 + MV_TRIGGER_SOURCE_LINE1 = 1, ///< \~chinese Line1 \~english Line1 + MV_TRIGGER_SOURCE_LINE2 = 2, ///< \~chinese Line2 \~english Line2 + MV_TRIGGER_SOURCE_LINE3 = 3, ///< \~chinese Line3 \~english Line3 + MV_TRIGGER_SOURCE_COUNTER0 = 4, ///< \~chinese Conuter0 \~english Conuter0 + + MV_TRIGGER_SOURCE_SOFTWARE = 7, ///< \~chinese \~english Software + MV_TRIGGER_SOURCE_FrequencyConverter= 8, ///< \~chinese Ƶ \~english Frequency Converter + +}MV_CAM_TRIGGER_SOURCE; + +/// \~chinese GigEVision IP \~english GigEVision IP Configuration +#define MV_IP_CFG_STATIC 0x05000000 ///< \~chinese ̬ \~english Static +#define MV_IP_CFG_DHCP 0x06000000 ///< \~chinese DHCP \~english DHCP +#define MV_IP_CFG_LLA 0x04000000 ///< \~chinese LLA \~english LLA + +/// \~chinese GigEVision紫ģʽ \~english GigEVision Net Transfer Mode +#define MV_NET_TRANS_DRIVER 0x00000001 ///< \~chinese \~english Driver +#define MV_NET_TRANS_SOCKET 0x00000002 ///< \~chinese Socket \~english Socket + +/// \~chinese CameraLink \~english CameraLink Baud Rates (CLUINT32) +#define MV_CAML_BAUDRATE_9600 0x00000001 ///< \~chinese 9600 \~english 9600 +#define MV_CAML_BAUDRATE_19200 0x00000002 ///< \~chinese 19200 \~english 19200 +#define MV_CAML_BAUDRATE_38400 0x00000004 ///< \~chinese 38400 \~english 38400 +#define MV_CAML_BAUDRATE_57600 0x00000008 ///< \~chinese 57600 \~english 57600 +#define MV_CAML_BAUDRATE_115200 0x00000010 ///< \~chinese 115200 \~english 115200 +#define MV_CAML_BAUDRATE_230400 0x00000020 ///< \~chinese 230400 \~english 230400 +#define MV_CAML_BAUDRATE_460800 0x00000040 ///< \~chinese 460800 \~english 460800 +#define MV_CAML_BAUDRATE_921600 0x00000080 ///< \~chinese 921600 \~english 921600 +#define MV_CAML_BAUDRATE_AUTOMAX 0x40000000 ///< \~chinese ֵ \~english Auto Max + +/// \~chinese 쳣Ϣ \~english Exception message type +#define MV_EXCEPTION_DEV_DISCONNECT 0x00008001 ///< \~chinese 豸Ͽ \~english The device is disconnected +#define MV_EXCEPTION_VERSION_CHECK 0x00008002 ///< \~chinese SDK汾ƥ \~english SDK does not match the driver version + +/// \~chinese U3V쳣 +typedef enum _MV_CC_STREAM_EXCEPTION_TYPE_ +{ + MV_CC_STREAM_EXCEPTION_ABNORMAL_IMAGE = 0x4001, ///< \~chinese 쳣ͼ񣬸֡ + MV_CC_STREAM_EXCEPTION_LIST_OVERFLOW = 0x4002, ///< \~chinese бɵһ֡ + MV_CC_STREAM_EXCEPTION_LIST_EMPTY = 0x4003, ///< \~chinese бΪգ֡ + MV_CC_STREAM_EXCEPTION_RECONNECTION = 0x4004, ///< \~chinese ָ + MV_CC_STREAM_EXCEPTION_DISCONNECTED = 0x4005, ///< \~chinese ,ָʧ,ȡֹ + MV_CC_STREAM_EXCEPTION_DEVICE = 0x4006, ///< \~chinese 豸쳣,ȡֹ + +}MV_CC_STREAM_EXCEPTION_TYPE; + +///< \~chinese 豸Event¼󳤶 \~english Max length of event name +#define MAX_EVENT_NAME_SIZE 128 + +/// \~chinese Event¼صϢ\ \~english Event callback infomation typedef struct _MV_EVENT_OUT_INFO_ { - char EventName[MAX_EVENT_NAME_SIZE]; ///< \~chinese Event名称\~english Event name + char EventName[MAX_EVENT_NAME_SIZE]; ///< [OUT] \~chinese Event \~english Event name + + unsigned short nEventID; ///< [OUT] \~chinese Event \~english Event ID + unsigned short nStreamChannel; ///< [OUT] \~chinese ͨ \~english Circulation number - unsigned short nEventID; ///< \~chinese Event号\~english Event ID - unsigned short nStreamChannel; ///< \~chinese 流通道序号\~english Circulation number + unsigned int nBlockIdHigh; ///< [OUT] \~chinese ֡Ÿλ \~english BlockId high + unsigned int nBlockIdLow; ///< [OUT] \~chinese ֡ŵλ \~english BlockId low - unsigned int nBlockIdHigh; ///< \~chinese 帧号高位\~english BlockId high - unsigned int nBlockIdLow; ///< \~chinese 帧号低位\~english BlockId low + unsigned int nTimestampHigh; ///< [OUT] \~chinese ʱλ \~english Timestramp high + unsigned int nTimestampLow; ///< [OUT] \~chinese ʱλ \~english Timestramp low - unsigned int nTimestampHigh; ///< \~chinese 时间戳高位\~english Timestramp high - unsigned int nTimestampLow; ///< \~chinese 时间戳低位\~english Timestramp low + void* pEventData; ///< [OUT] \~chinese Event \~english Event data + unsigned int nEventDataSize; ///< [OUT] \~chinese Eventݳ \~english Event data len - void *pEventData; ///< \~chinese Event数据\~english Event data - unsigned int nEventDataSize; ///< \~chinese Event数据长度\~english Event data len + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[16]; ///< \~chinese 预留\~english Reserved -} MV_EVENT_OUT_INFO; +}MV_EVENT_OUT_INFO; -/// \~chinese 文件存取\~english File Access +/// \~chinese ļȡ \~english File Access typedef struct _MV_CC_FILE_ACCESS_T { - const char *pUserFileName; ///< \~chinese 用户文件名\~english User file name - const char *pDevFileName; ///< \~chinese 设备文件名\~english Device file name + const char* pUserFileName; ///< [IN] \~chinese ûļ \~english User file name + const char* pDevFileName; ///< [IN] \~chinese 豸ļ \~english Device file name + + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_FILE_ACCESS; + +/// \~chinese ļȡ \~english File Access +typedef struct _MV_CC_FILE_ACCESS_E +{ + char* pUserFileBuf; ///< [IN] \~chinese ûݻ \~english User data Buffer + unsigned int pFileBufSize; ///< [IN] \~chinese ûݻС \~english data buffer size + unsigned int pFileBufLen; ///< [OUT][IN] \~chinese ļݻܳ(ȡʱļܳ,дʱļܳ) \~english data buffer len + const char* pDevFileName; ///< [IN] \~chinese 豸ļ \~english Device file name - unsigned int nReserved[32]; ///< \~chinese 预留\~english Reserved -} MV_CC_FILE_ACCESS; + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FILE_ACCESS_EX; -/// \~chinese 文件存取进度\~english File Access Progress +/// \~chinese ļȡ \~english File Access Progress typedef struct _MV_CC_FILE_ACCESS_PROGRESS_T { - int64_t nCompleted; ///< \~chinese 已完成的长度\~english Completed Length - int64_t nTotal; ///< \~chinese 总长度\~english Total Length + int64_t nCompleted; ///< [OUT] \~chinese ɵij \~english Completed Length + int64_t nTotal; ///< [OUT] \~chinese ܳ \~english Total Length - unsigned int nReserved[8]; ///< \~chinese 预留\~english Reserved -} MV_CC_FILE_ACCESS_PROGRESS; + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese 传输模式,可以为单播模式、组播模式等\~english Transmission type +}MV_CC_FILE_ACCESS_PROGRESS; + +/// \~chinese GigeĴ \~english The transmission type of Gige +typedef enum _MV_GIGE_TRANSMISSION_TYPE_ +{ + MV_GIGE_TRANSTYPE_UNICAST = 0x0, ///< \~chinese ʾ(Ĭ) \~english Unicast mode + MV_GIGE_TRANSTYPE_MULTICAST = 0x1, ///< \~chinese ʾ鲥(鲥IPΧ[224.*.*.*-239.*.*.*]) \~english Multicast mode + MV_GIGE_TRANSTYPE_LIMITEDBROADCAST = 0x2, ///< \~chinese ʾڹ㲥ݲ֧ \~english Limited broadcast mode,not support + MV_GIGE_TRANSTYPE_SUBNETBROADCAST = 0x3, ///< \~chinese ʾڹ㲥ݲ֧ \~english Subnet broadcast mode,not support + MV_GIGE_TRANSTYPE_CAMERADEFINED = 0x4, ///< \~chinese ʾ豸ȡݲ֧ \~english Transtype from camera,not support + MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT = 0x5, ///< \~chinese ʾûԶӦö˽ͼPort \~english User Defined Receive Data Port + MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV = 0x00010000, ///< \~chinese ʾ˵ʵͼ \~english Unicast without receive data + MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV= 0x00010001, ///< \~chinese ʾ鲥ģʽʵͼ \~english Multicast without receive data + +}MV_GIGE_TRANSMISSION_TYPE; + +/// \~chinese 紫ģʽ \~english Transmission type typedef struct _MV_TRANSMISSION_TYPE_T { - MV_GIGE_TRANSMISSION_TYPE enTransmissionType; ///< \~chinese 传输模式\~english Transmission type - unsigned int nDestIp; ///< \~chinese 目标IP,组播模式下有意义\~english Destination IP - unsigned short nDestPort; ///< \~chinese 目标Port,组播模式下有意义\~english Destination port + MV_GIGE_TRANSMISSION_TYPE enTransmissionType; ///< [IN] \~chinese ģʽ \~english Transmission type + unsigned int nDestIp; ///< [IN] \~chinese ĿIP鲥ģʽ \~english Destination IP + unsigned short nDestPort; ///< [IN] \~chinese ĿPort鲥ģʽ \~english Destination port - unsigned int nReserved[32]; ///< \~chinese 预留\~english Reserved -} MV_TRANSMISSION_TYPE; + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved -/// \~chinese 动作命令信息\~english Action Command +}MV_TRANSMISSION_TYPE; + +/// \~chinese Ϣ \~english Action Command typedef struct _MV_ACTION_CMD_INFO_T { - unsigned int nDeviceKey; ///< \~chinese 设备密钥 - unsigned int nGroupKey; ///< \~chinese 组键 - unsigned int nGroupMask; ///< \~chinese 组掩码 + unsigned int nDeviceKey; ///< [IN] \~chinese 豸Կ \~english Device Key; + unsigned int nGroupKey; ///< [IN] \~chinese \~english Group Key + unsigned int nGroupMask; ///< [IN] \~chinese \~english Group Mask + + unsigned int bActionTimeEnable; ///< [IN] \~chinese ֻó1ʱAction TimeЧ1ʱЧ \~english Action Time Enable + int64_t nActionTime; ///< [IN] \~chinese Ԥʱ䣬Ƶй \~english Action Time - unsigned int bActionTimeEnable; ///< \~chinese 只有设置成1时Action Time才有效,非1时无效 - int64_t nActionTime; ///< \~chinese 预定的时间,和主频有关 + const char* pBroadcastAddress; ///< [IN] \~chinese 㲥ַ \~english Broadcast Address + unsigned int nTimeOut; ///< [IN] \~chinese ȴACKijʱʱ䣬Ϊ0ʾҪACK \~english TimeOut - const char *pBroadcastAddress; ///< \~chinese 广播包地址 - unsigned int nTimeOut; ///< \~chinese 等待ACK的超时时间,如果为0表示不需要ACK + unsigned int bSpecialNetEnable; ///< [IN] \~chinese ֻó1ʱָIPЧ1ʱЧ \~english Special IP Enable + unsigned int nSpecialNetIP; ///< [IN] \~chinese ָIP \~english Special Net IP address - unsigned int nReserved[16]; ///< \~chinese 预留\~english Reserved + unsigned int nReserved[14]; ///< \~chinese Ԥ \~english Reserved -} MV_ACTION_CMD_INFO; +}MV_ACTION_CMD_INFO; -/// \~chinese 动作命令返回信息\~english Action Command Result +/// \~chinese Ϣ \~english Action Command Result typedef struct _MV_ACTION_CMD_RESULT_T { - unsigned char strDeviceAddress[12 + 3 + 1]; ///< IP address of the device + unsigned char strDeviceAddress[12 + 3 + 1]; ///< [OUT] \~chinese 豸IP \~english IP address of the device - // status code returned by the device - int nStatus; // 1.0x0000:success. - // 2.0x8001:Command is not supported by the device. - // 3.0x8013:The device is not synchronized to a master clock to be used as time reference. - // 4.0x8015:A device queue or packet data has overflowed. - // 5.0x8016:The requested scheduled action command was requested at a time that is already past. + int nStatus; ///< [OUT] \~chinese ״̬ \~english status code returned by the device + //1.0x0000:success. + //2.0x8001:Command is not supported by the device. + //3.0x8013:The device is not synchronized to a master clock to be used as time reference. + //4.0x8015:A device queue or packet data has overflowed. + //5.0x8016:The requested scheduled action command was requested at a time that is already past. - unsigned int nReserved[4]; ///< \~chinese 预留\~english Reserved + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved -} MV_ACTION_CMD_RESULT; +}MV_ACTION_CMD_RESULT; -/// \~chinese 动作命令返回信息列表\~english Action Command Result List +/// \~chinese Ϣб \~english Action Command Result List typedef struct _MV_ACTION_CMD_RESULT_LIST_T { - unsigned int nNumResults; ///< \~chinese 返回值个数 - MV_ACTION_CMD_RESULT *pResults; + unsigned int nNumResults; ///< [OUT] \~chinese ֵ \~english Number of returned values + MV_ACTION_CMD_RESULT* pResults; ///< [OUT] \~chinese \~english Reslut of action command -} MV_ACTION_CMD_RESULT_LIST; +}MV_ACTION_CMD_RESULT_LIST; -// ch:单个节点基本属性 | en:Single Node Basic Attributes -typedef struct _MV_XML_NODE_FEATURE_ +/// \~chinese ÿڵӦĽӿ \~english Interface type corresponds to each node +enum MV_XML_InterfaceType { - enum MV_XML_InterfaceType enType; ///< \~chinese 节点类型\~english Node Type - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Is visibility - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述,目前暂不支持\~english Node Description, NOT - ///< SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - - unsigned int nReserved[4]; -} MV_XML_NODE_FEATURE; + IFT_IValue, ///< \~chinese Value \~english IValue interface + IFT_IBase, ///< \~chinese Base \~english IBase interface + IFT_IInteger, ///< \~chinese Integer \~english IInteger interface + IFT_IBoolean, ///< \~chinese Boolean \~english IBoolean interface + IFT_ICommand, ///< \~chinese Command \~english ICommand interface + IFT_IFloat, ///< \~chinese Float \~english IFloat interface + IFT_IString, ///< \~chinese String \~english IString interface + IFT_IRegister, ///< \~chinese Register \~english IRegister interface + IFT_ICategory, ///< \~chinese Category \~english ICategory interface + IFT_IEnumeration, ///< \~chinese Enumeration \~english IEnumeration interface + IFT_IEnumEntry, ///< \~chinese EnumEntry \~english IEnumEntry interface + IFT_IPort, ///< \~chinese Port \~english IPort interface +}; -/// \~chinese 节点列表\~english Node List -typedef struct _MV_XML_NODES_LIST_ +/// \~chinese ڵķģʽ \~english Node Access Mode +enum MV_XML_AccessMode { - unsigned int nNodeNum; ///< \~chinese 节点个数\~english Node Number - MV_XML_NODE_FEATURE stNodes[MV_MAX_XML_NODE_NUM_C]; -} MV_XML_NODES_LIST; + AM_NI, ///< \~chinese ʵ \~english Not implemented + AM_NA, ///< \~chinese \~english Not available + AM_WO, ///< \~chinese ֻд \~english Write Only + AM_RO, ///< \~chinese ֻ \~english Read Only + AM_RW, ///< \~chinese д \~english Read and Write + AM_Undefined, ///< \~chinese δ \~english Object is not yet initialized + AM_CycleDetect, ///< \~chinese ڲAccessModeѭ \~english used internally for AccessMode cycle detection +}; -typedef struct _MV_XML_FEATURE_Value_ +/// \~chinese XML \~english Max XML Symbolic Number +#define MV_MAX_XML_SYMBOLIC_NUM 64 +/// \~chinese öֵ \~english Enumeration Value +typedef struct _MVCC_ENUMVALUE_T { - enum MV_XML_InterfaceType enType; ///< \~chinese节点类型\~english Node Type - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese节点描述 目前暂不支持\~english Node Description, - ///< NOT SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - unsigned int nReserved[4]; -} MV_XML_FEATURE_Value; + unsigned int nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + unsigned int nSupportedNum; ///< [OUT] \~chinese ݵЧݸ \~english Number of valid data + unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; ///< [OUT] \~chinese ֵ֧öֵ \~english Support Value -typedef struct _MV_XML_FEATURE_Base_ -{ - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode -} MV_XML_FEATURE_Base; + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved -typedef struct _MV_XML_FEATURE_Integer_ -{ - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; +}MVCC_ENUMVALUE; - enum MV_XML_Visibility enVisivility; ///< \~chinese是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int64_t nValue; ///< \~chinese 当前值\~english Current Value - int64_t nMinValue; ///< \~chinese 最小值\~english Min Value - int64_t nMaxValue; ///< \~chinese 最大值\~english Max Value - int64_t nIncrement; ///< \~chinese 增量\~english Increment +/// \~chinese öĿӦķų \~english Max Enum Entry Symbolic Number +#define MV_MAX_SYMBOLIC_LEN 64 +/// \~chinese öĿ \~english Enumeration Entry +typedef struct _MVCC_ENUMENTRY_T +{ + unsigned int nValue; ///< [IN] \~chinese ֵָ \~english Value + char chSymbolic[MV_MAX_SYMBOLIC_LEN]; ///< [OUT] \~chinese ֵָӦķ \~english Symbolic - unsigned int nReserved[4]; + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved -} MV_XML_FEATURE_Integer; +}MVCC_ENUMENTRY; -typedef struct _MV_XML_FEATURE_Boolean_ +/// \~chinese Intֵ \~english Int Value +typedef struct _MVCC_INTVALUE_T { - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + unsigned int nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + unsigned int nMax; ///< [OUT] \~chinese ֵ \~english Max + unsigned int nMin; ///< [OUT] \~chinese Сֵ \~english Min + unsigned int nInc; ///< [OUT] \~chinese \~english Inc - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - bool bValue; ///< \~chinese 当前值\~english Current Value + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[4]; -} MV_XML_FEATURE_Boolean; +}MVCC_INTVALUE; -typedef struct _MV_XML_FEATURE_Command_ +/// \~chinese IntֵEx \~english Int Value Ex +typedef struct _MVCC_INTVALUE_EX_T { - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + int64_t nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + int64_t nMax; ///< [OUT] \~chinese ֵ \~english Max + int64_t nMin; ///< [OUT] \~chinese Сֵ \~english Min + int64_t nInc; ///< [OUT] \~chinese Inc \~english Inc - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[4]; -} MV_XML_FEATURE_Command; +}MVCC_INTVALUE_EX; -typedef struct _MV_XML_FEATURE_Float_ +/// \~chinese Floatֵ \~english Float Value +typedef struct _MVCC_FLOATVALUE_T { - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + float fCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + float fMax; ///< [OUT] \~chinese ֵ \~english Max + float fMin; ///< [OUT] \~chinese Сֵ \~english Min - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - double dfValue; ///< \~chinese 当前值\~english Current Value - double dfMinValue; ///< \~chinese 最小值\~english Min Value - double dfMaxValue; ///< \~chinese 最大值\~english Max Value - double dfIncrement; ///< \~chinese 增量\~english Increment + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[4]; -} MV_XML_FEATURE_Float; +}MVCC_FLOATVALUE; -typedef struct _MV_XML_FEATURE_String_ +/// \~chinese Stringֵ \~english String Value +typedef struct _MVCC_STRINGVALUE_T { - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + char chCurValue[256]; ///< [OUT] \~chinese ǰֵ \~english Current Value - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - char strValue[MV_MAX_XML_STRVALUE_STRLEN_C]; ///< \~chinese 当前值\~english Current Value + int64_t nMaxLength; ///< [OUT] \~chinese 󳤶 \~english MaxLength + unsigned int nReserved[2]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[4]; -} MV_XML_FEATURE_String; +}MVCC_STRINGVALUE; -typedef struct _MV_XML_FEATURE_Register_ +/// \~chinese ɫ \~english Color of Auxiliary Line +typedef struct _MVCC_COLORF { - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + float fR; ///< [IN] \~chinese ɫɫȣΧΪ[0.0 , 1.0][0, 255]ɫ \~english RedRange[0.0, 1.0] + float fG; ///< [IN] \~chinese ɫɫȣΧΪ[0.0 , 1.0][0, 255]ɫ \~english GreenRange[0.0, 1.0] + float fB; ///< [IN] \~chinese ɫɫȣΧΪ[0.0 , 1.0][0, 255]ɫ \~english BlueRange[0.0, 1.0] + float fAlpha; ///< [IN] \~chinese ͸ȣɫ͸ȣΧΪ[0.0 , 1.0] (˲ݲ֧) \~english AlphaRange[0.0, 1.0](Not Support) + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int64_t nAddrValue; ///< \~chinese 当前值\~english Current Value +}MVCC_COLORF; - unsigned int nReserved[4]; -} MV_XML_FEATURE_Register; - -typedef struct _MV_XML_FEATURE_Category_ +/// \~chinese Զ \~english Point defined +typedef struct _MVCC_POINTF { - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述 目前暂不支持\~english Node Description, NOT - ///< SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice - - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible + float fX; ///< [IN] \~chinese õͼԵ룬ͼλãΧΪ[0.0 , 1.0] \~english Distance From LeftRange[0.0, 1.0] + float fY; ///< [IN] \~chinese õͼϱԵ룬ͼλãΧΪ[0.0 , 1.0] \~english Distance From TopRange[0.0, 1.0] + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[4]; -} MV_XML_FEATURE_Category; +}MVCC_POINTF; -typedef struct _MV_XML_FEATURE_EnumEntry_ +/// \~chinese οϢ \~english Rect Area Info +typedef struct _MVCC_RECT_INFO { - char strName[MV_MAX_XML_NODE_STRLEN_C]; - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 目前暂不支持\~english NOT SUPPORT NOW - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; - int bIsImplemented; - int nParentsNum; - MV_XML_NODE_FEATURE stParentsList[MV_MAX_XML_PARENTS_NUM]; + float fTop; ///< [IN] \~chinese ϱԵͼϱԵľ룬ͼλãΧΪ[0.0 , 1.0] \~english Distance From TopRange[0, 1.0] + float fBottom; ///< [IN] \~chinese ±ԵͼϱԵľ룬ͼλãΧΪ[0.0 , 1.0] \~english Distance From TopRange[0, 1.0] + float fLeft; ///< [IN] \~chinese ԵͼԵľ룬ͼλãΧΪ[0.0 , 1.0] \~english Distance From LeftRange[0, 1.0] + float fRight; ///< [IN] \~chinese ұԵͼԵľ룬ͼλãΧΪ[0.0 , 1.0] \~english Distance From LeftRange[0, 1.0] - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - int64_t nValue; ///< \~chinese 当前值\~english Current Value - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int nReserved[8]; + MVCC_COLORF stColor; ///< [IN] \~chinese ɫ \~english Color of Auxiliary Line + unsigned int nLineWidth; ///< [IN] \~chinese ߿ȣֻ12 \~english Width of Auxiliary Line, width is 1 or 2 + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved -} MV_XML_FEATURE_EnumEntry; +}MVCC_RECT_INFO; -typedef struct _MV_XML_FEATURE_Enumeration_ +/// \~chinese ԲοϢ \~english Circle Area Info +typedef struct _MVCC_CIRCLE_INFO { - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述 目前暂不支持\~english Node Description, NOT - ///< SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice + MVCC_POINTF stCenterPoint; ///< [IN] \~chinese ԲϢ \~english Circle Point Info + + float fR1; ///< [IN] \~chinese 뾶ͼλ[0, 1.0]뾶Բĵλйأ豣֤ԲʾΧ֮ڣ򱨴 \~english Windth Radius, Range[0, 1.0] + float fR2; ///< [IN] \~chinese 뾶ͼλ[0, 1.0]뾶Բĵλйأ豣֤ԲʾΧ֮ڣ򱨴 \~english Height Radius, Range[0, 1.0] - int nSymbolicNum; ///< \~chinese Symbolic数\~english Symbolic Number - char strCurrentSymbolic[MV_MAX_XML_SYMBOLIC_STRLEN_C]; ///< \~chinese 当前Symbolic索引\~english Current Symbolic - ///< Index - char strSymbolic[MV_MAX_XML_SYMBOLIC_NUM][MV_MAX_XML_SYMBOLIC_STRLEN_C]; - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW - int64_t nValue; ///< \~chinese 当前值\~english Current Value + MVCC_COLORF stColor; ///< [IN] \~chinese ɫϢ \~english Color of Auxiliary Line + unsigned int nLineWidth; ///< [IN] \~chinese ߿ȣֻ12 \~english Width of Auxiliary Line, width is 1 or 2 + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved - unsigned int nReserved[4]; -} MV_XML_FEATURE_Enumeration; +}MVCC_CIRCLE_INFO; -typedef struct _MV_XML_FEATURE_Port_ +/// \~chinese Ϣ \~english Linear Auxiliary Line Info +typedef struct _MVCC_LINES_INFO { - enum MV_XML_Visibility enVisivility; ///< \~chinese 是否可见\~english Visible - char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 节点描述 目前暂不支持\~english Node Description, NOT - ///< SUPPORT NOW - char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 显示名称\~english Display Name - char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese 节点名\~english Node Name - char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese 提示\~english Notice + MVCC_POINTF stStartPoint; ///< [IN] \~chinese ߵʼ \~english The Start Point of Auxiliary Line + MVCC_POINTF stEndPoint; ///< [IN] \~chinese ߵյ \~english The End Point of Auxiliary Line + MVCC_COLORF stColor; ///< [IN] \~chinese ɫϢ \~english Color of Auxiliary Line + unsigned int nLineWidth; ///< [IN] \~chinese ߿ȣֻ12 \~english Width of Auxiliary Line, width is 1 or 2 + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved - enum MV_XML_AccessMode enAccessMode; ///< \~chinese 访问模式\~english Access Mode - int bIsLocked; ///< \~chinese 是否锁定。0-否;1-是 目前暂不支持\~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW +}MVCC_LINES_INFO; - unsigned int nReserved[4]; -} MV_XML_FEATURE_Port; +///< \~chinese ʱعʱཫԴͼֵĸ \~english The maximum number of source image to be split in time-division exposure +#define MV_MAX_SPLIT_NUM 8 -typedef struct _MV_XML_CAMERA_FEATURE_ +/// \~chinese ͼعķʽ \~english Image reconstruction method +typedef enum _MV_IMAGE_RECONSTRUCTION_METHOD_ { - enum MV_XML_InterfaceType enType; + MV_SPLIT_BY_LINE = 1, ///< \~chinese Դͼвֳɶͼ \~english Source image split into multiple images by line - union - { - MV_XML_FEATURE_Integer stIntegerFeature; - MV_XML_FEATURE_Float stFloatFeature; - MV_XML_FEATURE_Enumeration stEnumerationFeature; - MV_XML_FEATURE_String stStringFeature; - } SpecialFeature; - -} MV_XML_CAMERA_FEATURE; +}MV_IMAGE_RECONSTRUCTION_METHOD; -typedef struct _MVCC_ENUMVALUE_T +/// \~chinese ͼعͼб \~english List of images after image reconstruction +typedef struct _MV_OUTPUT_IMAGE_INFO_ { - unsigned int nCurValue; ///< \~chinese 当前值\~english Current Value - unsigned int nSupportedNum; ///< \~chinese 数据的有效数据个数\~english Number of valid data - unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; + unsigned int nWidth; ///< [OUT] \~chinese Դͼ \~english Source Image Width + unsigned int nHeight; ///< [OUT] \~chinese Դͼ \~english Source Image Height + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel format - unsigned int nReserved[4]; -} MVCC_ENUMVALUE; + unsigned char* pBuf; ///< [IN][OUT] \~chinese ݻ \~english Output data buffer + unsigned int nBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + unsigned int nBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size -typedef struct _MVCC_INTVALUE_T + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_OUTPUT_IMAGE_INFO; + +/// \~chinese عͼϢ \~english Restructure image parameters +typedef struct _MV_RECONSTRUCT_IMAGE_PARAM_ { - unsigned int nCurValue; ///< \~chinese 当前值\~english Current Value - unsigned int nMax; - unsigned int nMin; - unsigned int nInc; + unsigned int nWidth; ///< [IN] \~chinese Դͼ \~english Source Image Width + unsigned int nHeight; ///< [IN] \~chinese Դͼ \~english Source Image Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format - unsigned int nReserved[4]; -} MVCC_INTVALUE; + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݳ \~english Input data length -typedef struct _MVCC_INTVALUE_EX_T -{ - int64_t nCurValue; ///< \~chinese 当前值\~english Current Value - int64_t nMax; - int64_t nMin; - int64_t nInc; + unsigned int nExposureNum; ///< [IN] \~chinese ع(1-8] \~english Exposure number + MV_IMAGE_RECONSTRUCTION_METHOD enReconstructMethod; ///< [IN] \~chinese ͼعʽ \~english Image restructuring method - unsigned int nReserved[16]; -} MVCC_INTVALUE_EX; + MV_OUTPUT_IMAGE_INFO stDstBufList[MV_MAX_SPLIT_NUM]; ///< [OUT] \~chinese ݻϢ \~english Output data info -typedef struct _MVCC_FLOATVALUE_T + unsigned int nRes[4]; +}MV_RECONSTRUCT_IMAGE_PARAM; + +/// \~chinese Ϣ \~english Serial Port Info +typedef struct _MV_CAML_SERIAL_PORT_ { - float fCurValue; ///< \~chinese 当前值\~english Current Value - float fMax; - float fMin; + unsigned char chSerialPort[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ں \~english Serial Port - unsigned int nReserved[4]; -} MVCC_FLOATVALUE; + unsigned int nRes[4]; ///<\~chinese Ԥ \~english Reserved +}MV_CAML_SERIAL_PORT; -typedef struct _MVCC_STRINGVALUE_T +///< \~chinese ֵ֧Ĵ \~english The maximum number of serial port supported +#define MV_MAX_SERIAL_PORT_NUM 64 + +typedef struct _MV_CAML_SERIAL_PORT_LIST_ { - char chCurValue[256]; ///< \~chinese 当前值\~english Current Value + unsigned int nSerialPortNum; //< [OUT] \~chinese \~english Serial Port Num + MV_CAML_SERIAL_PORT stSerialPort[MV_MAX_SERIAL_PORT_NUM]; //< [IN][OUT] \~chinese Ϣ \~english Serial Port Information - int64_t nMaxLength; - unsigned int nReserved[2]; -} MVCC_STRINGVALUE; + unsigned int nRes[4]; ///<\~chinese Ԥ \~english Reserved +}MV_CAML_SERIAL_PORT_LIST; #endif /* _MV_CAMERA_PARAMS_H_ */ diff --git a/hnurm_camera/include/hnurm_camera/MvCameraControl.h b/hnurm_camera/include/hnurm_camera/MvCameraControl.h index 6874425b7d6180af46961775616b53b07153f654..3e5b2b75ce8d4bb549c2557dca3f8a049f38bbad 100755 --- a/hnurm_camera/include/hnurm_camera/MvCameraControl.h +++ b/hnurm_camera/include/hnurm_camera/MvCameraControl.h @@ -2,15 +2,15 @@ #ifndef _MV_CAMERA_CTRL_H_ #define _MV_CAMERA_CTRL_H_ -#include "hnurm_camera/CameraParams.h" +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "MvObsoleteInterfaces.h" + + -/** - * @brief 动态库导入导出定义 - * @brief Import and export definition of the dynamic library - */ #ifndef MV_CAMCTRL_API -#if(defined(_WIN32) || defined(WIN64)) +#if (defined (_WIN32) || defined(WIN64)) #if defined(MV_CAMCTRL_EXPORTS) #define MV_CAMCTRL_API __declspec(dllexport) #else @@ -21,3470 +21,2592 @@ #define __stdcall #endif -#if defined(MV_CAMCTRL_EXPORTS) -#define MV_CAMCTRL_API __attribute__((visibility("default"))) -#else -#define MV_CAMCTRL_API +#ifndef MV_CAMCTRL_API +#define MV_CAMCTRL_API #endif #endif #endif +#ifdef MV_CAMCTRL_API + +#if (defined (_WIN32) || defined(WIN64)) + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __declspec(dllexport) + #else + #define MV_CAMCTRL_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __attribute__((visibility("default"))) + #else + #define MV_CAMCTRL_API + #endif + #endif + +#endif + #ifndef IN -#define IN + #define IN #endif #ifndef OUT -#define OUT + #define OUT #endif #ifdef __cplusplus -extern "C" -{ -#endif - - /************************************************************************/ - /* 相机的基本指令和操作 */ - /* Camera basic instructions and operations */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 获取SDK版本号 - * @return 始终返回4字节版本号 - | 主 | 次 | 修正 | 测试 | - | :---: | :---: | :---: | :---: | - | 8bits | 8bits | 8bits | 8bits | - * @remarks 比如返回值为0x01000001,即SDK版本号为V1.0.0.1。 - - * @~english - * @brief Get SDK Version - * @return Always return 4 Bytes of version number - | Main | Sub | Rev | Test | - | :---: | :---: | :---: | :---: | - | 8bits | 8bits | 8bits | 8bits | - * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. - ************************************************************************/ - MV_CAMCTRL_API unsigned int __stdcall MV_CC_GetSDKVersion(); - - /********************************************************************/ /** - * @~chinese - * @brief 获取支持的传输层 - * @return 支持的传输层编号 - - * @~english - * @brief Get supported Transport Layer - * @return Supported Transport Layer number - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_EnumerateTls(); - - /********************************************************************/ /** - * @~chinese - * @brief 枚举设备 - * @param nTLayerType [IN] 枚举传输层 - * @param pstDevList [OUT] 设备列表 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 设备列表的内存是在SDK内部分配的,多线程调用该接口时会进行设备列表内存的释放和申请.\n - 建议尽量避免多线程枚举操作。 - - * @~english - * @brief Enumerate Device - * @param nTLayerType [IN] Enumerate TLs - * @param pstDevList [OUT] Device List - * @return Success, return #MV_OK. Failure, return error code - * @remarks @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by - multiple threads, the memory of the device list will be released and applied.\n It is recommended to avoid - multithreaded enumeration operations as much as possible. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_EnumDevices( - IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST *pstDevList - ); - - /********************************************************************/ /** - * @~chinese - * @brief 根据厂商名字枚举设备 - * @param nTLayerType [IN] 枚举传输层 - * @param pstDevList [OUT] 设备列表 - * @param pManufacturerName [IN] 厂商名字 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Enumerate device according to manufacture name - * @param nTLayerType [IN] Transmission layer of enumeration - * @param pstDevList [OUT] Device list - * @param pManufacturerName [IN] Manufacture Name - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesEx( - IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST *pstDevList, IN const char *pManufacturerName - ); - - /********************************************************************/ /** - * @~chinese - * @brief 设备是否可达 - * @param pstDevInfo [IN] 设备信息结构体 - * @param nAccessMode [IN] 访问权限 - * @return 可达,返回true;不可达,返回false - * @remarks 读取设备CCP寄存器的值,判断当前状态是否具有某种访问权限。 \n - 如果设备不支持 #MV_ACCESS_ExclusiveWithSwitch、 #MV_ACCESS_ControlWithSwitch、 - #MV_ACCESS_ControlSwitchEnableWithKey这三种模式,接口返回false。目前设备不支持这3种抢占模式,国际上主流的厂商的相机也都暂不支持这3种模式。 - \n 该接口不支持CameraLink设备。 - - * @~english - * @brief Is the device accessible - * @param pstDevInfo [IN] Device Information Structure - * @param nAccessMode [IN] Access Right - * @return Access, return true. Not access, return false - @remarks Read device CCP register value and determine current access permission.\n - Return false if the device does not support the modes #MV_ACCESS_ExclusiveWithSwitch, - #MV_ACCESS_ControlWithSwitch, #MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 - preemption modes, neither do the devices from other mainstream manufacturers. \n This API is not supported by - CameraLink device. - ************************************************************************/ - MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceAccessible( - IN MV_CC_DEVICE_INFO *pstDevInfo, IN unsigned int nAccessMode - ); - - /********************************************************************/ /** - * @~chinese - * @brief 设置SDK日志路径(如果日志服务MvLogServer已启用,则该接口无效,默认日志服务为开启状态) - * @param pSDKLogPath [IN] SDK日志路径 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 设置路径之后,可以指定路径存放日志。\n - v2.4.1版本新增日志服务,开启服务之后该接口无效。 - - * @~english - * @brief Set SDK log path - * @param pSDKLogPath [IN] SDK log path - * @return Access, return true. Not access, return false - * @remarks For version V2.4.1, added log service, this API is invalid when the service is enabled.And The logging - service is enabled by default\n This API is used to set the log file storing path. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetSDKLogPath(IN const char *pSDKLogPath); - - /********************************************************************/ /** - * @~chinese - * @brief 创建设备句柄 - * @param handle [OUT] 设备句柄 - * @param pstDevInfo [IN] 设备信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 根据输入的设备信息,创建库内部必须的资源和初始化内部模块。通过该接口创建句柄,调用SDK接口,会默认生成SDK日志文件,保存在当前可执行程序路径下的MvSdkLog文件夹,如果不需要生成日志文件,可以通过MV_CC_CreateHandleWithoutLog创建句柄。 - - * @~english - * @brief Create Device Handle - * @param handle [OUT] Device handle - * @param pstDevInfo [IN] Device Information Structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Create required resources within library and initialize internal module according to input device - information. Create handle and call SDK interface through this interface, and SDK log file will be created by - default. Creating handle through #MV_CC_CreateHandleWithoutLog will not generate log files. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_CreateHandle(OUT void **handle, IN const MV_CC_DEVICE_INFO *pstDevInfo); - - /********************************************************************/ /** - * @~chinese - * @brief 创建设备句柄,不生成日志 - * @param handle [OUT] 设备句柄 - * @param pstDevInfo [IN] 设备信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 根据输入的设备信息,创建库内部必须的资源和初始化内部模块。通过该接口创建句柄,调用SDK接口,不会默认生成SDK日志文件,如果需要生成日志文件可以通过MV_CC_CreateHandle创建句柄,日志文件自动生成,保存在当前可执行程序路径下的MvSdkLog文件夹。 - - * @~english - * @brief Create Device Handle without log - * @param handle [OUT] Device handle - * @param pstDevInfo [IN] Device Information Structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Create required resources within library and initialize internal module according to input device - information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To - create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleWithoutLog( - OUT void **handle, IN const MV_CC_DEVICE_INFO *pstDevInfo - ); - - /********************************************************************/ /** - * @~chinese - * @brief 销毁设备句柄 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Destroy Device Handle - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_DestroyHandle(IN void *handle); - -/********************************************************************/ /** - * @~chinese - * @brief 打开设备 - * @param handle [IN] 设备句柄 - * @param nAccessMode [IN] 访问权限 - * @param nSwitchoverKey [IN] 切换访问权限时的密钥 - * @return 成功,返回#MV_OK ;错误,返回错误码 - * @remarks 根据设置的设备参数,找到对应的设备,连接设备。\n - 调用接口时可不传入nAccessMode和nSwitchoverKey,此时默认设备访问模式为独占权限。目前设备暂不支持#MV_ACCESS_ExclusiveWithSwitch、 - #MV_ACCESS_ControlWithSwitch、MV_ACCESS_ControlSwitchEnable、MV_ACCESS_ControlSwitchEnableWithKey这四种抢占模式。\n - 对于U3V设备,nAccessMode、nSwitchoverKey这两个参数无效。 - - * @~english - * @brief Open Device - * @param handle [IN] Device handle - * @param nAccessMode [IN] Access Right - * @param nSwitchoverKey [IN] Switch key of access right - * @return Success, return #MV_OK. Failure, return error code - * @remarks Find specific device and connect according to set device parameters. \n - When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access - mode is exclusive. Currently the device does not support the following preemption modes: - MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.\n For USB3Vision - device, nAccessMode, nSwitchoverKey are invalid. - ************************************************************************/ +extern "C" { +#endif + + +/****************************** ch: ժҪ | en: Instructions**********************************************/ + +/** +* @~chinese +* ͷļҪ9֣ +* 1.Ŀƺȡӿ +* 2.ýӿ&дĴӿ +* 3. +* 4.ע쳣ص¼ӿ +* 5.GigE豸ֵ֧Ľӿ +* 6.CameraLink 豸ֵ֧Ľӿ +* 7.U3V豸ֵ֧Ľӿ +* 8.GenTLؽӿ +* 9.ͼ񱣴桢ʽתؽӿ + +* @~english +* The document mainly consists of nine parts: +* 1.Camera control and streaming +* 2.Camera attribute nodes set and obtained universal interface +* 3.Camera upgrade and read-write register memory interface +* 4.Enrol abnormal callbacks and event interface +* 5.Only support GigE device interface +* 6.Only support camlink device interface +* 7.Only support U3V device interface +* 8.Only support GenTL device interface +* 9.Related image save and format convert interface +**/ + + + +/**************************Part1 ch: Ŀƺȡӿ | en: Camera control and streaming******************************************/ + + +/********************************************************************//** + * @~chinese + * @brief ʼSDK + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Initialize SDK + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_Initialize(); + +/********************************************************************//** + * @~chinese + * @brief ʼSDKͷԴ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Terminate SDK + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_Finalize(); + +/* + * @~chinese + * @brief ȡSDK汾 + * @return 4ֽڰ汾 + | | | | | + 8bits 8bits 8bits 8bits + * @remarks 緵ֵΪ0x01000001SDK汾ΪV1.0.0.1 + + * @~english + * @brief Get SDK Version + * @return Always return 4 Bytes of version number + |Main |Sub |Rev | Test| + 8bits 8bits 8bits 8bits + * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. + ************************************************************************/ +MV_CAMCTRL_API unsigned int __stdcall MV_CC_GetSDKVersion(); + +/********************************************************************//** + * @~chinese + * @brief ȡֵ֧Ĵ + * @return ֵ֧Ĵ + + * @~english + * @brief Get supported Transport Layer + * @return Supported Transport Layer number + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumerateTls(); + +/********************************************************************//** + * @~chinese + * @brief ö豸 + * @param nTLayerType [IN] öٴ, μCameraParams.h, : #define MV_GIGE_DEVICE 0x00000001 GigE豸 + * @param pstDevList [IN][OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź,龡߳öٲ + * @remarks öٴ㣬䴫MV_GIGE_DEVICEMV_1394_DEVICEMV_USB_DEVICEMV_CAMERALINK_DEVICEMV_GIGE_DEVICEò + GiGEص豸ϢGiGEGenTLµGiGE豸MV_USB_DEVICEòUSB豸USB豸 + + * @~english + * @brief Enumerate Device + * @param nTLayerType [IN] Enumerate TLs, Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_GIGE_DEVICE 0x00000001 + * @param pstDevList [IN][OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied + It is recommended to avoid multithreaded enumeration operations as much as possible. + * @remarks Transmission layer of enumeration, param only include MV_GIGE_DEVICEMV_1394_DEVICEMV_USB_DEVICEMV_CAMERALINK_DEVICE; + MV_GIGE_DEVICE can output virtual and GenTL GiGE devices, MV_USB_DEVICE can output all USB devices, include virtual usb devices. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevices(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ݳö豸 + * @param nTLayerType [IN] öٴ, μCameraParams.h, : #define MV_GIGE_DEVICE 0x00000001 GigE豸 + * @param pstDevList [IN][OUT] 豸б + * @param strManufacturerName [IN] + * @return ɹMV_OK󣬷ش + * @remarks öٴ㣬䴫MV_GIGE_DEVICEMV_1394_DEVICEMV_USB_DEVICEMV_CAMERALINK_DEVICEMV_GIGE_DEVICEò + GiGEص豸ϢGiGEGenTLµGiGE豸MV_USB_DEVICEòUSB豸USB豸 + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź,龡߳öٲ + + * @~english + * @brief Enumerate device according to manufacture name + * @param nTLayerType [IN] Transmission layer of enumeration, , Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_GIGE_DEVICE 0x00000001 + * @param pstDevList [IN][OUT] Device list + * @param strManufacturerName [IN] Manufacture Name + * @return Success, return MV_OK. Failure, return error code + * @remarks Transmission layer of enumeration, param only include MV_GIGE_DEVICEMV_1394_DEVICEMV_USB_DEVICEMV_CAMERALINK_DEVICE; + MV_GIGE_DEVICE can output virtual and GenTL GiGE devices, MV_USB_DEVICE can output all USB devices, include virtual usb devices. + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied. + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName); + + +/********************************************************************//** + * @~chinese + * @brief ö豸չָʽö١ݳֹˣ + * @param nTLayerType [IN] öٴ㣨ÿһִͣϣ, μCameraParams.h, : #define MV_GIGE_DEVICE 0x00000001 GigE豸 + * @param pstDevList [IN][OUT] 豸б + * @param strManufacturerName [IN] ֣ɴNULLˣ + * @param enSortMethod [IN] ʽ + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź,龡߳öٲ + strManufacturerNameɴNULLNULL򷵻ź豸б,ΪNULLֻźָ豸б + + * @~english + * @brief Enumerate device according to the specified ordering + * @param nTLayerType [IN] Transmission layer of enumeration(All layer protocol type can input), Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_GIGE_DEVICE 0x00000001 + * @param pstDevList [IN][OUT] Device list + * @param strManufacturerName [IN] Manufacture Name + * @param enSortMethod [IN] Sorting Method + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied. + It is recommended to avoid multithreaded enumeration operations as much as possible. + strManufacturerName can be passed in NULL,if NULL is passed in, it will return the sorted list of all devices. + If it is not NULL,it will only return the sorted list of the specified manufacturer's devices. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesEx2(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName, IN MV_SORT_METHOD enSortMethod); + +/********************************************************************//** + * @~chinese + * @brief 豸Ƿɴ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param nAccessMode [IN] Ȩ,μCameraParams.h, :#define MV_ACCESS_Exclusive 1 + * @remarks ȡ豸CCPĴֵжϵǰ״̬ǷijַȨ + 豸֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableWithKeyģʽӿڷfalse + Ŀǰ豸֧3ռģʽij̵豸Ҳݲ֧3ģʽ + ýӿ֧ GIGEU3V豸 + ýӿڲ֧CameraLink豸,ֵ֧.ctiʽɼ豸 + + * @~english + * @brief Is the device accessible + * @param pstDevInfo [IN] Device Information Structure + * @param nAccessMode [IN] Access Right, Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_ACCESS_Exclusive 1 + * @return Access, return true. Not access, return false + * @remarks Read device CCP register value and determine current access permission. + Return false if the device does not support the modes MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey. + Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers. + This API is not supported by CameraLink device. + **************************************************************************/ +MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode); + +/********************************************************************//** + * @~chinese + * @brief öٲɼ + * @param nTLayerType [IN] ɼӿ + * @param pInterfaceInfoList [IN][OUT] ɼб + * @return ɹMV_OK󣬷ش + + * @~english + * @brief öٲɼ + * @param nTLayerType [IN] ɼӿ + * @param pInterfaceInfoList [IN][OUT] ɼб + * @return ɹMV_OK󣬷ش + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumInterfaces(IN unsigned int nTLayerType, IN OUT MV_INTERFACE_INFO_LIST* pInterfaceInfoList); + +/********************************************************************//** + * @~chinese + * @brief ɼ + * @param handle [OUT] ɼ + * @param pInterfaceInfo [IN] ɼϢ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief ɼ + * @param handle [OUT] ɼ + * @param pInterfaceInfo [IN] ɼϢ + * @return ɹMV_OK󣬷ش + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateInterface(IN OUT void ** handle, IN MV_INTERFACE_INFO* pInterfaceInfo); + +/********************************************************************//** + * @~chinese + * @brief ͨɼIDɼ + * @param handle [[OUT] ɼ + * @param pInterfaceID [IN] ɼID + * @return ɹMV_OK󣬷ش + + * @~english + * @brief ͨɼIDɼ + * @param handle [IN][OUT] ɼ + * @param pInterfaceID [IN] ɼID + * @return ɹMV_OK󣬷ش + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateInterfaceByID(IN OUT void ** handle, IN char* pInterfaceID); + +/********************************************************************//** + * @~chinese + * @brief 򿪲ɼ + * @param handle [IN] ɼ + * @param pReserved [IN] ԤֱNULL + * @return ɹMV_OK󣬷ش + + * @~english + * @brief 򿪲ɼ + * @param handle [IN] ɼ + * @param pReserved [IN] ԤֱNULL + * @return ɹMV_OK󣬷ش + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_OpenInterface(IN void* handle, IN char* pReserved); + +/********************************************************************//** + * @~chinese + * @brief رղɼ + * @param handle [IN]ɼ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief رղɼ + * @param handle [IN]ɼ + * @return ɹMV_OK󣬷ش + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CloseInterface(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ٲɼ + * @param handle [IN]ɼ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief ٲɼ + * @param handle [IN]ɼ + * @return ɹMV_OK󣬷ش +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DestroyInterface(IN void* handle); + + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN][OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ + ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandleWithoutLog + + * @~english + * @brief Create Device Handle + * @param handle [IN][OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + Create handle and call SDK interface through this interface, and SDK log file will be created by default. + Creating handle through MV_CC_CreateHandleWithoutLog will not generate log files. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandle(IN OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸־ + * @param handle [IN][OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ + ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandle־ļԶ + + * @~english + * @brief Create Device Handle without log + * @param handle [IN][OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, + create handle through MV_CC_CreateHandle, and log files will be automatically generated. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleWithoutLog(IN OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Destroy Device Handle + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DestroyHandle(IN void * handle); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nAccessMode [IN] Ȩ, μCameraParams.h, :#define MV_ACCESS_Exclusive 1 + * @param nSwitchoverKey [IN] лȨʱԿ + * @return ɹMV_OK󣬷ش + * @remarks õ豸ҵӦ豸豸, ýӿʱɲnAccessModenSwitchoverKeyʱĬ豸ģʽΪռȨޡ + Ŀǰ豸ݲ֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableMV_ACCESS_ControlSwitchEnableWithKeyռģʽ + U3V豸nAccessModenSwitchoverKeyЧ + ýӿ֧豸öֱӴ򿪣֧UںGenTL豸öٴ豸 + + * @~english + * @brief Open Device + * @param handle [IN] Device handle + * @param nAccessMode [IN] Access Right, Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_ACCESS_Exclusive 1 + * @param nSwitchoverKey [IN] Switch key of access right + * @return Success, return MV_OK. Failure, return error code + * @remarks Find specific device and connect according to set device parameters.When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, + and the device access mode is exclusive. Currently the device does not support the following preemption modes: + MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey; For USB3Vision device, nAccessMode, nSwitchoverKey are invalid. + This Interface support open without enumeration by GEV deviceUSB device and GenTL device don't support . + ************************************************************************/ #ifndef __cplusplus - MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice( - IN void *handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey - ); +MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey); #else -MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice( - IN void *handle, IN unsigned int nAccessMode = MV_ACCESS_Exclusive, IN unsigned short nSwitchoverKey = 0 -); +MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode = MV_ACCESS_Exclusive, IN unsigned short nSwitchoverKey = 0); #endif - /********************************************************************/ /** - * @~chinese - * @brief 关闭相机 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK ;错误,返回错误码 - * @remarks 通过MV_CC_OpenDevice连接设备后,可以通过该接口断开设备连接,释放资源 - - * @~english - * @brief Close Device - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release - resources. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_CloseDevice(IN void *handle); - - /********************************************************************/ /** - * @~chinese - * @brief 判断相机是否处于连接状态 - * @param handle [IN] 设备句柄 - * @return 设备处于连接状态,返回true;没连接或失去连接,返回false - - * @~english - * @brief Is The Device Connected - * @param handle [IN] Device handle - * @return Connected, return true. Not Connected or DIsconnected, return false - ***********************************************************************/ - MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceConnected(IN void *handle); - - /********************************************************************/ /** - * @~chinese - * @brief 注册图像数据回调 - * @param handle [IN] 设备句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过该接口可以设置图像数据回调函数,在MV_CC_CreateHandle之后即可调用。 \n - 图像数据采集有两种方式,两种方式不能复用: - - - 方式一:调用MV_CC_RegisterImageCallBackEx设置图像数据回调函数,然后调用MV_CC_StartGrabbing开始采集,采集的图像数据在设置的回调函数中返回。 - - - 方式二:调用MV_CC_StartGrabbing开始采集,然后在应用层循环调用MV_CC_GetOneFrameTimeout获取指定像素格式的帧数据,获取帧数据时上层应用程序需要根据帧率控制好调用该接口的频率。 - 该接口仅在windows版本和Linux版本下支持。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Register the image callback function - * @param handle [IN] Device handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.\n - There are two available image data acquisition modes, and cannot be used together: - - Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then call - MV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function. - - Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly - in application layer to get frame data of specified pixel format. When getting frame data, the frequency of - calling this interface should be controlled by upper layer application according to frame rate. This API is not - supported by CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackEx( - void *handle, - void(__stdcall *cbOutput)(unsigned char *pData, MV_FRAME_OUT_INFO_EX *pFrameInfo, void *pUser), - void *pUser - ); - - /********************************************************************/ /** - * @~chinese - * @brief 注册图像数据回调,RGB - * @param handle [IN] 设备句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过该接口可以设置图像数据回调函数,在MV_CC_CreateHandle之后即可调用。 \n - 图像数据采集有两种方式,两种方式不能复用: - - - 方式一:调用MV_CC_RegisterImageCallBackForRGB设置RGB24格式图像数据回调函数,然后调用MV_CC_StartGrabbing开始采集,采集的图像数据在设置的回调函数中返回。 - - - 方式二:调用MV_CC_StartGrabbing开始采集,然后在应用层循环调用MV_CC_GetImageForRGB获取RGB24格式的帧数据,获取帧数据时上层应用程序需要根据帧率控制好调用该接口的频率。\n\n - 该接口仅在windows版本和Linux版本下支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief register image data callback, RGB - * @param handle [IN] Device handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API - MV_CC_CreateHandle. \n There are two image acquisition modes, the two modes cannot be reused: - - Mode 1: Call #MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, - and then call #MV_CC_StartGrabbing to start acquisition, - the collected image data will be returned in the configured callback function. - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB - repeatedly in application layer to get frame data with RGB24 format. - When getting frame data, the upper application program should control the frequency - of calling this API according to frame rate. \n\n - This API is not supported by CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForRGB( - void *handle, - void(__stdcall *cbOutput)(unsigned char *pData, MV_FRAME_OUT_INFO_EX *pFrameInfo, void *pUser), - void *pUser - ); - - /********************************************************************/ /** - * @~chinese - * @brief 注册图像数据回调,BGR - * @param handle [IN] 设备句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回 #MV_OK ;错误,返回错误码 - * @remarks 通过该接口可以设置图像数据回调函数,在MV_CC_CreateHandle之后即可调用。\n - 图像数据采集有两种方式,两种方式不能复用:\n - - 方式一:调用 #MV_CC_RegisterImageCallBackForBGR 设置 #BGR24 图像数据回调函数,然后调用 - #MV_CC_StartGrabbing 开始采集,采集的图像数据在设置的回调函数中返回。 - - 方式二:调用 #MV_CC_StartGrabbing 开始采集,然后在应用层循环调用 #MV_CC_GetImageForBGR 获取 #BGR24 - 格式的帧数据,获取帧数据时上层应用程序需要根据帧率控制好调用该接口的频率。 \n\n - 该接口仅在windows版本和Linux版本下支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief register image data callback, BGR - * @param handle [IN] Device handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API - MV_CC_CreateHandle. \n There are two image acquisition modes, the two modes cannot be reused: \n - - Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and - then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured - callback function.\n - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in - application layer to get frame data with BGR24 format. When getting frame data, the upper application program - should control the frequency of calling this API according to frame rate.\n This API is not supported by - CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForBGR( - void *handle, - void(__stdcall *cbOutput)(unsigned char *pData, MV_FRAME_OUT_INFO_EX *pFrameInfo, void *pUser), - void *pUser - ); - - /********************************************************************/ /** - * @~chinese - * @brief 开始取流 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口不支持CameraLink设备。 - - * @~english - * @brief Start Grabbing - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is not supported by CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_StartGrabbing(IN void *handle); - - /********************************************************************/ /** - * @~chinese - * @brief 停止取流 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口不支持CameraLink设备。 - - * @~english - * @brief Stop Grabbing - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is not supported by CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_StopGrabbing(IN void *handle); - - /********************************************************************/ /** - * @~chinese - * @brief 获取一帧RGB数据,此函数为查询式获取,每次调用查询内部 - 缓存有无数据,有数据则获取数据,无数据返回错误码 - * @param handle [IN] 设备句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @param nMsec [IN] 等待超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 每次调用该接口,将查询内部缓存是否有数据,如果有数据则转换成RGB24格式返回,如果没有数据则返回错误码。因为图像转换成RGB24格式有耗时,所以当数据帧率过高时该接口可能会导致丢帧。\n - 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。 - \n 该接口不支持CameraLink设备。 \n 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Get one frame of RGB data, this function is using query to get data - query whether the internal cache has data, get data if there has, return error code if no data - * @param handle [IN] Device handle - * @param pData [OUT] Image data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pFrameInfo [OUT] Image information structure - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API - MV_CC_CreateHandle. \n There are two image acquisition modes, the two modes cannot be reused: \n - - Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and - then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured - callback function.\n - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in - application layer to get frame data with BGR24 format. When getting frame data, the upper application program - should control the frequency of calling this API according to frame rate. \n This API is not supported by - CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetImageForRGB( - IN void *handle, - IN OUT unsigned char *pData, - IN unsigned int nDataSize, - IN OUT MV_FRAME_OUT_INFO_EX *pFrameInfo, - int nMsec - ); - - /********************************************************************/ /** - * @~chinese - * @brief 获取一帧BGR数据,此函数为查询式获取,每次调用查询内部 - 缓存有无数据,有数据则获取数据,无数据返回错误码 - * @param handle [IN] 设备句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @param nMsec [IN] 等待超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 每次调用该接口,将查询内部缓存是否有数据,如果有数据则转换成BGR24格式返回,如果没有数据则返回错误码。因为图像转换成BGR24格式有耗时,所以当数据帧率过高时该接口可能会导致丢帧。 - \n - 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。\n - 该接口不支持CameraLink设备。\n - 该接口仅在windows版本和Linux版本下支持。 - - - * @~english - * @brief Get one frame of BGR data, this function is using query to get data - query whether the internal cache has data, get data if there has, return error code if no data - * @param handle [IN] Device handle - * @param pData [OUT] Image data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pFrameInfo [OUT] Image information structure - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to set image data callback function, you should call this API - MV_CC_CreateHandle. \n There are two image acquisition modes, the two modes cannot be reused: \n - - Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and - then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured - callback function.\n - - Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in - application layer to get frame data with BGR24 format. When getting frame data, the upper application program - should control the frequency of calling this API according to frame rate. \n This API is not supported by - CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetImageForBGR( - IN void *handle, - IN OUT unsigned char *pData, - IN unsigned int nDataSize, - IN OUT MV_FRAME_OUT_INFO_EX *pFrameInfo, - int nMsec - ); - - /********************************************************************/ /** - * @~chinese - * @brief 使用内部缓存获取一帧图片(与MV_CC_Display不能同时使用) - * @param handle [IN] 设备句柄 - * @param pFrame [OUT] 图像数据和图像信息 - * @param nMsec [IN] 等待超时时间,输入INFINITE时表示无限等待,直到收到一帧数据或者停止取流 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。该接口支持设置超时时间,SDK内部等待直到有数据时返回,可以增加取流平稳性,适合用于对平稳性要求较高的场合。 - \n - 该接口与MV_CC_FreeImageBuffer配套使用,当处理完取到的数据后,需要用MV_CC_FreeImageBuffer接口将pFrame内的数据指针权限进行释放。 - \n - 该接口与MV_CC_GetOneFrameTimeout相比,有着更高的效率。且其取流缓存的分配是由sdk内部自动分配的,而MV_CC_GetOneFrameTimeout接口是需要客户自行分配。\n - 该接口在调用MV_CC_Display后无法取流。 \n - 该接口对于U3V、GIGE设备均可支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Get a frame of an image using an internal cache - * @param handle [IN] Device handle - * @param pFrame [OUT] Image data and image information - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image - acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling - this API according to the frame rate. This API supports setting timeout, and SDK will wait to return until data - appears. This function will increase the streaming stability, which can be used in the situation with high - stability requirement. \n This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the - acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. \n This - interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically - allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. \n - This API cannot be called to stream after calling MV_CC_Display. \n - This API is not supported by CameraLink device. \n - This API is supported by both USB3 vision camera and GigE camera. \n - **********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetImageBuffer(IN void *handle, OUT MV_FRAME_OUT *pFrame, IN unsigned int nMsec); - - /********************************************************************/ /** - * @~chinese - * @brief 释放图像缓存(此接口用于释放不再使用的图像缓存,与MV_CC_GetImageBuffer配套使用) - * @param handle [IN] 设备句柄 - * @param pFrame [IN] 图像数据和图像数据 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口与MV_CC_GetImageBuffer配套使用,使用MV_CC_GetImageBuffer接口取到的图像数据pFrame,需要用 - #MV_CC_FreeImageBuffer 接口进行权限释放。 \n - 该接口对于取流效率高于GetOneFrameTimeout接口,且GetImageBuffer在不进行Free的情况下,最大支持输出的节点数与 - #MV_CC_SetImageNodeNum 接口所设置的节点数相等,默认节点数是1。\n 该接口对于U3V、GIGE设备均可支持。 \n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) - * @param handle [IN] Device handle - * @param pFrame [IN] Image data and image information - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to - get image data pFrame, you should call #MV_CC_FreeImageBuffer to release the permission. \n Compared with API - MV_CC_GetOneFrameTimeout, this API has higher efficiency of image acquisition. The max. number of nodes can be - outputted is same as the "nNum" of API #MV_CC_SetImageNodeNum, default value is 1. \n This API is not supported by - CameraLink device. \n This API is supported by both USB3 vision camera and GigE camera. - **********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_FreeImageBuffer(IN void *handle, IN MV_FRAME_OUT *pFrame); - - /********************************************************************/ /** - * @~chinese - * @brief 采用超时机制获取一帧图片,SDK内部等待直到有数据时返回 - * @param handle [IN] 设备句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @param nMsec [IN] 等待超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 调用该接口获取图像数据帧之前需要先调用MV_CC_StartGrabbing启动图像采集。该接口为主动式获取帧数据,上层应用程序需要根据帧率,控制好调用该接口的频率。该接口支持设置超时时间,SDK内部等待直到有数据时返回,可以增加取流平稳性,适合用于对平稳性要求较高的场合。\n - 该接口对于U3V、GIGE设备均可支持。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned - * @param handle [IN] Device handle - * @param pData [OUT] Image data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pFrameInfo [OUT] Image information structure - * @param nMsec [IN] Waiting timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. - This API can get frame data actively, the upper layer program should control the frequency of calling this API - according to the frame rate. This API supports setting timeout, SDK will wait to return until data appears. This - function will increase the streaming stability, which can be used in the situation with high stability - requirement. \n Both the USB3Vision and GIGE camera can support this API. \n This API is not supported by - CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameTimeout( - IN void *handle, - IN OUT unsigned char *pData, - IN unsigned int nDataSize, - IN OUT MV_FRAME_OUT_INFO_EX *pFrameInfo, - unsigned int nMsec - ); - - /********************************************************************/ /** - * @~chinese - * @brief 显示图像,注册显示窗口,内部自动显示(与MV_CC_GetImageBuffer不能同时使用) - * @param handle [IN] 句柄 - * @param hWnd [IN] 显示窗口句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Display one frame image, register display window, automatic display internally - * @param handle [IN] Handle - * @param hWnd [IN] Display Window Handle - * @return Success, return #MV_OK. Failure, return error code - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_Display(IN void *handle, void *hWnd); - - /********************************************************************/ /** - * @~chinese - * @brief 显示一帧图像 - * @param handle [IN] 设备句柄 - * @param pDisplayInfo [IN] 图像信息 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 该接口对于U3V、GIGE设备均可支持。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Display one frame image - * @param handle [IN] Device handle - * @param pDisplayInfo [IN] Frame Info - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is valid for USB3Vision camera and GIGE camera. \n - This API is not supported by CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_DisplayOneFrame(IN void *handle, IN MV_DISPLAY_FRAME_INFO *pDisplayInfo); - - /********************************************************************/ /** - * @~chinese - * @brief 设置SDK内部图像缓存节点个数,大于等于1,在抓图前调用 - * @param handle [IN] 设备句柄 - * @param nNum [IN] 缓存节点个数,范围[1,30],默认为1 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 调用该接口可以设置SDK内部图像缓存节点个数,在调用MV_CC_StartGrabbing开始抓图前调用。\n - 增加图像缓存节点个数会增加SDK使用的内存,但是可以有效避免某些性能差的ARM板出现的跳帧现象。\n - 该接口不支持CameraLink设备。 - - * @~english - * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called - before the capture - * @param handle [IN] Device handle - * @param nNum [IN] Image Node Number, range[1,30], default 1 - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this interface to set the number of SDK internal image buffer nodes. - The interface should be called before calling MV_CC_StartGrabbing for capturing. \n - Increasing the number of image cache nodes will increase the memory used by the SDK, - but it can effectively avoid frame skipping on some ARM boards with poor performance. \n - This API is not supported by CameraLink device. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetImageNodeNum(IN void *handle, unsigned int nNum); - - /********************************************************************/ /** - * @~chinese - * @brief 获取设备信息,取流之前调用 - * @param handle [IN] 设备句柄 - * @param pstDevInfo [IN][OUT] 返回给调用者有关相机设备信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 支持用户在打开设备后获取设备信息。\n - 若该设备是GigE相机,则调用该接口存在阻塞风险,因此不建议在取流过程中调用该接口。 - - * @~english - * @brief Get device information - * @param handle [IN] Device handle - * @param pstDevInfo [IN][OUT] Structure pointer of device information - * @return Success, return #MV_OK. Failure, return error code - * @remarks The API support users to access device information after opening the device. \n - If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not - recommended to call the interface during the fetching process. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceInfo(IN void *handle, IN OUT MV_CC_DEVICE_INFO *pstDevInfo); - - /********************************************************************/ /** - * @~chinese - * @brief 获取各种类型的信息 - * @param handle [IN] 设备句柄 - * @param pstInfo [IN][OUT] 返回给调用者有关相机各种类型的信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 接口里面输入需要获取的信息类型(指定MV_ALL_MATCH_INFO结构体中的nType类型),获取对应的信息(在MV_ALL_MATCH_INFO结构体中pInfo里返回)。 - \n - 该接口的调用前置条件取决于所获取的信息类型,获取GigE设备的MV_MATCH_TYPE_NET_DETECT信息需在开启抓图之后调用,获取U3V设备的MV_MATCH_TYPE_USB_DETECT信息需在打开设备之后调用。 - \n 该接口不支持CameraLink设备。 - - * @~english - * @brief Get various type of information - * @param handle [IN] Device handle - * @param pstInfo [IN][OUT] Structure pointer of various type of information - * @return Success, return #MV_OK. Failure, return error code - * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and - get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO). \n The calling precondition of - this interface is determined by obtained information type. Call after enabling capture to get - MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get - MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. \n This API is not supported by CameraLink device. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAllMatchInfo(IN void *handle, IN OUT MV_ALL_MATCH_INFO *pstInfo); - - /************************************************************************/ - /* 设置和获取相机参数的万能接口 */ - /* General interface for getting and setting camera parameters */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 获取Integer属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param pIntValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表, - * 表格里面数据类型为“IInteger”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to get width - * @param pIntValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to get the value of camera node with integer type after connecting the device. - * For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list - * can be obtained via this API. strKey corresponds to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue( - IN void *handle, IN const char *strKey, OUT MVCC_INTVALUE *pIntValue - ); - - /********************************************************************/ /** - * @~chinese - * @brief 获取Integer属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param pIntValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 连接设备之后调用该接口可以获取int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表, - * 表格里面数据类型为“IInteger”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to get width - * @param pIntValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to get the value of camera node with integer type after connecting the device. - * For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list - * can be obtained via this API. strKey corresponds to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetIntValueEx( - IN void *handle, IN const char *strKey, OUT MVCC_INTVALUE_EX *pIntValue - ); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Integer型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param nValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IInteger”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to set width - * @param nValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to set the value of camera node with integer type after connecting the device. - For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this - API. strKey corresponds to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void *handle, IN const char *strKey, IN unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Integer型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取宽度信息则为"Width" - * @param nValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置int类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IInteger”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Integer value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "Width" to set width - * @param nValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks You can call this API to set the value of camera node with integer type after connecting the device. - For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this - API. strKey corresponds to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetIntValueEx(IN void *handle, IN const char *strKey, IN int64_t nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取Enum属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取像素格式信息则为"PixelFormat" - * @param pEnumValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以获取Enum类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IEnumeration”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Enum value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel - format - * @param pEnumValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, - see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds - to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetEnumValue( - IN void *handle, IN const char *strKey, OUT MVCC_ENUMVALUE *pEnumValue - ); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Enum型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取像素格式信息则为"PixelFormat" - * @param nValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置Enum类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IEnumeration”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Enum value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel - format - * @param nValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified Enum nodes. For value of strKey, - see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds - to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValue(IN void *handle, IN const char *strKey, IN unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Enum型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值,如获取像素格式信息则为"PixelFormat" - * @param sValue [IN] 想要设置的相机的属性字符串 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置Enum类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IEnumeration”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Enum value - * @param handle [IN] Device handle - * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel - format - * @param sValue [IN] Feature String to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API after connecting the device. All the values of nodes with IEnumeration type can be set - via this API. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValueByString( - IN void *handle, IN const char *strKey, IN const char *sValue - ); - - /********************************************************************/ /** - * @~chinese - * @brief 获取Float属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param pFloatValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以获取float类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IFloat”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Float value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param pFloatValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified float node. For detailed strKey - value see: MvCameraNode. The node values of IFloat can be obtained through this interface, strKey value - corresponds to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetFloatValue( - IN void *handle, IN const char *strKey, OUT MVCC_FLOATVALUE *pFloatValue - ); - - /********************************************************************/ /** - * @~chinese - * @brief 设置float型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param fValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置float类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IFloat”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set float value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param fValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified float node. For detailed strKey - value see: MvCameraNode. The node values of IFloat can be set through this interface, strKey value corresponds to - the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetFloatValue(IN void *handle, IN const char *strKey, IN float fValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取Boolean属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param pBoolValue [IN][OUT] 返回给调用者有关相机属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以获取bool类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IBoolean”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get Boolean value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param pBoolValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified bool nodes. For value of strKey, - see MvCameraNode. The node values of IBoolean can be obtained through this interface, strKey value corresponds to - the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBoolValue(IN void *handle, IN const char *strKey, OUT bool *pBoolValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Boolean型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param bValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置bool类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IBoolean”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set Boolean value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param bValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified bool nodes. For value of strKey, - see MvCameraNode. The node values of IBoolean can be set through this interface, strKey value corresponds to the - Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBoolValue(IN void *handle, IN const char *strKey, IN bool bValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取String属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param pStringValue [IN][OUT] 返回给调用者有关相机属性结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以获取string类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IString”的节点值都可以通过该接口获取,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Get String value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param pStringValue [IN][OUT] Structure pointer of camera features - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to get specified string nodes. For value of strKey, - see MvCameraNode. The node values of IString can be obtained through this interface, strKey value corresponds to - the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetStringValue( - IN void *handle, IN const char *strKey, OUT MVCC_STRINGVALUE *pStringValue - ); - - /********************************************************************/ /** - * @~chinese - * @brief 设置String型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @param sValue [IN] 想要设置的相机的属性值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置string类型的指定节点的值。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“IString”的节点值都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Set String value - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @param sValue [IN] Feature value to set - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified string nodes. For value of strKey, - see MvCameraNode. The node values of IString can be set through this interface, strKey value corresponds to the - Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetStringValue(IN void *handle, IN const char *strKey, IN const char *sValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Command型属性值 - * @param handle [IN] 设备句柄 - * @param strKey [IN] 属性键值 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 连接设备之后调用该接口可以设置指定的Command类型节点。strKey取值可以参考XML节点参数类型列表,表格里面数据类型为“ICommand”的节点都可以通过该接口设置,strKey参数取值对应列表里面的“名称”一列。 - - * @~english - * @brief Send Command - * @param handle [IN] Device handle - * @param strKey [IN] Key value - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set specified Command nodes. For value of - strKey, see MvCameraNode. The node values of ICommand can be set through this interface, strKey value corresponds - to the Name column. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetCommandValue(IN void *handle, IN const char *strKey); - - /********************************************************************/ /** - * @~chinese - * @brief 清除GenICam节点缓存 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Invalidate GenICam Nodes - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_InvalidateNodes(IN void *handle); - - /************************************************************************/ - /* 设备升级 和 寄存器读写 和异常、事件回调 */ - /* Device upgrade, register read and write and exception callback */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 设备本地升级 - * @param handle [IN] 设备句柄 - * @param pFilePathName [IN] 文件名 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 通过该接口可以将升级固件文件发送给设备进行升级。该接口需要等待升级固件文件成功传给设备端之后再返回,响应时间可能较长。 - - * @~english - * @brief Device Local Upgrade - * @param handle [IN] Device handle - * @param pFilePathName [IN] File name - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_LocalUpgrade(IN void *handle, const void *pFilePathName); - - /********************************************************************/ /** - * @~chinese - * @brief 获取升级进度 - * @param handle [IN] 设备句柄 - * @param pnProcess [OUT] 进度接收地址 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 获取升级进度百分值。 - - * @~english - * @brief Get Upgrade Progress - * @param handle [IN] Device handle - * @param pnProcess [OUT] Progress receiving address - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to send the upgrade firmware to the device for upgrade. This API will wait for return - until the upgrade firmware is sent to the device, this response may take a long time. \n For CameraLink device, it - keeps sending upgrade firmware continuously. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetUpgradeProcess(IN void *handle, unsigned int *pnProcess); - - /********************************************************************/ /** - * @~chinese - * @brief 读内存 - * @param handle [IN] 设备句柄 - * @param pBuffer [IN][OUT] 作为返回值使用,保存读到的内存值(内存值是按照大端模式存储的) - * @param nAddress [IN] - 待读取的内存地址,该地址可以从设备的Camera.xml文件中获取,形如xxx_RegAddr的xml节点值 - * @param nLength [IN] 待读取的内存长度 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 访问设备,读取某段寄存器的数据。 - - * @~english - * @brief Read Memory - * @param handle [IN] Device Handle - * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( - Memory value is stored in accordance with the big end model) - * @param nAddress [IN] Memory address to be read, which can be obtained from the - Camera.xml file of the device, the form xml node value of xxx_RegAddr - * @param nLength [IN] Length of the memory to be read - * @return Success, return #MV_OK. Failure, return error code - * @remarks Access device, read the data from certain register. - *************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_ReadMemory(IN void *handle, void *pBuffer, int64_t nAddress, int64_t nLength); - - /********************************************************************/ /** - * @~chinese - * @brief 写内存 - * @param handle [IN] 设备句柄 - * @param pBuffer [IN] 待写入的内存值(注意内存值要按照大端模式存储) - * @param nAddress [IN] - 待写入的内存地址,该地址可以从设备的Camera.xml文件中获取,形如xxx_RegAddr的xml节点值 - * @param nLength [IN] 待写入的内存长度 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 访问设备,把一段数据写入某段寄存器。 - - * @~english - * @brief Write Memory - * @param handle [IN] Device Handle - * @param pBuffer [IN] Memory value to be written ( Note the memory value to be - stored in accordance with the big end model) - * @param nAddress [IN] Memory address to be written, which can be obtained from - the Camera.xml file of the device, the form xml node value of xxx_RegAddr - * @param nLength [IN] Length of the memory to be written - * @return Success, return #MV_OK. Failure, return error code - * @remarks Access device, write a piece of data into a certain segment of register. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_WriteMemory( - IN void *handle, const void *pBuffer, int64_t nAddress, int64_t nLength - ); - - /********************************************************************/ /** - * @~chinese - * @brief 注册异常消息回调,在打开设备之后调用 - * @param handle [IN] 设备句柄 - * @param cbException [IN] 异常回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 该接口需要在MV_CC_OpenDevice打开设备之后调用。设备异常断开连接后可以在回调里面获取到异常消息,GigE设备掉线之后需要先调用MV_CC_CloseDevice接口关闭设备,再调用MV_CC_OpenDevice接口重新打开设备。 - - * @~english - * @brief Register Exception Message CallBack, call after open device - * @param handle [IN] Device handle - * @param cbException [IN] Exception Message CallBack Function Pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally - disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first - call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterExceptionCallBack( - IN void *handle, void(__stdcall *cbException)(unsigned int nMsgType, void *pUser), void *pUser - ); - - /********************************************************************/ /** - * @~chinese - * @brief 注册全部事件回调,在打开设备之后调用 - * @param handle [IN] 设备句柄 - * @param cbEvent [IN] 事件回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口设置事件回调,可以在回调函数里面获取采集、曝光等事件信息。 \n - 该接口不支持CameraLink设备。\n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Register event callback, which is called after the device is opened - * @param handle [IN] Device handle - * @param cbEvent [IN] Event CallBack Function Pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, - exposure, and so on. \n This API is not supported by CameraLink device. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterAllEventCallBack( - void *handle, void(__stdcall *cbEvent)(MV_EVENT_OUT_INFO *pEventInfo, void *pUser), void *pUser - ); - - /********************************************************************/ /** - * @~chinese - * @brief 注册单个事件回调,在打开设备之后调用 - * @param handle [IN] 设备句柄 - * @param pEventName [IN] 事件名称 - * @param cbEvent [IN] 事件回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口设置事件回调,可以在回调函数里面获取采集、曝光等事件信息。\n - 该接口不支持CameraLink设备,仅支持"设备掉线"这一种事件。 - - * @~english - * @brief Register single event callback, which is called after the device is opened - * @param handle [IN] Device handle - * @param pEventName [IN] Event name - * @param cbEvent [IN] Event CallBack Function Pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, - exposure, and so on. \n This API is not supported by CameraLink device . - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBackEx( - void *handle, - const char *pEventName, - void(__stdcall *cbEvent)(MV_EVENT_OUT_INFO *pEventInfo, void *pUser), - void *pUser - ); - - /************************************************************************/ - /* GigEVision 设备独有的接口 */ - /* GigEVision device specific interface */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 强制IP - * @param handle [IN] 设备句柄 - * @param nIP [IN] 设置的IP - * @param nSubNetMask [IN] 子网掩码 - * @param nDefaultGateWay [IN] 默认网关 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 强制设置相机网络参数(包括IP、子网掩码、默认网关),强制设置之后将需要重新创建设备句柄,仅GigEVision相机支持。\n - 如果设备为DHCP的状态,调用该接口强制设置相机网络参数之后设备将会重启。 - - * @~english - * @brief Force IP - * @param handle [IN] Device handle - * @param nIP [IN] IP to set - * @param nSubNetMask [IN] Subnet mask - * @param nDefaultGateWay [IN] Default gateway - * @return Success, return #MV_OK. Failure, return error code - * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After - forced setting, device handle should be created again. This function is only supported by GigEVision camera.\n If - device is in DHCP status, after calling this API to force setting camera network parameter, the device will - restart. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIpEx( - IN void *handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay - ); - - /********************************************************************/ /** - * @~chinese - * @brief 配置IP方式 - * @param handle [IN] 设备句柄 - * @param nType [IN] IP类型,见MV_IP_CFG_x - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 发送命令设置相机的IP方式,如DHCP、LLA等,仅GigEVision相机支持。 - - * @~english - * @brief IP configuration method - * @param handle [IN] Device handle - * @param nType [IN] IP type, refer to MV_IP_CFG_x - * @return Success, return #MV_OK. Failure, return error code - * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetIpConfig(IN void *handle, unsigned int nType); - - /********************************************************************/ /** - * @~chinese - * @brief 设置仅使用某种模式,type: MV_NET_TRANS_x,不设置时,默认优先使用driver - * @param handle [IN] 设备句柄 - * @param nType [IN] 网络传输模式,见MV_NET_TRANS_x - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 通过该接口可以设置SDK内部优先使用的网络模式,默认优先使用驱动模式,仅GigEVision相机支持。 - - * @~english - * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default - * @param handle [IN] Device handle - * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x - * @return Success, return #MV_OK. Failure, return error code - * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by - GigEVision camera. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetNetTransMode(IN void *handle, unsigned int nType); - - /********************************************************************/ /** - * @~chinese - * @brief 获取网络传输信息 - * @param handle [IN] 设备句柄 - * @param pstInfo [OUT] 信息结构体 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - 通过该接口可以获取网络传输相关信息,包括已接收数据大小、丢帧数量等,在MV_CC_StartGrabbing开启采集之后调用。仅GigEVision相机支持。 - - * @~english - * @brief Get net transmission information - * @param handle [IN] Device handle - * @param pstInfo [OUT] Information Structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Get network transmission information through this API, including received data size, number of lost - frames. Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by - GigEVision Camera. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetNetTransInfo(IN void *handle, MV_NETTRANS_INFO *pstInfo); - - /********************************************************************/ /** - * @~chinese - * @brief 设置GVSP取流超时时间 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 超时时间,默认300ms,范围:>10ms - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks - 连接设备之后,取流动作发生前,调用该接口可以设置GVSP取流超时时间。GVSP取流超时设置过短可能造成图像异常,设置过长可能造成取流时间变长。 - - * @~english - * @brief Set GVSP streaming timeout - * @param handle [IN] Device handle - * @param nMillisec [IN] Timeout, default 300ms, range: >10ms - * @return Success, return MV_OK. Failure, return error code - * @remarks After the device is connected, and just before start streaming, - * call this interface to set GVSP streaming timeout value. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvspTimeout(void *handle, unsigned int nMillisec); - - /********************************************************************/ /** - * @~chinese - * @brief 获取GVSP取流超时时间 - * @param handle [IN] 设备句柄 - * @param pnMillisec [IN] 超时时间指针,以毫秒位单位 - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 该接口用于获取当前的GVSP取流超时时间 - - * @~english - * @brief Get GVSP streaming timeout - * @param handle [IN] Device handle - * @param pnMillisec [IN] Timeout, ms as unit - * @return Success, return MV_OK. Failure, return error code - * @remarks This interface is used to get the current GVSP streaming timeout. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvspTimeout(IN void *handle, unsigned int *pnMillisec); - - /********************************************************************/ /** - * @~chinese - * @brief 设置GVCP命令超时时间 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 超时时间,以毫秒位单位,范围:0-1000000 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 连接设备之后调用该接口可以设置GVCP命令超时时间。 - - * @~english - * @brief Set GVCP cammand timeout - * @param handle [IN] Device handle - * @param nMillisec [IN] Timeout, ms as unit, range: 0-1000000 - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set GVCP command timeout time. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvcpTimeout(void *handle, unsigned int nMillisec); - - /********************************************************************/ /** - * @~chinese - * @brief 获取最佳的packet size,该接口目前只支持GigE相机 - * @param handle [IN] 设备句柄 - * @return 最佳packetsize - * @remarks 获取最佳的packet - size,对应GigEVision设备是SCPS,对应U3V设备是每次从驱动读取的包大小,该大小即网络上传输一个包的大小。该接口需要在MV_CC_OpenDevice之后、MV_CC_StartGrabbing之前调用。 - \n 该接口不支持CameraLink设备。 - - * @~english - * @brief Get the optimal Packet Size, Only support GigE Camera - * @param handle [IN] Device handle - * @return Optimal packetsize - * @remarks To get optimized packet size, for GigEVision device is SCPS, for USB3Vision device is the size of - packet read from drive each time, and it is the size of a packet transported on the network. The interface should - be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. \n This API is not supported by CameraLink - device. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetOptimalPacketSize(IN void *handle); - -/********************************************************************/ /** - * @~chinese - * @brief 设置是否打开重发包支持,及重发包设置 - * @param handle [IN] 设备句柄 - * @param bEnable [IN] 是否支持重发包 - * @param nMaxResendPercent [IN] 最大重发比 - * @param nResendTimeout [IN] 重发超时时间 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 连接设备之后调用该接口可以设置重发包属性,仅GigEVision相机支持。 \n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Set whethe to enable resend, and set resend - * @param handle [IN] Device handle - * @param bEnable [IN] enable resend - * @param nMaxResendPercent [IN] Max resend persent - * @param nResendTimeout [IN] Resend timeout - * @return Success, return #MV_OK. Failure, return error code - * @remarks After the device is connected, call this interface to set resend packet properties, only supported by - GigEVision camera. - ************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ر豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ͨMV_CC_OpenDevice豸󣬿ͨýӿڶϿ豸ӣͷԴ + + * @~english + * @brief Close Device + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CloseDevice(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ж豸Ƿ״̬ + * @param handle [IN] 豸 + * @return 豸״̬trueûӻʧȥӣfalse + + * @~english + * @brief Is The Device Connected + * @param handle [IN] Device handle + * @return Connected, return true. Not Connected or DIsconnected, return false + ***********************************************************************/ +MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceConnected(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief עͼݻص + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵ, ͼݲɼַʽַʽܸã + ʽһMV_CC_RegisterImageCallBackExͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصз + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetOneFrameTimeoutȡָظʽ֡ݣ + ȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register the image callback function + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.There are two available image data acquisition modes, and cannot be used together: + Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function. + Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly in application layer to get frame data of specified pixel format. When getting frame data, + the frequency of calling this interface should be controlled by upper layer application according to frame rate. + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackEx(IN void* handle, + IN void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), IN void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصRGB + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵáͼݲɼַʽַʽܸã + ʽһMV_CC_RegisterImageCallBackForRGBRGB24ʽͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForRGBȡRGB24ʽ֡, + ȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, RGB + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle.There are two image acquisition modes, the two modes cannot be reused: + Mode 1: Call MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function. + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB repeatedly in application layer to get frame data with RGB24 format. + When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForRGB(IN void* handle, + IN void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), IN void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصBGR + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵáͼݲɼַʽַʽܸ: + ʽһMV_CC_RegisterImageCallBackForBGRBGR24ͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForBGRȡBGR24ʽ֡, + ȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, BGR + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle.There are two image acquisition modes, the two modes cannot be reused: + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function. + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. + When getting frame data,the upper application program should control the frequency of calling this API according to frame rate. + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForBGR(IN void* handle, + IN void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), IN void* pUser); + +/********************************************************************//** + * @~chinese + * @brief ʼȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Start Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StartGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ֹͣȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Stop Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StopGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡RGBݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [IN][OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [IN][OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתRGB24ʽأû򷵻ش롣 + ΪͼתRGB24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼ + ýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of RGB data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [IN][OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [IN][OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Each time the API is called, the internal cache is checked for data. If there is data, it will be transformed as RGB24 format for return, if there is no data, return error code. + As time-consuming exists when transform the image to RGB24 format,this API may cause frame loss when the data frame rate is too high. + Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. + This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, IN int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡BGRݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [IN][OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [IN][OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתBGR24ʽأû򷵻ش롣 + ΪͼתBGR24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡.øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼ + ýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of BGR data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [IN][OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [IN][OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. + There are two image acquisition modes, the two modes cannot be reused: + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function. + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. + When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, IN int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ʹڲȡһ֡ͼƬMV_CC_Displayͬʱʹã + * @param handle [IN] 豸 + * @param pstFrame [IN][OUT] ͼݺͼϢ + * @param nMsec [IN] ȴʱʱ䣬INFINITEʱʾ޵ȴֱյһ֡ݻֹͣȡ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵ, + ýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ + ýӿMV_CC_FreeImageBufferʹãȡݺҪMV_CC_FreeImageBufferӿڽpFrameڵָȨ޽ͷš + ýӿMV_CC_GetOneFrameTimeoutȣŸߵЧʡȡķsdkڲԶģMV_CC_GetOneFrameTimeoutӿҪͻз䡣 + ýӿڵMV_CC_Display޷ȡ + ýӿڶU3VGIGE豸֧֡ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get a frame of an image using an internal cache + * @param handle [IN] Device handle + * @param pstFrame [IN][OUT] Image data and image information + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image acquisition. + This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API support setting timeout, and SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. + This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. + This interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. + This API cannot be called to stream after calling MV_CC_Display. + This API is not supported by CameraLink device. + This API is supported by both USB3 vision camera and GigE camera. + *****************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageBuffer(IN void* handle, IN OUT MV_FRAME_OUT* pstFrame, IN unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ͷͼ񻺴(˽ӿͷŲʹõͼ񻺴棬MV_CC_GetImageBufferʹ) + * @param handle [IN] 豸 + * @param pstFrame [IN] ͼݺͼ + * @return ɹMV_OK󣬷ش + * @remarks ýӿMV_CC_GetImageBufferʹãʹMV_CC_GetImageBufferӿȡͼpFrameҪMV_CC_FreeImageBufferӿڽȨͷ + ýӿڶȡЧʸGetOneFrameTimeoutӿڣGetImageBufferڲFree£֧ĽڵSetImageNodeӿõĽڵȣĬϽڵ1 + ýӿڶU3VGIGE豸֧ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) + * @param handle [IN] Device handle + * @param pstFrame [IN] Image data and image information + * @return Success, return MV_OK. Failure, return error code + * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to get image data pFrame, you should call MV_CC_FreeImageBuffer to release the permission. + Compared with API MV_CC_GetOneFrameTimeout + this API has higher efficiency of image acquisition. The max. number of nodes can be outputted is same as the "nNum" of API MV_CC_SetImageNodeNum, default value is 1. + This API is not supported by CameraLink device. + This API is supported by both USB3 vision camera and GigE camera. + **********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pstFrame); + +/********************************************************************//** + * @~chinese + * @brief óʱƻȡһ֡ͼƬSDKڲȴֱʱ + * @param handle [IN] 豸 + * @param pData [IN][OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [IN][OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼ + ýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵ + ýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵij + ýӿڶU3VGIGE豸֧ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned + * @param handle [IN] Device handle + * @param pData [IN][OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [IN][OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. + This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. + This API supports setting timeout, SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. + Both the USB3Vision and GIGE camera can support this API. + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameTimeout(IN void* handle, IN OUT unsigned char* pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, IN unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡݻ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿûڲֹͣȡʱ򣬾вҪͼ + ýӿģʽдģʽ󣬿ʷݡ + + * @~english + * @brief if Image buffers has retrieved the dataClear them + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface allows user to clear the unnecessary images from the buffer memory without stopping acquisition. + This interface allows user to clear previous data after switching from continuous mode to trigger mode. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ClearImageBuffer(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡǰͼ񻺴Чͼ + * @param handle [IN] 豸 + * @param pnValidImageNum [IN][OUT] ǰͼ񻺴Чͼָ + * @return ɹMV_OK󣬷ش + * @remarks + + * @~english + * @brief Get the number of valid images in the current image buffer + * @param handle [IN] Device handle + * @param pnValidImageNum [IN][OUT] The number of valid images in the current image buffer + * @return Success, return MV_OK. Failure, return error code + * @remarks + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetValidImageNum(IN void* handle, IN OUT unsigned int *pnValidImageNum); + +/********************************************************************//** + * @~chinese + * @brief ʾһ֡ͼ + * @param handle [IN] 豸 + * @param pstDisplayInfo [IN] ͼϢ + * @return ɹMV_OK󣬷ش + * @remarks 豸޹ + + * @~english + * @brief Display one frame image + * @param handle [IN] Device handle + * @param pstDisplayInfo [IN] Frame Info + * @return Success, return MV_OK. Failure, return error code + * @remarks Not related to device type + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pstDisplayInfo); + +/********************************************************************//** + * @~chinese + * @brief ʾһ֡ͼ + * @param handle [IN] 豸 + * @param hWnd [IN] ھ + * @param pstDisplayInfo [IN] ͼϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧PixelType_Gvsp_RGB8_PackedPixelType_Gvsp_BGR8_PackedPixelType_Gvsp_Mono8ظʽȾߴСint + * ظʽȾֿ֧short + + * @~english + * @brief Display one frame image + * @param handle [IN] Device handle + * @param hWnd [IN] HWND + * @param pstDisplayInfo [IN] Frame Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support rendering in three pixel formats:PixelType_Gvsp_RGB8_Packed,PixelType_Gvsp_BGR8_Packed and PixelType_Gvsp_Mono8,width and height to int. + * The rest of the pixel format rendering only supports width and height to short. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DisplayOneFrameEx(IN void* handle, IN void* hWnd, IN MV_DISPLAY_FRAME_INFO_EX* pstDisplayInfo); + +/********************************************************************//** + * @~chinese + * @brief SDKڲͼ񻺴ڵڵ1ץͼǰ + * @param handle [IN] 豸 + * @param nNum [IN] ڵ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڿSDKڲͼ񻺴ڵڵMV_CC_StartGrabbingʼץͼǰá + SDKĬ1ڵ㡣 + CameraLink豸ýӿڲִ֧ڷʽ,֧GenTLʽӡ + + * @~english + * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture + * @param handle [IN] Device handle + * @param nNum [IN] Image Node Number + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface to set the number of SDK internal image buffer nodes. The interface should be called before calling MV_CC_StartGrabbing for capturing. + In the SDK, it defaults to 1 node. + For CameraLink devices: This interface does not support serial connection, but supports GenTL connection. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetImageNodeNum(IN void* handle, IN unsigned int nNum); + +/********************************************************************//** + * @~chinese + * @brief ȡԣýӿֻ֧windowsƽ̨ + * @param handle [IN] 豸 + * @param enGrabStrategy [IN] öֵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶȡԣûԸʵѡ񡣾£ + OneByOne:Ӿɵһ֡һ֡Ĵблȡͼ񣬴豸ĬΪò + LatestImagesOnly:блȡµһ֡ͼͬʱб + LatestImages:блȡµOutputQueueSize֡ͼOutputQueueSizeΧΪ1-ImageNodeNumMV_CC_SetOutputQueueSizeӿãImageNodeNumĬΪ1 + MV_CC_SetImageNodeNumӿ OutputQueueSizeó1ͬLatestImagesOnlyԣOutputQueueSizeóImageNodeNumͬOneByOne + UpcomingImage:ڵȡӿʱбͼ񣬲ȴ豸ɵһ֡ͼ񡣸òֻ֧GigE豸֧U3V豸 + + * @~english + * @brief Set Grab StrategyThis interface only supports windows platform + * @param handle [IN] Device handle + * @param enGrabStrategy [IN] The value of Grab Strategy + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is set by four image acquisition approaches, the user may choose one as needed. Specific details are as followed: + OneByOne:Obtain image from output cache list frame by frame in order, this function is default strategy when device is on. + LatestImagesOnly:Obtain the latest image from output cache list only, meanwhile clear output cache list. + LatestImages:Obtain the latest OutputQueueSize image from output cache list, the range of OutputQueueSize is 1-ImageNodeNum, + the user may set the value of MV_CC_SetOutputQueueSizeinterface,the default value of ImageNodeNum is 1, + If the user usesMV_CC_SetImageNodeNuminterface to set up OutputQueueSize,when the value of OutputQueueSize is set to be 1, + the function will be same as LatestImagesOnly; if the value of OutputQueueSize is set to be ImageNodeNum, the function will be same as OneByOne. + UpcomingImage:Ignore all images in output cache list when calling image acuiqisiotn interface, wait the next upcoming image generated. Support for GigE camera only, not support for U3V camera. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGrabStrategy(IN void* handle, IN MV_GRAB_STRATEGY enGrabStrategy); + +/********************************************************************//** + * @~chinese + * @brief ýӿֻ֧windowsƽֻ̨MV_GrabStrategy_LatestImages²ЧΧ1-ImageNodeNum + * @param handle [IN] 豸 + * @param nOutputQueueSize [IN] + * @return ɹMV_OK󣬷ش + * @remarks ýӿLatestImagesȡ׵ãLatestImagesͼĸȡж̬ + + * @~english + * @brief Set The Size of Output Queue(This interface only supports windows platform, Only work under the strategy of MV_GrabStrategy_LatestImagesrang1-ImageNodeNum) + * @param handle [IN] Device handle + * @param nOutputQueueSize [IN] The Size of Output Queue + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface must be used with LatestImages Grab strategy, it is used for setting the maximum allowance queue size of the image under the LatestImages strategy. + The user may change the output queue size while grabbing images. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetOutputQueueSize(IN void* handle, IN unsigned int nOutputQueueSize); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸Ϣȡ֮ǰ + * @param handle [IN] 豸 + * @param pstDevInfo [IN][OUT] ظй豸Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ֧ûڴ豸ȡ豸Ϣ֧GenTL豸 + 豸GigE豸øýӿڴգ˲ȡеøýӿڡ + + * @~english + * @brief Get device information + * @param handle [IN] Device handle + * @param pstDevInfo [IN][OUT] Structure pointer of device information + * @return Success, return MV_OK. Failure, return error code + * @remarks The API support users to access device information after opening the devicedon't support GenTL Devices + If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not recommended to call the interface during the fetching process. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief ȡ͵Ϣ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظй豸͵Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӿҪȡϢָͣMV_ALL_MATCH_INFOṹеnTypeͣȡӦϢMV_ALL_MATCH_INFOṹpInfoﷵأ + ýӿڵĵǰȡȡϢͣȡGigE豸MV_MATCH_TYPE_NET_DETECTϢڿץͼ֮ãȡU3V豸MV_MATCH_TYPE_USB_DETECTϢڴ豸֮ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get various type of information + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of various type of information + * @return Success, return MV_OK. Failure, return error code + * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO) + The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, + and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo); + + + +/*******************Part2 ch: ýӿ | en: Camera attribute nodes universal interface*******************/ + +/********************************************************************//** + * @~chinese + * @brief ȡIntegerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param pstIntValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡint͵ָڵֵ + + * @~english + * @brief Get Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to get width + * @param pstIntValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,IN OUT MVCC_INTVALUE_EX *pstIntValue); + +/********************************************************************//** + * @~chinese + * @brief Integerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿint͵ָڵֵ + + * @~english + * @brief Set Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to set width + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue); + +/********************************************************************//** + * @~chinese + * @brief ȡEnumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param pstEnumValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡEnum͵ָڵֵ + + * @~english + * @brief Get Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel format + * @param pstEnumValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetEnumValue(IN void* handle,IN const char* strKey,IN OUT MVCC_ENUMVALUE *pstEnumValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵ + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Enum nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + +/********************************************************************//** + * @~chinese + * @brief ȡEnumͽڵֵָķ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param pstEnumEntry [IN][OUT] Ҫȡ豸Է + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡEnum͵ָڵֵӦķš + + * @~english + * @brief Get the symbolic of the specified value of the Enum type node + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param pstEnumEntry [IN][OUT] Symbolic to get + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface after connecting the device to obtain the symbol corresponding to the value of the specified node of Enum type. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetEnumEntrySymbolic(IN void* handle,IN const char* strKey,IN OUT MVCC_ENUMENTRY* pstEnumEntry); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param strValue [IN] Ҫõ豸ַ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵ + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param strValue [IN] Feature String to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Enum nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValueByString(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief ȡFloatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstFloatValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡfloat͵ָڵֵ + + * @~english + * @brief Get Float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstFloatValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified float node. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFloatValue(IN void* handle,IN const char* strKey,IN OUT MVCC_FLOATVALUE *pstFloatValue); + +/********************************************************************//** + * @~chinese + * @brief floatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param fValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿfloat͵ָڵֵ + + * @~english + * @brief Set float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param fValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified float node. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFloatValue(IN void* handle,IN const char* strKey,IN float fValue); + +/********************************************************************//** + * @~chinese + * @brief ȡBooleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pbValue [IN][OUT] ظй豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡbool͵ָڵֵ + + * @~english + * @brief Get Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pbValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified bool nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBoolValue(IN void* handle,IN const char* strKey,IN OUT bool *pbValue); + +/********************************************************************//** + * @~chinese + * @brief Booleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param bValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿbool͵ָڵֵ + + * @~english + * @brief Set Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param bValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified bool nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBoolValue(IN void* handle,IN const char* strKey,IN bool bValue); + +/********************************************************************//** + * @~chinese + * @brief ȡStringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstStringValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡstring͵ָڵֵ + + * @~english + * @brief Get String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstStringValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified string nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetStringValue(IN void* handle,IN const char* strKey,IN OUT MVCC_STRINGVALUE *pstStringValue); + +/********************************************************************//** + * @~chinese + * @brief Stringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param strValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿstring͵ָڵֵ + + * @~english + * @brief Set String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param strValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified string nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetStringValue(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief Commandֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿָCommandͽڵ㡣 + + * @~english + * @brief Send Command + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Command nodes. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetCommandValue(IN void* handle,IN const char* strKey); + + + +/********************************************************************//** + * @~chinese + * @brief ڴ + * @param handle [IN] 豸 + * @param pBuffer [IN][OUT] ΪֵʹãڴֵGEV豸ڴֵǰմģʽ洢ģЭ豸С˴洢 + * @param nAddress [IN] ȡڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] ȡڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸ȡijμĴݡ + + * @~english + * @brief Read Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( Memory value is stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be read, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be read + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, read the data from certain register. +*************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ReadMemory(IN void* handle , IN OUT void *pBuffer, IN int64_t nAddress, IN int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief дڴ + * @param handle [IN] 豸 + * @param pBuffer [IN] дڴֵעGEV豸ڴֵҪմģʽ洢Э豸С˴洢 + * @param nAddress [IN] дڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] дڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸һдijμĴ + + * @~english + * @brief Write Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN] Memory value to be written ( Note the memory value to be stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be written, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be written + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, write a piece of data into a certain segment of register. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_WriteMemory(IN void* handle, IN const void *pBuffer, IN int64_t nAddress, IN int64_t nLength); + + + +/********************************************************************//** + * @~chinese + * @brief GenICamڵ㻺 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Invalidate GenICam Nodes + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_InvalidateNodes(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸XML + * @param handle [IN] 豸 + * @param pData [IN][OUT] XMLݽջ + * @param nDataSize [IN] ջС + * @param pnDataLen [IN][OUT] ʵݴС + * @return ɹMV_OK󣬷ش + * @remarks pDataΪNULLnDataSizeʵʵxmlļСʱݣpnDataLenxmlļС + pDataΪЧַһ㹻ʱݱڸû棬pnDataLenxmlļʵʴС + + * @~english + * @brief Get camera feature tree XML + * @param handle [IN] Device handle + * @param pData [IN][OUT] XML data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pnDataLen [IN][OUT] Actual data length + * @return Success, return MV_OK. Failure, return error code + * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, returned by pnDataLen XML file size. + When pData is a valid cache address and the cache is large enough, copy the full data into the cache, and pnDataLen returns the actual size of the XML file. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, IN OUT unsigned int* pnDataLen); + +/********************************************************************//** + * @~chinese + * @brief õǰڵķģʽ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penAccessMode [IN][OUT] ڵķģʽ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Get Access mode of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penAccessMode [IN][OUT] Access mode of the node + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeAccessMode(IN void* handle, IN const char * strName, IN OUT MV_XML_AccessMode *penAccessMode); + +/********************************************************************//** + * @~chinese + * @brief õǰڵ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penInterfaceType [IN][OUT] ڵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڿڵܽӿ֮ǰǰ֪ڵͣûѡʵܽӿڽнڵֵúͻȡ + + * @~english + * @brief Get Interface Type of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penInterfaceType [IN][OUT] Interface Type of the node + * @return Success, return MV_OK. Failure, return error code + * @remarks The interface can know the node type in advance before calling the universal interface, so as to facilitate users to select the appropriate universal interface for setting and obtaining the node value. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeInterfaceType(IN void* handle, IN const char * strName, IN OUT MV_XML_InterfaceType *penInterfaceType); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Save camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FeatureSave(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Load camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FeatureLoad(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸ȡļ + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Read the file from the camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessRead(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + + +/********************************************************************//** + * @~chinese + * @brief 豸ȡļ,ļData + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش ļȨʧ + + * @~english + * @brief Read the file data from the camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessReadEx(IN void* handle, IN OUT MV_CC_FILE_ACCESS_EX * pstFileAccessEx); + +/********************************************************************//** + * @~chinese + * @brief ļд豸 + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Write the file to camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessWrite(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + + +/********************************************************************//** + * @~chinese + * @brief (buffer)д豸 + * @param handle [IN] 豸 + * @param pstFileAccessEx [IN][OUT] ļȡṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֱʹûݣждֱӲļȨ޵,MV_CC_FileAccessWriteչӿ + + * @~english + * @brief Write the data(buffer) to camera + * @param handle [IN] Device handle + * @param pstFileAccessEx [IN][OUT] File access structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface uses cached data for read and write,solve the problem of no permissions in direct operation files, it's an extended interface of MV_CC_FileAccessWrite. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessWriteEx(IN void* handle, IN OUT MV_CC_FILE_ACCESS_EX * pstFileAccessEx); + + +/********************************************************************//** + * @~chinese + * @brief ȡļȡĽ + * @param handle [IN] 豸 + * @param pstFileAccessProgress [IN][OUT] + * @return ɹMV_OK󣬷ش ǰļȡ״̬ + + * @~english + * @brief Get File Access Progress + * @param handle [IN] Device handle + * @param pstFileAccessProgress [IN][OUT] File access Progress + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFileAccessProgress(IN void* handle, IN OUT MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress); + + +/*******************Part3 ch: | en: Camera upgrade *******************/ + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFilePathName [IN] ļ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԽ̼ļ͸豸 + ýӿҪȴ̼ļɹ豸֮ٷأӦʱܽϳ + + * @~english + * @brief Device Local Upgrade + * @param handle [IN] Device handle + * @param strFilePathName [IN] File name + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to send the upgrade firmware to the device for upgrade. + This API will wait for return until the upgrade firmware is sent to the device, this response may take a long time. + For CameraLink device, it keeps sending upgrade firmware continuously. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_LocalUpgrade(IN void* handle, IN const void* strFilePathName); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param pnProcess [IN][OUT] Ƚյַ + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Get Upgrade Progress + * @param handle [IN] Device handle + * @param pnProcess [IN][OUT] Progress receiving address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetUpgradeProcess(IN void* handle, IN OUT unsigned int* pnProcess); + + +/*******************Part4 ch: ע쳣ص¼ӿ | en: Enrol abnormal callbacks and event interface*******************/ + +/********************************************************************//** + * @~chinese + * @brief ע쳣Ϣصڴ豸֮ + * @param handle [IN] 豸 + * @param cbException [IN] 쳣صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿҪMV_CC_OpenDevice豸֮á + 豸쳣ϿӺڻصȡ쳣ϢGigE豸֮ҪȵMV_CC_CloseDeviceӿڹر豸ٵMV_CC_OpenDeviceӿ´豸 + + * @~english + * @brief Register Exception Message CallBack, call after open device + * @param handle [IN] Device handle + * @param cbException [IN] Exception Message CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. + When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, + first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterExceptionCallBack(IN void* handle, IN void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), IN void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עȫ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on + This API is not supported by CameraLink device. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterAllEventCallBack(IN void* handle, IN void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), IN void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עᵥ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param strEventName [IN] ¼ + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register single event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param strEventName [IN] Event name + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. + This API is not supported by CameraLink device . +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBackEx(IN void* handle, IN const char* strEventName, IN void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), IN void* pUser); + + +/*******************Part5 ch: GigE豸ֵ֧Ľӿ | en: Only support GigE interface*******************/ + +/********************************************************************//** + * @~chinese + * @brief öٳʱʱ䣬֧GigEЭ飬Χ 1 - UINT_MAX1UINT_MAX + * @param nMilTimeout [IN] ʱʱ䣬Ĭ100ms + * @return ɹMV_OK󣬷ش + * @remarks ڵMV_CC_EnumDevicesöٽӿǰʹøýӿڣöGIGE豸ʱʱ䣨Ĭ100ms,Լʱʱ䣬ӿöGIGE豸ٶ + * @remarks ýӿڽ֧޷ + + * @~english + * @brief Set enumerate device timeout,only support GigE,range 1 - UINT_MAX,(the minimum value is greater than or equal to 1,maximum value less than UINT_MAX) + * @param nMilTimeout [IN] time out,default 100ms + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling enum device interfaces,call MV_GIGE_SetEnumDevTimeout to set max timeout,can reduce the maximum timeout to speed up the enumeration of GigE devices. + * @remarks This API only support input of unsigned int. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetEnumDevTimeout(IN unsigned int nMilTimeout); + +/********************************************************************//** + * @~chinese + * @brief ǿIP + * @param handle [IN] 豸 + * @param nIP [IN] õIP + * @param nSubNetMask [IN] + * @param nDefaultGateWay [IN] Ĭ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ǿ豸IP롢Ĭأǿ֮Ҫ´豸GigEVision豸֧ + 豸ΪDHCP״̬øýӿǿ豸֮豸 + + * @~english + * @brief Force IP + * @param handle [IN] Device handle + * @param nIP [IN] IP to set + * @param nSubNetMask [IN] Subnet mask + * @param nDefaultGateWay [IN] Default gateway + * @return Success, return MV_OK. Failure, return error code + * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After forced setting, device handle should be created again. + This function is only supported by GigEVision camera. + If device is in DHCP status, after calling this API to force setting camera network parameter, the device will restart. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIpEx(IN void* handle, IN unsigned int nIP, IN unsigned int nSubNetMask, IN unsigned int nDefaultGateWay); + +/********************************************************************//** + * @~chinese + * @brief IPʽ + * @param handle [IN] 豸 + * @param nType [IN] IPͣMV_IP_CFG_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸IPʽDHCPLLAȣGigEVision豸֧֡ + + * @~english + * @brief IP configuration method + * @param handle [IN] Device handle + * @param nType [IN] IP type, refer to MV_IP_CFG_x + * @return Success, return MV_OK. Failure, return error code + * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetIpConfig(IN void* handle, IN unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ýʹijģʽ,type: MV_NET_TRANS_xʱĬʹdriver + * @param handle [IN] 豸 + * @param nType [IN] 紫ģʽMV_NET_TRANS_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿSDKڲʹõģʽĬʹģʽGigEVision豸֧֡ + + * @~english + * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default + * @param handle [IN] Device handle + * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x + * @return Success, return MV_OK. Failure, return error code + * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by GigEVision camera. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetNetTransMode(IN void* handle, IN unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ȡ紫Ϣ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] Ϣṹ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԻȡ紫ϢѽݴС֡ȣMV_CC_StartGrabbingɼ֮áGigEVision豸֧֡ + + * @~english + * @brief Get net transmission information + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Get network transmission information through this API, including received data size, number of lost frames. + Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by GigEVision Camera. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetNetTransInfo(IN void* handle, IN OUT MV_NETTRANS_INFO* pstInfo); + +/********************************************************************//** + * @~chinese + * @brief öĻظ + * @param nMode [IN] ظͣĬϹ㲥0-1-㲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻGigEЧ + + * @~english + * @brief Setting the ACK mode of devices Discovery. + * @param nMode [IN] ACK modeDefault-Broadcast,0-Unicast,1-Broadcast. + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is ONLY effective on GigE cameras. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetDiscoveryMode(IN unsigned int nMode); + +/********************************************************************//** + * @~chinese + * @brief GVSPȡʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ300msΧ>10ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮ȡǰøýӿڿGVSPȡʱʱ䡣GVSPȡʱù̿ͼ쳣ùȡʱ䳤 + + * @~english + * @brief Set GVSP streaming timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 300ms, range: >10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, and just before start streaming, + * call this interface to set GVSP streaming timeout value. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvspTimeout(IN void* handle, IN unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVSPȡʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [IN][OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVSPȡʱʱ + + * @~english + * @brief Get GVSP streaming timeout + * @param handle [IN] Device handle + * @param pnMillisec [IN][OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVSP streaming timeout. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvspTimeout(IN void* handle, IN OUT unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief GVCPʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ500msΧ0-10000ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿGVCPʱʱ䡣 + + * @~english + * @brief Set GVCP cammand timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 500ms, range: 0-10000ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set GVCP command timeout time. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvcpTimeout(IN void* handle, IN unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVCPʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [IN][OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPʱʱ䡣 + + * @~english + * @brief Get GVCP cammand timeout + * @param handle [IN] Device handle + * @param pnMillisec [IN][OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVCP timeout. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvcpTimeout(IN void* handle, IN OUT unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief شGVCP + * @param handle [IN] 豸 + * @param nRetryGvcpTimes [IN] شΧ0-100 + * @return ɹMV_OK󣬷ش + * @remarks ýӿGVCP쳣ʱشĴһ̶ϿԱ豸ߣΧΪ0-100 + + * @~english + * @brief Set the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param nRetryGvcpTimes [IN] The number of retriesrang0-100 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to increase The Times of retransmission when GVCP packet transmission is abnormal,and to some extent, + it can avoid dropping the camera, with a range of 0-100. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetRetryGvcpTimes(IN void* handle, IN unsigned int nRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشGVCP + * @param handle [IN] 豸 + * @param pnRetryGvcpTimes [IN][OUT] شָ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPشĬ3Ρ + + * @~english + * @brief Get the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param pnRetryGvcpTimes [IN][OUT] The number of retries + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of GVCP retransmissions, which defaults to 3. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetRetryGvcpTimes(IN void* handle, IN OUT unsigned int* pnRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡѵpacket sizeýӿĿǰֻ֧GigE豸 + * @param handle [IN] 豸 + * @return packetsize + * @remarks ȡѵpacket sizeӦGigEVision豸SCPS + ýӿҪMV_CC_OpenDevice֮MV_CC_StartGrabbing֮ǰá + ýӿڲ֧CameraLink豸U3V豸 + ýӿڲ֧GenTL豸Э鲻֧֣,GenTLʽӵʵGevSCPSPacketSize1500 + + * @~english + * @brief Get the optimal Packet Size, Only support GigE Camera + * @param handle [IN] Device handle + * @return Optimal packetsize + * @remarks To get optimized packet size, for GigEVision device is SCPS + and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. + This API is not supported by CameraLink device and U3V device. + This interface does not support GenTL devices (protocol not supported). If a network camera is added in GenTL mode, it is recommended to configure GevSCPSPacketSize according to the actual network situation,or 1500. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOptimalPacketSize(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief Ƿط֧֣ط + * @param handle [IN] 豸 + * @param bEnable [IN] Ƿ֧ط + * @param nMaxResendPercent [IN] ط + * @param nResendTimeout [IN] طʱʱ + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿطԣGigEVision豸֧֡ + + * @~english + * @brief Set whethe to enable resend, and set resend + * @param handle [IN] Device handle + * @param bEnable [IN] enable resend + * @param nMaxResendPercent [IN] Max resend persent + * @param nResendTimeout [IN] Resend timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera. + ************************************************************************/ #ifndef __cplusplus - MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend( - void *handle, unsigned int bEnable, unsigned int nMaxResendPercent, unsigned int nResendTimeout - ); +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(IN void* handle, IN unsigned int bEnable, IN unsigned int nMaxResendPercent, IN unsigned int nResendTimeout); #else -MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend( - void *handle, unsigned int bEnable, unsigned int nMaxResendPercent = 10, unsigned int nResendTimeout = 50 -); +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(IN void* handle, IN unsigned int bEnable, IN unsigned int nMaxResendPercent = 10, IN unsigned int nResendTimeout = 50); #endif - /********************************************************************/ /** - * @~chinese - * @brief 设置重传命令最大尝试次数 - * @param handle [IN] 设备句柄 - * @param nRetryTimes [IN] 重传命令最大尝试次数,默认20 - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 该接口必须在MV_CC_StartGrabbing之前调用,否则返回错误码MV_E_CALLORDER。 - - * @~english - * @brief set the max resend retry times - * @param handle [IN] Device handle - * @param nRetryTimes [IN] the max times to retry resending lost packets,default 20 - * @return Success, return MV_OK. Failure, return error code - * @remarks This interface must be called before MV_CC_StartGrabbing. Otherwise return MV_E_CALLORDER. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendMaxRetryTimes(void *handle, unsigned int nRetryTimes); - - /********************************************************************/ /** - * @~chinese - * @brief 获取重传命令最大尝试次数 - * @param handle [IN] 设备句柄 - * @param pnRetryTimes [IN] 重传命令最大尝试次数 - * @return 成功,返回MV_OK;错误,返回错误码 - - * @~english - * @brief get the max resend retry times - * @param handle [IN] Device handle - * @param pnRetryTimes [OUT] the max times to retry resending lost packets - * @return Success, return MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendMaxRetryTimes(void *handle, unsigned int *pnRetryTimes); - - /********************************************************************/ /** - * @~chinese - * @brief 设置同一重传包多次请求之间的时间间隔 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 同一重传包多次请求之间的时间间隔,默认10ms - * @return 成功,返回MV_OK;错误,返回错误码 - * @remarks 该接口必须在MV_CC_StartGrabbing之前调用,否则返回错误码MV_E_CALLORDER。 - - * @~english - * @brief set time interval between same resend requests - * @param handle [IN] Device handle - * @param nMillisec [OUT] the time interval between same resend requests, default - 10ms - * @return Success, return MV_OK. Failure, return error code - * @remarks This interface must be called before MV_CC_StartGrabbing. Otherwise return MV_E_CALLORDER. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendTimeInterval(void *handle, unsigned int nMillisec); - - /********************************************************************/ /** - * @~chinese - * @brief 获取同一重传包多次请求之间的时间间隔 - * @param handle [IN] 设备句柄 - * @param pnMillisec [IN] 同一重传包多次请求之间的时间间隔 - * @return 成功,返回MV_OK;错误,返回错误码 - - * @~english - * @brief get time interval between same resend requests - * @param handle [IN] Device handle - * @param pnMillisec [OUT] the time interval between same resend requests - * @return Success, return MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendTimeInterval(void *handle, unsigned int *pnMillisec); - - /********************************************************************/ /** - * @~chinese - * @brief 设置传输模式,可以为单播模式、组播模式等 - * @param handle [IN] 设备句柄 - * @param pstTransmissionType [IN] 传输模式结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 通过该接口可以设置传输模式为单播、组播等模式,仅GigEVision相机支持。 - - * @~english - * @brief Set transmission type,Unicast or Multicast - * @param handle [IN] Device handle - * @param pstTransmissionType [IN] Struct of transmission type - * @return Success, return #MV_OK. Failure, return error code - * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is - only valid for GigEVision camera. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetTransmissionType(void *handle, MV_TRANSMISSION_TYPE *pstTransmissionType); - - /********************************************************************/ /** - * @~chinese - * @brief 发出动作命令 - * @param pstActionCmdInfo [IN] 动作命令信息 - * @param pstActionCmdResults [OUT] 动作命令返回信息列表 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 仅GigEVision相机支持。 - - * @~english - * @brief Issue Action Command - * @param pstActionCmdInfo [IN] Action Command - * @param pstActionCmdResults [OUT] Action Command Result List - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by GigEVision camera. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_IssueActionCommand( - IN MV_ACTION_CMD_INFO *pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST *pstActionCmdResults - ); - - /************************************************************************/ - /* XML解析树的生成 */ - /* XML parse tree generation */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 获取相机属性树XML - * @param handle [IN] 设备句柄 - * @param pData [OUT] XML数据接收缓存 - * @param nDataSize [IN] 接收缓存大小 - * @param pnDataLen [OUT] 实际数据大小 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks 当pData为NULL或nDataSize比实际的xml文件小时,不拷贝数据,由pnDataLen返回xml文件大小;\n - 当pData为有效缓存地址,且缓存足够大时,拷贝完整数据保存在该缓存里面,并由pnDataLen返回xml文件实际大小。 - - * @~english - * @brief Get camera feature tree XML - * @param handle [IN] Device handle - * @param pData [OUT] XML data receiving buffer - * @param nDataSize [IN] Buffer size - * @param pnDataLen [OUT] Actual data length - * @return Success, return #MV_OK. Failure, return error code - * @remarks * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, - returned by pnDataLen XML file size.\n When pData is a valid cache address and the cache is large enough, copy the - full data into the cache, and pnDataLen returns the actual size of the XML file. - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_XML_GetGenICamXML( - IN void *handle, IN OUT unsigned char *pData, IN unsigned int nDataSize, OUT unsigned int *pnDataLen - ); - - /************************************************************************/ - /* 附加接口 */ - /* Additional interface */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 保存图片,支持Bmp和Jpeg.编码质量在50-99之前 - * @param handle [IN] 设备句柄 - * @param pSaveParam [IN][OUT] 保存图片参数结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 通过将接口可以将从设备采集到的原始图像数据转换成JPEG或者BMP等格式并存放在指定内存中,然后用户可以将转换之后的数据直接保存成图片文件。该接口调用无接口顺序要求,有图像源数据就可以进行转换,可以先调用MV_CC_GetOneFrameTimeout或者MV_CC_RegisterImageCallBackEx设置回调函数,获取一帧图像数据,然后再通过该接口转换格式。 - \n MV_CC_SaveImageEx2比MV_CC_SaveImageEx增加参数handle,为了保证与其他接口的统一。\n - 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Save image, support Bmp and Jpeg. Encoding quality(50-99] - * @param handle [IN] Device handle - * @param pSaveParam [IN][OUT] Save image parameters structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks Once there is image data, you can call this API to convert the data. \n - You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to - get one image frame and set the callback function, and then call this API to convert the format. \n Comparing with - the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. - - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx2(IN void *handle, MV_SAVE_IMAGE_PARAM_EX *pSaveParam); - - /********************************************************************/ /** - * @~chinese - * @brief 像素格式转换 - * @param handle [IN] 设备句柄 - * @param pstCvtParam [IN][OUT] 像素格式转换参数结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 通过将接口可以将从设备采集到的原始图像数据转换成用户所需的像素格式并存放在指定内存中。该接口调用无接口顺序要求,有图像源数据就可以进行转换,可以先调用MV_CC_GetOneFrameTimeout或者MV_CC_RegisterImageCallBack设置回调函数,获取一帧图像数据,然后再通过该接口转换格式。如果相机当前采集图像是JPEG压缩的格式,则不支持调用该接口进行显示。 - \n 该接口仅在windows版本和Linux版本下支持。 - - * @~english - * @brief Pixel format conversion - * @param handle [IN] Device handle - * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is used to transform the collected original data to pixel format and save to specified - memory. There is no order requirement to call this API, the transformation will execute when there is image data. - First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of - image data, then call this API to transform the format. \n - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_ConvertPixelType(IN void *handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM *pstCvtParam); - - /********************************************************************/ /** - * @~chinese - * @brief 插值算法类型设置 - * @param handle [IN] 设备句柄 - * @param BayerCvtQuality [IN] Bayer的插值方法 0-最近邻 1-双线性 2-Hamilton - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - 设置内部图像转换接口的贝尔插值质量参数,MV_CC_ConvertPixelType、MV_CC_SaveImageEx2接口内部使用的插值算法是该接口所设定的。 - - * @~english - * @brief Interpolation algorithm type setting - * @param handle [IN] Device handle - * @param BayerCvtQuality [IN] Bayer interpolation method 0-nearest neighbour - 1-bilinearity 2-Hamilton - * @return Success, return #MV_OK. Failure, return error code - * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, and the - interpolation algorithm used in the MV CC ConvertPixelType and MV CC SaveImageEx2 interfaces is set by this - interface. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCvtQuality(IN void *handle, IN unsigned int BayerCvtQuality); - - /********************************************************************/ /** - * @~chinese - * @brief 保存相机属性 - * @param handle [IN] 设备句柄 - * @param pFileName [IN] 属性文件名 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Save camera feature - * @param handle [IN] Device handle - * @param pFileName [IN] File name - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_FeatureSave(IN void *handle, IN const char *pFileName); - - /********************************************************************/ /** - * @~chinese - * @brief 导入相机属性 - * @param handle [IN] 设备句柄 - * @param pFileName [IN] 属性文件名 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Load camera feature - * @param handle [IN] Device handle - * @param pFileName [IN] File name - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_FeatureLoad(IN void *handle, IN const char *pFileName); - - /********************************************************************/ /** - * @~chinese - * @brief 从相机读取文件 - * @param handle [IN] 设备句柄 - * @param pstFileAccess [IN] 文件存取结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Read the file from the camera - * @param handle [IN] Device handle - * @param pstFileAccess [IN] File access structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_FileAccessRead(IN void *handle, IN MV_CC_FILE_ACCESS *pstFileAccess); - - /********************************************************************/ /** - * @~chinese - * @brief 将文件写入相机 - * @param handle [IN] 设备句柄 - * @param pstFileAccess [IN] 文件存取结构体 - * @return 成功,返回#MV_OK ;错误,返回错误码 - - * @~english - * @brief Write the file to camera - * @param handle [IN] Device handle - * @param pstFileAccess [IN] File access structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_FileAccessWrite(IN void *handle, IN MV_CC_FILE_ACCESS *pstFileAccess); - - /********************************************************************/ /** - * @~chinese - * @brief 获取文件存取的进度 - * @param handle [IN] 设备句柄 - * @param pstFileAccessProgress [IN] 进度内容 - * @return 成功,返回#MV_OK ;错误,返回错误码 (当前文件存取的状态) - - * @~english - * @brief Get File Access Progress - * @param handle [IN] Device handle - * @param pstFileAccessProgress [IN] File access Progress - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetFileAccessProgress( - IN void *handle, OUT MV_CC_FILE_ACCESS_PROGRESS *pstFileAccessProgress - ); - - /********************************************************************/ /** - * @~chinese - * @brief 开始录像 - * @param handle [IN] 设备句柄 - * @param pstRecordParam [IN] 录像参数结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Start Record - * @param handle [IN] Device handle - * @param pstRecordParam [IN] Record param structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_StartRecord(IN void *handle, IN MV_CC_RECORD_PARAM *pstRecordParam); - - /********************************************************************/ /** - * @~chinese - * @brief 输入录像数据 - * @param handle [IN] 设备句柄 - * @param pstInputFrameInfo [IN] 录像数据结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - - * @~english - * @brief Input RAW data to Record - * @param handle [IN] Device handle - * @param pstInputFrameInfo [IN] Record data structure - * @return Success, return #MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_InputOneFrame(IN void *handle, IN MV_CC_INPUT_FRAME_INFO *pstInputFrameInfo); - - /********************************************************************/ /** - * @~chinese - * @brief 停止录像 - * @param handle [IN] 设备句柄 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Stop Record - * @param handle [IN] Device handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_StopRecord(IN void *handle); - - /************************************************************************/ - /* 不建议使用的接口 */ - /* Interfaces not recommended */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 获取图像基本信息 - * @param handle [IN] 相机句柄 - * @param pstInfo [IN][OUT] 返回给调用者有关相机图像基本信息结构体指针 - * @return 成功,返回 #MV_OK ,失败,返回错误码 - * @remarks 参考 CameraParams.h 中的 #MV_IMAGE_BASIC_INFO 定义 - - * @~english - * @brief Get basic information of image - * @param handle [IN] Handle - * @param pstInfo [IN][OUT] Structure pointer of image basic information - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to the definition of #MV_IMAGE_BASIC_INFO in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetImageInfo(IN void *handle, IN OUT MV_IMAGE_BASIC_INFO *pstInfo); - - /********************************************************************/ /** - * @~chinese - * @brief 获取GenICam代理 - * @param handle [IN] 句柄地址 - * @return GenICam代理类指针 ,正常返回值非NULL;异常返回NULL - - * @~english - * @brief Get GenICam proxy - * @param handle [IN] Handle address - * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL - ************************************************************************/ - MV_CAMCTRL_API void *__stdcall MV_CC_GetTlProxy(IN void *handle); - - /********************************************************************/ /** - * @~chinese - * @brief 获取根节点 - * @param handle [IN] 句柄 - * @param pstNode [OUT] 根节点信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get root node - * @param handle [IN] Handle - * @param pstNode [OUT] Root node information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_XML_GetRootNode(IN void *handle, IN OUT MV_XML_NODE_FEATURE *pstNode); - - /********************************************************************/ /** - * @~chinese - * @brief 从xml中获取指定节点的所有子节点,根节点为Root - * @param handle [IN] 句柄 - * @param pstNode [IN] 根节点信息结构体 - * @param pstNodesList [OUT] 节点列表结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get all children node of specific node from xml, root node is Root - * @param handle [IN] Handle - * @param pstNode [IN] Root node information structure - * @param pstNodesList [OUT] Node information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_XML_GetChildren( - IN void *handle, IN MV_XML_NODE_FEATURE *pstNode, IN OUT MV_XML_NODES_LIST *pstNodesList - ); - - /********************************************************************/ /** - * @~chinese - * @brief 获得当前节点的属性 - * @param handle [IN] 句柄 - * @param pstNode [IN] 根节点信息结构体 - * @param pstFeature [OUT] 当前节点属性结构体, - pstFeature 具体结构体内容参考 MV_XML_FEATURE_x - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get current node feature - * @param handle [IN] Handle - * @param pstNode [IN] Root node information structure - * @param pstFeature [OUT] Current node feature structure - Details of pstFeature refer to MV_XML_FEATURE_x - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_XML_GetNodeFeature( - IN void *handle, IN MV_XML_NODE_FEATURE *pstNode, IN OUT void *pstFeature - ); - - /********************************************************************/ /** - * @~chinese - * @brief 更新节点 - * @param handle [IN] 句柄 - * @param enType [IN] 节点类型 - * @param pstFeature [OUT] 当前节点属性结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Update node - * @param handle [IN] Handle - * @param enType [IN] Node type - * @param pstFeature [OUT] Current node feature structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_XML_UpdateNodeFeature( - IN void *handle, IN enum MV_XML_InterfaceType enType, IN void *pstFeature - ); - - // 有节点需要更新时的回调函数 - // 当调用MV_XML_UpdateNodeFeature接口更新节点属性时,注册的回调函数cbUpdate会在pstNodesList中返回与之相关联的节点 - /********************************************************************/ /** - * @~chinese - * @fn MV_XML_RegisterUpdateCallBack - * @brief 注册更新回调 - * @param handle [IN] 句柄 - * @param cbUpdate [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Register update callback - * @param handle [IN] Handle - * @param cbUpdate [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_XML_RegisterUpdateCallBack( - IN void *handle, - IN void(__stdcall *cbUpdate)( - enum MV_XML_InterfaceType enType, void *pstFeature, MV_XML_NODES_LIST *pstNodesList, void *pUser - ), - IN void *pUser - ); - - /************************************************************************/ - /* 弃用的接口 */ - /* Abandoned interface */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 获取一帧图像,此函数为查询式获取,每次调用查询内部缓存有 - 无数据,有数据则范围数据,无数据返回错误码 - (该接口已弃用,建议改用 MV_CC_GetOneFrameTimeOut接口) - * @param handle [IN] 句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get one frame data, this function is using query to get data, - query whether the internal cache has data, return data if there has, return error code if no data - (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) - * @param handle [IN] Handle - * @param pData [OUT] Recevied image data pointer - * @param nDataSize [IN] Recevied buffer size - * @param pFrameInfo [OUT] Image information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrame( - IN void *handle, IN OUT unsigned char *pData, IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO *pFrameInfo - ); - - /********************************************************************/ /** - * @~chinese - * @brief 获取一帧trunck数据,此函数为查询式获取,每次调用查询内部 - 缓存有无数据,有数据则范围数据,无数据返回错误码 - (该接口已弃用,建议改用 MV_CC_GetOneFrameTimeOut接口) - * @param handle [IN] 句柄 - * @param pData [OUT] 图像数据接收指针 - * @param nDataSize [IN] 接收缓存大小 - * @param pFrameInfo [OUT] 图像信息结构体 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Get one frame of trunck data, this function is using query to get data, - query whether the internal cache has data, return data if there has, return error code if no data - (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) - * @param handle [IN] Handle - * @param pData [OUT] Recevied image data pointer - * @param nDataSize [IN] Recevied buffer size - * @param pFrameInfo [OUT] Image information structure - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameEx( - IN void *handle, IN OUT unsigned char *pData, IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX *pFrameInfo - ); - - /********************************************************************/ /** - * @~chinese - * @brief 注册图像数据回调(该接口已弃用,建议改用 MV_CC_RegisterImageCallBackEx接口) - * @param handle [IN] 句柄 - * @param cbOutput [IN] 回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Register image data callback (This interface is abandoned, it is recommended to use the - MV_CC_RegisterImageCallBackEx) - * @param handle [IN] Handle - * @param cbOutput [IN] Callback function pointer - * @param pUser [IN] User defined variable - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ***********************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBack( - void *handle, - void(__stdcall *cbOutput)(unsigned char *pData, MV_FRAME_OUT_INFO *pFrameInfo, void *pUser), - void *pUser - ); - - /********************************************************************/ /** - * @~chinese - * @brief 保存图片(该接口已弃用,建议改用 MV_CC_SaveImageEx2接口) - * @param pSaveParam [IN][OUT] 保存图片参数结构体 - - pData; // [IN] 输入数据缓存 - - nDataLen; // [IN] 输入数据大小 - - enPixelType; // [IN] 输入数据的像素格式 - - nWidth; // [IN] 图像宽 - - nHeight; // [IN] 图像高 - - pImageBuffer; // [OUT] 输出图片缓存 - - nImageLen; // [OUT] 输出图片大小 - - nBufferSize; // [IN] 提供的输出缓冲区大小 - - enImageType; // [IN] 输出图片格式 - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Save image (This interface is abandoned, it is recommended to use the MV_CC_SaveImageEx2) - * @param pSaveParam [IN][OUT] Save image parameters structure - - pData; // [IN] Input data buffer - - nDataLen; // [IN] Input data size - - enPixelType; // [IN] Input data pixel format - - nWidth; // [IN] Width - - nHeight; // [IN] Height - - pImageBuffer; // [OUT] Output image buffer - - nImageLen; // [OUT] Output image size - - nBufferSize; // [IN] Provided output buffer size - - enImageType; // [IN] Output image type - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM *pSaveParam); - - /********************************************************************/ /** - * @~chinese - * @brief 保存图片,支持Bmp和Jpeg.编码质量在50-99之前 (该接口已弃用,建议改用 MV_CC_SaveImageEx2接口) - * @param pSaveParam [IN][OUT] 保存图片参数结构体 - pData; // [IN] 输入数据缓存 - nDataLen; // [IN] 输入数据大小 - enPixelType; // [IN] 输入数据的像素格式 - nWidth; // [IN] 图像宽 - nHeight; // [IN] 图像高 - pImageBuffer; // [OUT] 输出图片缓存 - nImageLen; // [OUT] 输出图片大小 - nBufferSize; // [IN] 提供的输出缓冲区大小 - enImageType; // [IN] 输出图片格式 - nJpgQuality; // [IN] 编码质量, (50-99] - nReserved[4]; - * @return 成功,返回#MV_OK;错误,返回错误码 - * @remarks - - * @~english - * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] - * @param pSaveParam [IN][OUT] Save image parameters structure - pData; // [IN] Input data buffer - nDataLen; // [IN] Input data size - enPixelType; // [IN] Pixel format of input data - nWidth; // [IN] Image width - nHeight; // [IN] Image height - pImageBuffer; // [OUT] Output image buffer - nImageLen; // [OUT] Output image size - nBufferSize; // [IN] Output buffer size provided - enImageType; // [IN] Output image format - nJpgQuality; // [IN] Encoding quality, (50-99] - nReserved[4]; - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX *pSaveParam); - - /********************************************************************/ /** - * @~chinese - * @brief 强制IP(该接口已弃用,建议改用 MV_GIGE_ForceIpEx接口) - * @param handle [IN] 设备句柄 - * @param nIP [IN] 设置的IP - * @return 见返回错误码 - * @remarks - - * @~english - * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) - * @param handle [IN] Handle - * @param nIP [IN] IP to set - * @return Refer to error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIp(IN void *handle, unsigned int nIP); - - /********************************************************************/ /** - * @~chinese - * @brief 注册事件回调(该接口已弃用,建议改用 MV_CC_RegisterEventCallBackEx接口) - * @param handle [IN] 设备句柄 - * @param cbEvent [IN] 事件回调函数指针 - * @param pUser [IN] 用户自定义变量 - * @return 见返回错误码 - * @remarks - - * @~english - * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the - MV_CC_RegisterEventCallBackEx interface) - * @param handle [IN] Handle - * @param cbEvent [IN] event callback pointer - * @param pUser [IN] User defined value - * @return Refer to error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBack( - void *handle, void(__stdcall *cbEvent)(unsigned int nExternalEventId, void *pUser), void *pUser - ); - - /************************************************************************/ - /* 相机参数获取和设置,此模块的所有接口,将逐步废弃,建议用万能接口代替 */ - /* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 获取图像宽度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机宽度的信息结构体指针 - * 返回的pstValue结构体的意义 - * - unsigned int nCurValue; // 代表相机当前的宽度值 - * - unsigned int nMax; // 表示相机允许的最大可设置的宽度值 - * - unsigned int nMin; // 表示相机允许的最小可设置的宽度值 - * - unsigned int nInc; // 表示相机设置的宽度增量必须是nInc的倍数,否则无效 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他整型结构体参数的接口可参照此接口 - - * @~english - * @brief Get image width - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Returns the information structure pointer about the camera's - width for the caller - * The meaning of returns pstValue structure - * - unsigned int nCurValue; // Represents the current width value of the camera - * - unsigned int nMax; // Indicates the maximum settable width value allowed by the - camera - * - unsigned int nMin; // Indicates the minimum settable width value allowed by the - camera - * - unsigned int nInc; // Indicates that the width increment set by the camera must - be a multiple of nInc, otherwise it is invalid - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Other Integer structure parameters interface can refer to this interface - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置图像宽度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] - 想要设置的相机宽度的值,注意此宽度值必须是MV_CC_GetWidth接口返回的pstValue中的nInc的倍数才能设置成功 - * @return 成功,返回#MV_OK,并且相机宽度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image width - * @param handle [IN] Camera Handle - * @param nValue [IN] To set the value of the camera width, note that the width value - must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface - * @return Success, return #MV_OK, and the camera width will change to the corresponding value. Failure, return - error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取图像高度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机高度的信息结构体指针 - * @return 成功,返回#MV_OK,并将高度信息返回到结构体中,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get image height - * @param handle [IN] Camera handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera - height to user - * @return Success, return #MV_OK, and return height information to the structure. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置图像高度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] - 想要设置的相机宽度的值,注意此宽度值必须是MV_CC_GetWidth接口返回的pstValue中的nInc的倍数才能设置成功 - * @return 成功,返回#MV_OK,并且相机高度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image height - * @param handle [IN] Camera Handle - * @param nValue [IN] Camera height value to set, note that this value must be times - of nInc of pstValue returned by MV_CC_GetWidth - * @return Success, return #MV_OK, and the camera height will change to the corresponding value. Failure, return - error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取图像X偏移 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机X偏移的信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get image X offset - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera X offset - to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置图像AOI偏移 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的相机AOI的值 - * @return 成功,返回#MV_OK,并且相机AOI偏移将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image X offset - * @param handle [IN] Camera Handle - * @param nValue [IN] Camera X offset value to set - * @return Success, return #MV_OK, and the camera X offset will change to the corresponding value. Failure, return - error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取图像Y偏移 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机Y偏移的信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get image Y offset - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera Y offset - to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置图像AOI偏移 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的相机AOI的值 - * @return 成功,返回#MV_OK,并且相机AOI偏移将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set image Y offset - * @param handle [IN] Camera Handle - * @param nValue [IN] Camera Y offset value to set - * @return Success, return #MV_OK, and the camera Y offset will change to the corresponding value. Failure, return - error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取曝光下限 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机曝光值下限结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get exposure lower limit - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera exposure - lower to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置曝光值下限 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的曝光值下限 - * @return 成功,返回#MV_OK,并且相机曝光下限将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set exposure lower limit - * @param handle [IN] Camera Handle - * @param nValue [IN] Exposure lower to set - * @return Success, return #MV_OK, and the camera exposure time lower limit value will change to the corresponding - value. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取曝光上限 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机曝光值上限结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get exposure upper limit - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera exposure - upper to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置曝光值上限 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的曝光值上限 - * @return 成功,返回#MV_OK,并且相机曝光上限将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set exposure upper limit - * @param handle [IN] Camera Handle - * @param nValue [IN] Exposure upper to set - * @return Success, return #MV_OK, and the camera exposure time upper limit value will change to the corresponding - value. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取亮度值 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机亮度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口#MV_CC_GetWidth - - * @~english - * @brief Get brightness - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera - brightness to user - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to #MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置亮度值 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的亮度值 - * @return 成功,返回#MV_OK,并且相机亮度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set brightness - * @param handle [IN] Camera Handle - * @param nValue [IN] Brightness upper to set - * @return Success, return #MV_OK, and the camera brightness value will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取帧率 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机帧率的信息结构体指针 - * 返回的pstValue结构体的意义 - * - float fCurValue; // 表示相机当前的帧率 - * - float fMax; // 表示相机允许设置的最大帧率 - * - float fMin; // 表示相机允许设置的最小帧率 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他浮点型结构体参数的接口可参照此接口 - - * @~english - * @brief Get Frame Rate - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to camera frame - rate to user - * The meaning of returns pstValue structure - * - float fCurValue; // Indicates the current frame rate of the - camera - * - float fMax; // Indicates the maximum frame rate - allowed by the camera - * - float fMin; // Indicates the minimum frame rate - allowed by the camera - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Other interface of Float structure parameters can refer to this interface - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void *handle, IN OUT MVCC_FLOATVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置帧率 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机帧率 - * @return 成功,返回#MV_OK,并且相机帧率将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set frame rate - * @param handle [IN] Camera Handle - * @param fValue [IN] Camera frame rate to set - * @return Success, return #MV_OK, and camera frame rate will be changed to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void *handle, IN const float fValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取增益 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机增益的信息结构体指针 - * 返回的pstValue结构体的意义 - * - float fCurValue; // 表示相机当前的帧率 - * - float fMax; // 表示相机允许设置的最大帧率 - * - float fMin; // 表示相机允许设置的最小帧率 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他浮点型结构体参数的接口可参照此接口 - - * @~english - * @brief Get Gain - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to gain to user - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * - float fCurValue; // Camera current gain - * - float fMax; // The maximum gain camera allowed - * - float fMin; // The minimum gain camera allowed - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Other interface of Float structure parameters can refer to this interface - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void *handle, IN OUT MVCC_FLOATVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置帧率 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机帧率 - * @return 成功,返回#MV_OK,并且相机帧率将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Gain - * @param handle [IN] Camera Handle - * @param fValue [IN] Gain value to set - * @return Success, return #MV_OK, and the camera gain value will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void *handle, IN const float fValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取曝光时间 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机曝光时间的信息结构体指针 - * 返回的pstValue结构体的意义 - * - float fCurValue; // 表示相机当前的帧率 - * - float fMax; // 表示相机允许设置的最大帧率 - * - float fMin; // 表示相机允许设置的最小帧率 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他浮点型结构体参数的接口可参照此接口 - - * @~english - * @brief Get exposure time - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Return pointer of information structure related to exposure - time to user - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * - float fCurValue; // Camera current exposure time - * - float fMax; // The maximum exposure time camera - allowed - * - float fMin; // The minimum exposure time camera - allowed - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Other interface of Float structure parameters can refer to this interface - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void *handle, IN OUT MVCC_FLOATVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置曝光时间 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机帧率 - * @return 成功,返回#MV_OK,并且相机帧率将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set exposure time - * @param handle [IN] Camera Handle - * @param fValue [IN] Exposure time to set - * @return Success, return #MV_OK, and the camera exposure time value will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void *handle, IN const float fValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取像素格式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关像素格式的信息结构体指针 \n - * 返回的pstValue结构体的意义 - * - unsigned int nCurValue; // - 相机当前的像素格式,是枚举类型,比如说PixelType_Gvsp_Mono8, - 这里获得的是其整型值,具体数值参照PixelType.h的MvGvspPixelType枚举类型 - * - unsigned int nSupportedNum; // 相机支持的像素格式的个数 - * - unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // - 相机所有支持的像素格式对应的整型值列表,后面要设置像素格式时,参数必须是这个数组中的一种,否则无效 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 其他枚举类型参数接口可参照此接口,有关相应参数的枚举类型对应的整型值请查找PixelType.h 和 - CameraParams.h中相应的定义 - - * @~english - * @brief Get Pixel Format - * @param handle [IN] Camera Handle - * @param pstValue [IN][OUT] Returns the information structure pointer about pixel format - for the caller \n - * The meaning of returns pstValue structure - * - unsigned int nCurValue; // The current pixel format of the camera, is - the enumeration type, such as #PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to - MvGvspPixelType enumeration type in PixelType.h - * - unsigned int nSupportedNum; // Number of pixel formats supported by the - camera - * - unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all - supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this - list, otherwise invalid - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Other interface of Enumeration structure parameters can refer to this interface, look for the - corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置像素格式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] - 要设置的像素格式对应的整型值,调用此接口时可以直接填写枚举值,如#MV_CC_SetPixelFormat(m_handle, - #PixelType_Gvsp_RGB8_Packed); - * @return 成功,返回#MV_OK,并且相机像素格式将会更改为相应值,失败,返回错误码 - * @remarks 要设置的枚举类型必须是Get接口返回的nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]中的一种,否则会失败 - - * @~english - * @brief Set Pixel Format - * @param handle [IN] Camera Handle - * @param nValue [IN] The corresponding integer value for pixel format to be set, - when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, - PixelType_Gvsp_RGB8_Packed); - * @return Success, return #MV_OK, and the camera pixel format will change to the corresponding value. Failure, - return error code - * @remarks Other interface of Enumeration structure parameters can refer to this interface, the enumeration type - to be set must be one of the nSupportValue [#MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it - will fail - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取采集模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关采集模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的#MV_CAM_ACQUISITION_MODE 定义 - - * @~english - * @brief Get acquisition mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of acquisition mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_ACQUISITION_MODE in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置像素格式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的采集模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机采集模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set acquisition mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to acquisition mode - * @return Success, return #MV_OK, and the camera acquisition mode will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取增益模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关增益模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_GAIN_MODE 定义 - - * @~english - * @brief Get gain mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of gain mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_GAIN_MODE in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置增益模式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的增益模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机增益模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set gain mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to gain mode - * @return Success, return #MV_OK, and the camera gain mode will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取自动曝光模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关自动曝光模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的#MV_CAM_EXPOSURE_AUTO_MODE 定义 - - * @~english - * @brief Get auto exposure mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of auto exposure mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_EXPOSURE_AUTO_MODE in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置自动曝光模式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的自动曝光模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机自动曝光模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set auto exposure mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to auto exposure mode - * @return Success, return #MV_OK, and the camera auto exposure mode will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取触发模式 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关触发模式的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口#MV_CC_GetPixelFormat,参考 CameraParams.h 中的#MV_CAM_TRIGGER_MODE 定义 - - * @~english - * @brief Get trigger mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of trigger mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to #MV_CC_GetPixelFormat and definition of #MV_CAM_TRIGGER_MODE in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置触发模式 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的触发模式对应的整型值 - * @return 成功,返回#MV_OK,并且相机触发模式将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set trigger mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to trigger mode - * @return Success, return #MV_OK, and the camera trigger mode will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取触发延时 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机触发延时的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetFrameRate - - * @~english - * @brief Get tigger delay - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of trigger delay - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to MV_CC_GetFrameRate - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void *handle, IN OUT MVCC_FLOATVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置触发延时 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机触发延时 - * @return 成功,返回#MV_OK,并且相机触发延时将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set tigger delay - * @param handle [IN] Handle - * @param fValue [IN] Trigger delay to set - * @return Success, return #MV_OK, and the camera trigger delay will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void *handle, IN const float fValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取触发源 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关触发源的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_TRIGGER_SOURCE 定义 - - * @~english - * @brief Get trigger source - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of trigger source - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置触发源 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的触发源对应的整型值 - * @return 成功,返回#MV_OK,并且相机触发源将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set trigger source - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to trigger source - * @return Success, return #MV_OK, and the camera trigger source will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 软触发一次(接口仅在已选择的触发源为软件触发时有效) - * @param handle [IN] 相机句柄 - * @return 成功,返回#MV_OK, 失败,返回错误码 - * @remarks - - * @~english - * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) - * @param handle [IN] Handle - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void *handle); - - /********************************************************************/ /** - * @~chinese - * @brief 获取Gamma类型 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关Gamma类型的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_GAMMA_SELECTOR 定义 - - * @~english - * @brief Get Gamma mode - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of gamma mode - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Gamma类型 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的Gamma类型对应的整型值 - * @return 成功,返回#MV_OK,并且相机Gamma类型将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Gamma mode - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to gamma mode - * @return Success, return #MV_OK, and the camera gamma mode will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取Gamma值 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机Gamma值的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetExposureTime - - * @~english - * @brief Get Gamma value - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of gamma value - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to MV_CC_GetFrameRate - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void *handle, IN OUT MVCC_FLOATVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置Gamma值 - * @param handle [IN] 相机句柄 - * @param fValue [IN] 想要设置的相机Gamma值 - * @return 成功,返回#MV_OK,并且相机Gamma值将会更改为相应值,失败,返回错误码 - - * @~english - * @brief Set Gamma value - * @param handle [IN] Handle - * @param fValue [IN] Gamma value to set - * @return Success, return #MV_OK, and the camera gamma value will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void *handle, IN const float fValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取锐度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机锐度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get sharpness - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of sharpness - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置锐度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的锐度 - * @return 成功,返回#MV_OK,并且相机锐度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set sharpness - * @param handle [IN] Handle - * @param nValue [IN] Sharpness to set - * @return Success, return #MV_OK, and the camera sharpness will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取灰度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机灰度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get Hue - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of Hue - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置灰度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的灰度 - * @return 成功,返回#MV_OK,并且相机灰度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Hue - * @param handle [IN] Handle - * @param nValue [IN] Hue to set - * @return Success, return #MV_OK, and the camera Hue will change to the corresponding value. Failure, return - error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取饱和度 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机饱和度结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get Saturation - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of Saturation - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置饱和度 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的饱和度 - * @return 成功,返回#MV_OK,并且相机饱和度将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Saturation - * @param handle [IN] Handle - * @param nValue [IN] Saturation to set - * @return Success, return #MV_OK, and the camera Saturation will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取自动白平衡 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者的有关自动白平衡的信息结构体指针 - * @return 成功,返回#MV_OK,并获得相应参数信息的结构体, 失败, 返回错误码 - * @remarks 可参照接口MV_CC_GetPixelFormat,参考 CameraParams.h 中的 MV_CAM_BALANCEWHITE_AUTO 定义 - - - * @~english - * @brief Get Auto white balance - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of auto white balance - * @return Success, return #MV_OK, and get the structure of the corresponding parameters. Failure, return error - code - * @remarks Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParams.h - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void *handle, IN OUT MVCC_ENUMVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置自动白平衡 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 要设置的自动白平衡对应的整型值 - * @return 成功,返回#MV_OK,并且相机自动白平衡将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set Auto white balance - * @param handle [IN] Handle - * @param nValue [IN] Integer value to set corresponding to auto white balance - * @return Success, return #MV_OK, and the camera auto white balance will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取白平衡 红 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机白平衡 红结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get white balance red - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of white balance red - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置白平衡 红 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的白平衡 红 - * @return 成功,返回#MV_OK,并且相机白平衡 红将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set white balance red - * @param handle [IN] Handle - * @param nValue [IN] White balance red to set - * @return Success, return #MV_OK, and the camera white balance red will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取白平衡 绿 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机白平衡 绿结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get white balance green - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of white balance green - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置白平衡 绿 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的白平衡 绿 - * @return 成功,返回#MV_OK,并且相机白平衡 绿将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set white balance green - * @param handle [IN] Handle - * @param nValue [IN] White balance green to set - * @return Success, return #MV_OK, and the camera white balance green will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取白平衡 蓝 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机白平衡 蓝结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get white balance blue - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of white balance blue - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置白平衡 蓝 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的白平衡 蓝 - * @return 成功,返回#MV_OK,并且相机白平衡 蓝将会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set white balance blue - * @param handle [IN] Handle - * @param nValue [IN] White balance blue to set - * @return Success, return #MV_OK, and the camera white balance blue will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取水印信息内包含的信息类型 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机水印信息内包含的信息类型结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get information type included by frame stamp - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of information type included by frame stamp - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置水印信息内包含的信息类型 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的水印信息内包含的信息类型 - * @return 成功,返回#MV_OK,并且相机水印信息内包含的信息类型会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set information type included by frame stamp - * @param handle [IN] Handle - * @param nValue [IN] Information type included by frame stamp to set - * @return Success, return #MV_OK, and the camera information type included by frame stamp will change to the - corresponding value. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取设备自定义名字 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机名字结构体指针 - * @return 成功,返回#MV_OK,并且获取到相机的自定义名字,失败,返回错误码 - * @remarks - - * @~english - * @brief Get device user defined name - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of device name - * @return Success, return #MV_OK, and get the camera user defined name. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void *handle, IN OUT MVCC_STRINGVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置设备自定义名字 - * @param handle [IN] 相机句柄 - * @param chValue [IN] 设备名字 - * @return 成功,返回#MV_OK,并且设置设备自定义名字,失败,返回错误码 - * @remarks - - * @~english - * @brief Set device user defined name - * @param handle [IN] Handle - * @param chValue [IN] Device name - * @return Success, return #MV_OK, and set the camera user defined name. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void *handle, IN const char *chValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取一次触发的帧数 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机一次触发的帧数结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get frame number trigger by once - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of frame number trigger by once - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置一次触发的帧数 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的一次触发的帧数 - * @return 成功,返回#MV_OK,并且相机一次触发的帧数会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set frame number trigger by once - * @param handle [IN] Handle - * @param nValue [IN] Frame number trigger by once to set - * @return Success, return #MV_OK, and the camera frame number trigger by once will change to the corresponding - value. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取行频 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机行频结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get line rate - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of line rate - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置行频 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的行频 - * @return 成功,返回#MV_OK,并且相机行频会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set line rate - * @param handle [IN] Handle - * @param nValue [IN] Line rate to set - * @return Success, return #MV_OK, and the camera line rate will change to the corresponding value. Failure, - return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取心跳信息 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机心跳信息结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get heartbeat information - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of heartbeat information - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置心跳信息 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的心跳信息 - * @return 成功,返回#MV_OK,并且相机心跳信息会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set heartbeat information - * @param handle [IN] Handle - * @param nValue [IN] Heartbeat information to set - * @return Success, return #MV_OK, and the camera heartbeat information will change to the corresponding value. - Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取网络包大小 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机网络包大小结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get network packet size - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of network packet size - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置网络包大小 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的网络包大小 - * @return 成功,返回#MV_OK,并且相机网络包大小会更改为相应值,失败,返回错误码 - - * @~english - * @brief Set network packet size - * @param handle [IN] Handle - * @param nValue [IN] Packet size to set - * @return Success, return #MV_OK, and change packet size to setting value. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取网络包发送间隔 - * @param handle [IN] 相机句柄 - * @param pstValue [IN][OUT] 返回给调用者有关相机网络包发送间隔结构体指针 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 可参照接口MV_CC_GetWidth - - * @~english - * @brief Get network packet sending delay - * @param handle [IN] Handle - * @param pstValue [IN][OUT] Structure pointer of network packet sending delay - * @return Success, return #MV_OK. Failure, return error code - * @remarks Refer to MV_CC_GetWidth - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void *handle, IN OUT MVCC_INTVALUE *pstValue); - - /********************************************************************/ /** - * @~chinese - * @brief 设置网络包发送间隔 - * @param handle [IN] 相机句柄 - * @param nValue [IN] 想要设置的网络包发送间隔 - * @return 成功,返回#MV_OK,并且相机网络包发送间隔会更改为相应值,失败,返回错误码 - - * @~english - * @brief Set network packet sending delay - * @param handle [IN] Handle - * @param nValue [IN] Packet delay to set - * @return Success, return #MV_OK, and change packet delay to setting value. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void *handle, IN const unsigned int nValue); - - /********************************************************************/ /** - * @~chinese - * @brief 获取接收端IP地址,0xa9fe0102 表示 169.254.1.2 - * @param handle [IN] 相机句柄 - * @param pnIP [IN][OUT] 返回给调用者接收端IP地址 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - - * @~english - * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 - * @param handle [IN] Handle - * @param pnIP [IN][OUT] Receiver IP address - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void *handle, unsigned int *pnIP); - - /********************************************************************/ /** - * @~chinese - * @brief 设置接收端IP地址 - * @param handle [IN] 相机句柄 - * unsigned int nIP [IN] 想要设置的接收端IP地址 - * @return 成功,返回#MV_OK,并且相机接收端IP地址会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set receiver IP address - * @param handle [IN] Handel - * unsigned int nIP [IN] Receiver IP address to set - * @return Success, return #MV_OK, and change receiver IP address to setting value. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void *handle, unsigned int nIP); - - /********************************************************************/ /** - * @~chinese - * @brief 获取发送端的端口号 - * @param handle [IN] 相机句柄 - * @param pnPort [IN][OUT] 返回给调用者发送端的端口号 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - - * @~english - * @brief Get transmitter port number - * @param handle [IN] Handle - * @param pnPort [IN][OUT] Transmitter port number - * @return Success, return #MV_OK. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void *handle, unsigned int *pnPort); - - /********************************************************************/ /** - * @~chinese - * @brief 设置发送端的端口号 - * @param handle [IN] 相机句柄 - * @param nPort [IN] 想要设置的发送端的端口号 - * @return 成功,返回#MV_OK,并且相机发送端的端口号会更改为相应值,失败,返回错误码 - * @remarks - - * @~english - * @brief Set transmitter port number - * @param handle [IN] Handle - * @param nPort [IN] Transmitter port number to set - * @return Success, return #MV_OK, and change transmitter port number to setting value. Failure, return error code - * @remarks - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void *handle, unsigned int nPort); - - /************************************************************************/ - /* CameraLink 设备独有的接口,Linux 平台不支持 */ - /* APIs only support CameraLink device, not supported on Linux */ - /************************************************************************/ - /********************************************************************/ /** - * @~chinese - * @brief 设置设备波特率 - * @param handle [IN] 设备句柄 - * @param nBaudrate [IN] 设置的波特率值,数值参考CameraParams.h中宏定义,如#define - MV_CAML_BAUDRATE_9600 0x00000001 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口接口支持在设备未连接时调用。 - - * @~english - * @brief Set device bauderate using one of the CL_BAUDRATE_XXXX value - * @param handle [IN] Device handle - * @param nBaudrate [IN] baud rate to set. Refer to the CameraParams.h for parameter - definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by CameraLink device.\n - This API supports calls when devices are not connected. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBauderate(IN void *handle, unsigned int nBaudrate); - - /********************************************************************/ /** - * @~chinese - * @brief 获取设备波特率 - * @param handle [IN] 设备句柄 - * @param pnCurrentBaudrate [OUT] 波特率信息指针,数值参考CameraParams.h中宏定义,如#define - MV_CAML_BAUDRATE_9600 0x00000001 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口接口支持在设备未连接时调用。 - - * @~english - * @brief Returns the current device bauderate, using one of the CL_BAUDRATE_XXXX value - * @param handle [IN] Device handle - * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the - CameraParams.h for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by CameraLink device.\n - This API supports calls when devices are not connected. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBauderate(IN void *handle, unsigned int *pnCurrentBaudrate); - - /********************************************************************/ /** - * @~chinese - * @brief 获取设备与主机间连接支持的波特率 - * @param handle [IN] 设备句柄 - * @param pnBaudrateAblity [OUT] - 支持的波特率信息的指针。所支持波特率的或运算结果,单个数值参考CameraParams.h中宏定义,如#define - MV_CAML_BAUDRATE_9600 0x00000001 - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks 该接口接口支持在设备未连接时调用。 - - * @~english - * @brief Returns supported bauderates of the combined device and host interface - * @param handle [IN] Device handle - * @param pnBaudrateAblity [OUT] Return pointer of the supported bauderates to user. 'OR' - operation results of the supported bauderates. Refer to the CameraParams.h for single value definitions, for - example, #define MV_CAML_BAUDRATE_9600 0x00000001 - * @return Success, return #MV_OK. Failure, return error code - * @remarks This API is supported only by CameraLink device.\n - This API supports calls when devices are not connected. - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBauderates(IN void *handle, unsigned int *pnBaudrateAblity); - - /********************************************************************/ /** - * @~chinese - * @brief 设置串口操作等待时长 - * @param handle [IN] 设备句柄 - * @param nMillisec [IN] 串口操作的等待时长, ms - * @return 成功,返回#MV_OK,失败,返回错误码 - * @remarks - - * @~english - * @brief Sets the timeout for operations on the serial port - * @param handle [IN] Device handle - * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. - * @return Success, return #MV_OK. Failure, return error code - * @return Success, return MV_OK. Failure, return error code - ************************************************************************/ - MV_CAMCTRL_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void *handle, unsigned int nMillisec); +/********************************************************************//** + * @~chinese + * @brief شԴ + * @param handle [IN] 豸 + * @param nRetryTimes [IN] شԴĬ20 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set the max resend retry times + * @param handle [IN] Device handle + * @param nRetryTimes [IN] The max times to retry resending lost packetsdefault 20 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendMaxRetryTimes(IN void* handle, IN unsigned int nRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشԴ + * @param handle [IN] 豸 + * @param pnRetryTimes [IN][OUT] شԴ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get the max resend retry times + * @param handle [IN] Device handle + * @param pnRetryTimes [IN][OUT] The max times to retry resending lost packets + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendMaxRetryTimes(IN void* handle, IN OUT unsigned int* pnRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ͬһش֮ʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ͬһش֮ʱĬ10ms + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set time interval between same resend requests + * @param handle [IN] Device handle + * @param nMillisec [IN] The time interval between same resend requests,default 10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendTimeInterval(IN void* handle, IN unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡͬһش֮ʱ + * @param handle [IN] 豸 + * @param pnMillisec [IN][OUT] ͬһش֮ʱ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get time interval between same resend requests + * @param handle [IN] Device handle + * @param pnMillisec [IN][OUT] The time interval between same resend requests + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendTimeInterval(IN void* handle, IN OUT unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief ôģʽΪģʽ鲥ģʽ + * @param handle [IN] 豸 + * @param stTransmissionType [IN] ģʽṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿôģʽΪ鲥ģʽGigEVision豸֧֡ + + * @~english + * @brief Set transmission type,Unicast or Multicast + * @param handle [IN] Device handle + * @param stTransmissionType [IN] Struct of transmission type + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is only valid for GigEVision camera. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetTransmissionType(IN void* handle, IN MV_TRANSMISSION_TYPE * pstTransmissionType); + +/********************************************************************//** + * @~chinese + * @brief + * @param pstActionCmdInfo [IN] Ϣ + * @param pstActionCmdResults [IN][OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks GigEVision豸֧֡ + + * @~english + * @brief Issue Action Command + * @param pstActionCmdInfo [IN] Action Command + * @param pstActionCmdResults [IN][OUT] Action Command Result List + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by GigEVision camera. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, IN OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults); + +/********************************************************************//** + * @~chinese + * @brief ȡ鲥״̬ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param pbStatus [IN][OUT] 鲥״̬,true:鲥״̬false:鲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿж豸ǰǷ鲥״̬ͻöʱҪ豸ж鲥⡣ + + * @~english + * @brief Get Multicast Status + * @param pstDevInfo [IN] Device Information Structure + * @param pbStatus [IN][OUT] Status of Multicast + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to determine whether the camera is currently in multicast state, + and to solve the problem that the client needs to turn on the camera to determine multicast when enumerating. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetMulticastStatus(IN MV_CC_DEVICE_INFO* pstDevInfo, IN OUT bool* pbStatus); + + +/*******************Part6 ch: CameraLink 豸ֵ֧Ľӿ | en: Only support camlink device interface*******************/ +/********************************************************************//** + * @~chinese + * @brief ȡϢб + * @param pstSerialPortList [IN][OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡصĴϢ + + * @~english + * @brief Get serial port information list + * @param pstSerialPortList [IN][OUT] serial port information list + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get local serial port information + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSerialPortList(IN OUT MV_CAML_SERIAL_PORT_LIST* pstSerialPortList); + +/********************************************************************//** + * @~chinese + * @brief ȡָöٴ + * @param pstSerialPortList [IN][OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks ýӿöCameraLink 豸ָڡ + + * @~english + * @brief Set the specified enumeration serial port + * @param pstSerialPortList [IN] serial port information list + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to set the specified enumeration serial port + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetEnumSerialPorts(IN MV_CAML_SERIAL_PORT_LIST* pstSerialPortList); + +/***********************************************************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱ. ͨGenTLЭ豸ʱҪ豸ܵøýӿ + Ӳ/ϵͳ/ⲿŵ,ø߲ʿܵͨ쳣òС115200 + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device. + This API support calls when devices are not connected. But it is necessary to connect to the device first when accessing a CameraLink Device through the GenTL protocol. + Due to hardware/system/external interference and other factors, configuring a high baud rate may cause abnormal communication. + It is recommended to configure a baud rate of less than 115200 +************************************************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBaudrate(IN void* handle, IN unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [IN][OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [IN][OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device. + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBaudrate(IN void* handle,IN OUT unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [IN][OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [IN][OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device. + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBaudrates(IN void* handle,IN OUT unsigned int* pnBaudrateAblity); + +/********************************************************************//** + * @~chinese + * @brief ôڲȴʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ڲĵȴʱ, λΪms + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Sets the timeout for operations on the serial port + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. + * @return Success, return MV_OK. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void* handle, IN unsigned int nMillisec); + + +/*******************Part7 ch: U3V豸ֵ֧Ľӿ | en: Only support U3V device interface*******************/ + +/********************************************************************//** + * @~chinese + * @brief U3VĴС + * @param handle [IN] 豸 + * @param nTransferSize [IN] İС, ByteĬΪ1Mrang>=0x400ֵ[windows] rang <= 0x400000[Linux] rang <= 0x200000 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӴСʵȡʱCPUռʡͬPCͲͬUSBչڲͬļԣòùܻȡͼķա + + * @~english + * @brief Set transfer size of U3V device + * @param handle [IN] Device handle + * @param nTransferSize [IN] Transfer sizeBytedefault1Mrang>=0x400Recommended maximum: [windows] rang <= 0x400000; [Linux] rang <= 0x200000 + * @return Success, return MV_OK. Failure, return error code + * @remarks Increasing the transmission packet size can reduce the CPU utilization at the time of fetching. However, different PCS and different USB extension CARDS have different compatibility, and if this parameter is set too large, there may be the risk of not getting the image. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetTransferSize(IN void* handle, IN unsigned int nTransferSize); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴС + * @param handle [IN] 豸 + * @param pnTransferSize [IN][OUT] İСָ, Byte + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3VСĬ1M + + * @~english + * @brief Get transfer size of U3V device + * @param handle [IN] Device handle + * @param pnTransferSize [IN][OUT] Transfer sizeByte + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current U3V transfer packet size, default 1M. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetTransferSize(IN void* handle, IN OUT unsigned int* pnTransferSize); + +/********************************************************************//** + * @~chinese + * @brief U3VĴͨ + * @param handle [IN] 豸 + * @param nTransferWays [IN] ͨΧ1-10 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ûԸPCܡ豸ͼ֡ʡͼСڴʹʵضԸòеڡͬPCͲͬUSBչڲͬļԡ + + * @~english + * @brief Set transfer ways of U3V device + * @param handle [IN] Device handle + * @param nTransferWays [IN] Transfer waysrang1-10 + * @return Success, return MV_OK. Failure, return error code + * @remarks Users can adjust this parameter according to PC performance, camera image frame rate, image size, memory utilization and other factors. But different PCS and different USB expansion CARDS have different compatibility. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetTransferWays(IN void* handle, IN unsigned int nTransferWays); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴͨ + * @param handle [IN] 豸 + * @param pnTransferWays [IN][OUT] ָͨ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3V첽ȡڵ2000W豸MONO8ĬΪ3YUVΪĬ2RGBΪĬ1Ĭ8ڵ㡣 + + * @~english + * @brief Get transfer ways of U3V device + * @param handle [IN] Device handle + * @param pnTransferWays [IN][OUT] Transfer ways + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of U3V asynchronous feed nodes. For 2000W camera, MONO8 defaults to 3, YUV defaults to 2, RGB defaults to 1, and other cases default to 8 nodes. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetTransferWays(IN void* handle, IN OUT unsigned int* pnTransferWays); + +/********************************************************************//** + * @~chinese + * @brief ע쳣Ϣصڴ豸֮ãֻ֧U3V֧GenTL豸 + * @param handle [IN] 豸 + * @param cbException [IN] 쳣صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Register exception stream callBack, call after open device (only support U3V Camera, don't support GenTL Device) + * @param handle [IN] Device handle + * @param cbException [IN] Exception callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_RegisterStreamExceptionCallBack(IN void* handle, IN void(__stdcall* cbException)(MV_CC_STREAM_EXCEPTION_TYPE enExceptionType, void* pUser), IN void* pUser); + +/********************************************************************//** + * @~chinese + * @brief U3V¼ڵ + * @param handle [IN] 豸 + * @param nEventNodeNum [IN] ¼ڵΧ1-64 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿõǰU3V¼ڵĬΪ5 + + * @~english + * @brief Set the number of U3V device event cache nodes + * @param handle [IN] Device handle + * @param nEventNodeNum [IN] Event Node Number + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to set the current number of U3V event nodes. default to 5 nodes. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetEventNodeNum(IN void* handle, IN unsigned int nEventNodeNum); + + +/********************************************************************//** + * @~chinese + * @brief U3Vͬдʱʱ䣬ΧΪ1000 ~ UINT_MAX(1000UINT_MAX) + * @param handle [IN] 豸 + * @param nMills [IN] ͬдʱʱ,ĬʱΪ1000ms + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͬȡʱӿڣݲò1000ms + + * @~english + * @brief Set U3V Synchronisation timeout,range is 1000 ~ UINT_MAX(minimum value greater than 1000,maximum value less than UINT_MAX) + * @param handle [IN] Device handle + * @param nMills [IN] set synchronisation timeout(ms),default 1000ms + * @return Success, return MV_OK. Failure, return error code + * @remarks Increasing the SetSyncTimeOut can compatible with some camera configuretion parameters very slow,more than 1000ms +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetSyncTimeOut(IN void* handle, IN unsigned int nMills); + +/********************************************************************//** + * @~chinese + * @brief ȡU3Vͬдʱʱ + * @param handle [IN] 豸 + * @param pnMills [IN][OUT] ȡijʱʱ(ms) + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3VͬдʱʱСĬ1000ms + + * @~english + * @brief Get U3V Camera Synchronisation timeout + * @param handle [IN] Device handle + * @param pnMills [IN][OUT] Get Synchronisation time(ms) + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current U3V timeout, default 1000ms. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetSyncTimeOut(IN void* handle, IN OUT unsigned int* pnMills); + + + +/*******************Part8 ch: GenTLؽӿ | en: GenTL related interface*******************/ + +/******************************************************************************//** + * @~chinese + * @brief ͨGenTLöInterfaces + * @param pstIFList [IN][OUT] Interfacesб + * @param strGenTLPath [IN] GenTLctiļ· + * @return ɹMV_OK󣬷ش + * @remarks InterfacesбڴSDKڲģ̵߳øýӿʱ豸бڴͷź + 龡߳öٲ + + * @~english + * @brief Enumerate Interfaces with GenTL + * @param pstIFList [IN][OUT] Interfaces List + * @param strGenTLPath [IN] GenTL cti file path + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the Interfaces list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + *******************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumInterfacesByGenTL(IN OUT MV_GENTL_IF_INFO_LIST* pstIFList, IN const char * strGenTLPath); + +/********************************************************************//** + * @~chinese + * @brief жcti + * @param pGenTLPath [IN] öٿʱصctiļ· + * @return ɹMV_OK󣬷ش + * @remarks жǰҪ֤ͨctiöٳȫرգ򱨴ǰ + + * @~english + * @brief Unload cti library + * @param pGenTLPath [IN] GenTL cti file path + * @return Success, return MV_OK. Failure, return error code + * @remarks Make sure that all devices enumerated by this cti are already closed. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_UnloadGenTLLibrary(IN const char * pGenTLPath); + +/*****************************************************************************************************//** + * @~chinese + * @brief ͨGenTL Interfaceö豸 + * @param pstIFInfo [IN] InterfaceϢ + * @param pstDevList [IN][OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź + 龡߳öٲ + + * @~english + * @brief Enumerate Devices with GenTL interface + * @param pstIFInfo [IN] Interface information + * @param pstDevList [IN][OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + *****************************************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesByGenTL(IN MV_GENTL_IF_INFO* pstIFInfo, IN OUT MV_GENTL_DEV_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL豸Ϣ豸 + * @param handle [IN][OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹָ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣 + + * @~english + * @brief Create Device Handle with GenTL Device Info + * @param handle [IN][OUT] Device handle + * @param pstDevInfo [IN] Device Information + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleByGenTL(IN OUT void ** handle, IN const MV_GENTL_DEV_INFO* pstDevInfo); + + + +/*******************Part9 ch: ͼ񱣴桢ʽתؽӿ | en: Related image save and format convert interface*******************/ + +/********************************************************************//** + * @~chinese + * @brief ͼƬ֧BmpJpeg. + * @param handle [IN] 豸 + * @param pstSaveParam [IN][OUT] ͼƬṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿԽ豸ɼԭʼͼתJPEGBMPȸʽָڴУȻûԽתֱ֮ӱͼƬļ + ýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ + ýӿ֧ͼ ߡܳ UINT_MAX, MV_CC_SaveImageEx2֧ ߡܳ USHRT_MAX + JPEGʽֿ֧Ϊ65500 + + * @~english + * @brief Save image, support Bmp and Jpeg. + * @param handle [IN] Device handle + * @param pstSaveParam [IN][OUT] Save image parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Once there is image data, you can call this API to convert the data. + You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. + Comparing with the API MV_CC_SaveImageEx2, this API support the parameter nWidth/nHeight/nDataLen to UINT_MAX. + JPEG format supports a maximum width and height of 65500 + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx3(IN void* handle, IN OUT MV_SAVE_IMAGE_PARAM_EX3* pstSaveParam); + +/********************************************************************//** + * @~chinese + * @brief ͼļ + * @param handle [IN] 豸 + * @param pstSaveFileParam [IN][OUT] ͼƬļṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧BMP/JPEG/PNG/TIFF + ýӿ֧ͼ ߡܳ UINT_MAX, MV_CC_SaveImageToFile֧ ߡܳ USHRT_MAX + ýӿMV_CC_SaveImageToFileӿڵչӿ + JPEGʽֿ֧Ϊ65500 + * @~english + * @brief Save the image file. + * @param handle [IN] Device handle + * @param pstSaveFileParam [IN][OUT] Save the image file parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support BMP/JPEG/PNG/TIFF. + Comparing with the API MV_CC_SaveImageToFile, this API support the parameter nWidth/nHeight/nDataLen to UINT_MAX. + JPEG format supports a maximum width and height of 65500 + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageToFileEx(IN void* handle, IN OUT MV_SAVE_IMAGE_TO_FILE_PARAM_EX* pstSaveFileParam); + + +/********************************************************************//** + * @~chinese + * @brief 3Dݣ֧PLYCSVOBJָʽ + * @param handle [IN] 豸 + * @param pstPointDataParam [IN][OUT] ݲṹ + * @return ɹMV_OK󣬷ش + * @remarks 3Dݸʽ3Dļʽ֧PLY/CSV/OBJ + Ŀǰ֧PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f, + ݲ֧3Dʽ + + * @~english + * @brief Save 3D point data, support PLYCSV and OBJ + * @param handle [IN] Device handle + * @param pstPointDataParam [IN][OUT] Save 3D point data parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Save the 3D data format to 3D file formatsupport PLYCSV and OBJ, + only support PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f + Other 3D format is not supported now. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SavePointCloudData(IN void* handle, IN OUT MV_SAVE_POINT_CLOUD_PARAM* pstPointDataParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstRotateParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵ90/180/270ת + + * @~english + * @brief Rotate Image + * @param handle [IN] Device handle + * @param pstRotateParam [IN][OUT] Rotate image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support 90/180/270 rotation of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RotateImage(IN void* handle, IN OUT MV_CC_ROTATE_IMAGE_PARAM* pstRotateParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstFlipParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵĴֱˮƽת + + * @~english + * @brief Flip Image + * @param handle [IN] Device handle + * @param pstFlipParam [IN][OUT] Flip image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support vertical and horizontal reverse of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FlipImage(IN void* handle, IN OUT MV_CC_FLIP_IMAGE_PARAM* pstFlipParam); + + +/********************************************************************//** + * @~chinese + * @brief ظʽת + * @param handle [IN] 豸 + * @param pstCvtParam [IN][OUT] ظʽתṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתûظʽָڴС + ýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûص + ȡһ֡ͼݣȻͨýӿתʽ豸ǰɼͼJPEGѹĸʽֵ֧øýӿڽת + ýӿ֧ͼ ߡܳ UINT_MAX, MV_CC_ConvertPixelType֧ ߡܳ USHRT_MAX + + * @~english + * @brief Pixel format conversion + * @param handle [IN] Device handle + * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. + There is no order requirement to call this API, the transformation will execute when there is image data. + First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, + then call this API to transform the format. + Comparing with the API MV_CC_ConvertPixelType, this API support the parameter nWidth/nHeight/nSrcDataLen to UINT_MAX. + + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ConvertPixelTypeEx(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM_EX* pstCvtParam); + +/********************************************************************//** + * @~chinese + * @brief òֵ㷨 + * @param handle [IN] 豸 + * @param nBayerCvtQuality [IN] BayerIJֵ 0- 1- 2-ţĬΪţ 3-+ + * @return ɹMV_OK󣬷ش + * @remarks ڲͼתӿڵBayerֵ㷨ͲMV_CC_ConvertPixelTypeExMV_CC_GetImageForRGB/BGRӿڲʹõIJֵ㷨Ǹýӿ趨ġ + + * @~english + * @brief Interpolation algorithm type setting + * @param handle [IN] Device handle + * @param nBayerCvtQuality [IN] Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + * @return Success, return MV_OK. Failure, return error code + * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, + and the interpolation algorithm used in the MV_CC_ConvertPixelTypeEx and MV_CC_GetImageForRGB/BGR interfaces is set by this interface. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int nBayerCvtQuality); + +/********************************************************************//** + * @~chinese + * @brief ֵ㷨ƽʹ + * @param handle [IN] 豸 + * @param bFilterEnable [IN] ƽʹ(ĬϹر) + * @return ɹ#MV_OK󣬷ش + * @remarks ڲͼתӿڵıֵƽʹܲMV_CC_ConvertPixelTypeExMV_CC_SaveImageEx3ӿڲʹõIJֵ㷨Ǹýӿ趨ġ + + * @~english + * @brief Filter type of the bell interpolation quality algorithm setting + * @param handle [IN] Device handle + * @param bFilterEnable [IN] Filter type enable + * @return Success, return MV_OK. Failure, return error code + * @remarks Set the bell interpolation filter type parameters of the internal image conversion interface, + and the interpolation algorithm used in the MV_CC_ConvertPixelTypeEx and MV_CC_SaveImageEx3 interfaces is set by this interface. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerFilterEnable(IN void* handle, IN bool bFilterEnable); + +/********************************************************************//** + * @~chinese + * @brief BayerʽGammaֵ + * @param handle [IN] 豸 + * @param fBayerGammaValue [IN] Gammaֵ:0.1 ~ 4.0 + * @return ɹMV_OK󣬷ش + * @remarks øֵڵMV_CC_ConvertPixelTypeExMV_CC_SaveImageEx3MV_CC_SaveImageToFileExӿڽBayer8/10/12/16ʽתRGB24/48 RGBA32/64BGR24/48BGRA32/64ʱЧ + + * @~english + * @brief Set Gamma value + * @param handle [IN] Device handle + * @param fBayerGammaValue [IN] Gamma value[0.1,4.0] + * @return Success, return MV_OK. Failure, return error code + * @remarks After setting the value, it works when calling MV_CC_ConvertPixelTypeEx\MV_CC_SaveImageEx3\MV_CC_SaveImageToFileEx API convert Bayer8/10/12/16 to RGB24/48 RGBA32/64BGR24/48BGRA32/64. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerGammaValue(IN void* handle, IN float fBayerGammaValue); + +/********************************************************************//** + * @~chinese + * @brief Mono8/Bayer8/10/12/16ʽGammaֵ + * @param handle [IN] 豸 + * @param MvGvspPixelType enSrcPixelType [IN] ظʽ,֧PixelType_Gvsp_Mono8,Bayer8/10/12/16 + * @param fGammaValue [IN] Gammaֵ:0.1 ~ 4.0 + * @return ɹMV_OK󣬷ش + * @remarks Mono8gammaֵڵMV_CC_ConvertPixelTypeExӿڽMono8תMono8ʱgammaֵЧ + * @remarks Bayer8/10/12/16gammaֵڵMV_CC_ConvertPixelTypeExMV_CC_SaveImageToFileExMV_CC_SaveImageEx3ӿڽBayer8/10/12/16תRGB24/48 RGBA32/64BGR24/48BGRA32/64ʱgammaֵЧ + * @remarks ýӿڼMV_CC_SetBayerGammaValueӿڣ֧Mono8ظʽ + + * @~english + * @brief Set Gamma value + * @param handle [IN] Device handle + * @param MvGvspPixelType enSrcPixelType [IN] PixelType,support PixelType_Gvsp_Mono8,Bayer8/10/12/16 + * @param fGammaValue [IN] Gamma value:0.1~ 4.0 + * @remarks After setting the gamma of Mono8 the gamma value takes effect when calling MV_CC_ConvertPixelTypeEx converts Mono8 to Mono8. + * @remarks After setting the gamma of Bayer8/10/12/16, the gamma value takes effect when calling MV_CC_ConvertPixelTypeEx\MV_CC_SaveImageToFileEx\MV_CC_SaveImageEx3 converts Bayer8/10/12/16 to RGB24/48,RGBA32/64,BGR24/48,BGRA32/64. + * @remarks This API compatible with MV_CC_SetBayerGammaValue, adds Mono8 PixelType. + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGammaValue(IN void* handle, IN enum MvGvspPixelType enSrcPixelType, IN float fGammaValue); + +/********************************************************************//** + * @~chinese + * @brief BayerʽGammaϢ + * @param handle [IN] 豸 + * @param pstGammaParam [IN] GammaϢ + * @return ɹMV_OK󣬷ش + * @remarks øϢڵMV_CC_ConvertPixelTypeExMV_CC_SaveImageEx3MV_CC_SaveImageToFileExӿڽBayer8/10/12/16ʽתRGB24/48 RGBA32/64BGR24/48BGRA32/64ʱGammaֵЧ + + * @~english + * @brief Set Gamma param + * @param handle [IN] Device handle + * @param pstGammaParam [IN] Gamma param + * @return Success, return MV_OK. Failure, return error code + * @remarks After setting the param, it work in the calling MV_CC_ConvertPixelTypeEx\MV_CC_SaveImageEx3\MV_CC_SaveImageToFileEx API convert Bayer8/10/12/16 to RGB24/48 RGBA32/64BGR24/48BGRA32/64. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerGammaParam(IN void* handle, IN MV_CC_GAMMA_PARAM* pstGammaParam); + +/********************************************************************//** + * @~chinese + * @brief BayerʽCCMʹܺ;ϵĬ1024 + * @param handle [IN] 豸 + * @param pstCCMParam [IN] CCM + * @return ɹMV_OK󣬷ش + * @remarks CCMCCMڵMV_CC_ConvertPixelTypeExMV_CC_SaveImageEx3ӿڽBayer8/10/12/16ʽתRGB24/48 RGBA32/64BGR24/48BGRA32/64ʱЧ + + * @~english + * @brief Set CCM param,Scale default 1024 + * @param handle [IN] Device handle + * @param pstCCMParam [IN] CCM parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the color correction and set the color correction matrix, It work in the calling MV_CC_ConvertPixelTypeEx\MV_CC_SaveImageEx3 API convert Bayer8/10/12/16 to RGB24/48 RGBA32/64BGR24/48BGRA32/64. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCCMParam(IN void* handle, IN MV_CC_CCM_PARAM* pstCCMParam); + +/********************************************************************//** + * @~chinese + * @brief BayerʽCCMʹܺ; + * @param handle [IN] 豸 + * @param pstCCMParam [IN] CCM + * @return ɹMV_OK󣬷ش + * @remarks CCMCCMڵMV_CC_ConvertPixelTypeExMV_CC_SaveImageEx3ӿڽBayer8/10/12/16ʽתRGB24/48 RGBA32/64BGR24/48BGRA32/64ʱЧ + + * @~english + * @brief Set CCM param + * @param handle [IN] Device handle + * @param pstCCMParam [IN] CCM parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the color correction and set the color correction matrix, It work in the calling MV_CC_ConvertPixelTypeEx\MV_CC_SaveImageEx3 API convert Bayer8/10/12/16 to RGB24/48 RGBA32/64BGR24/48BGRA32/64. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCCMParamEx(IN void* handle, IN MV_CC_CCM_PARAM_EX* pstCCMParam); + +/********************************************************************//** + * @~chinese + * @brief ͼԱȶȵ + * @param handle [IN] 豸 + * @param pstContrastParam [IN][OUT] Աȶȵڲ + * @return ɹMV_OK󣬷ش + * @remarks + + * @~english + * @brief Adjust image contrast + * @param handle [IN] Device handle + * @param pstContrastParam [IN][OUT] Contrast parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ImageContrast(IN void* handle, IN OUT MV_CC_CONTRAST_PARAM* pstContrastParam); + +/********************************************************************//** + * @~chinese + * @brief + * @param handle [IN] 豸 + * @param pstDecodeParam [IN][OUT] ṹ + * @return ɹMV_OK󣬷ش + * @remarks ȡѹݣͬʱֽ֧ǰʵʱͼˮӡϢǵǰ߲ʵʱȡģˮӡ쳣; + ʧܣ1ҪCPU֧ SSE AVXָ2ǰ֡쳣ȣ,ܵ½쳣3ͼ쳣 ʹҲ쳣 + + * @~english + * @brief High Bandwidth Decode + * @param handle [IN] Device handle + * @param pstDecodeParam [IN][OUT] High Bandwidth Decode parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Decode the lossless compressed data from the camera into raw dataAt the same time, it supports parsing the watermark information of the real-time image of the current camera (if the input lossless code stream is not the current camera or is not real-time streaming, the watermark parsing may be abnormal); + If decoding fails, please check the following: (1) The CPU is required to support the SSE AVX instruction set. (2) If the current frame is abnormal (packet loss, etc.), it may cause decoding exceptions. (3) The camera plot is abnormal, even if there is no packet loss, it may cause exceptions + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_HB_Decode(IN void* handle, IN OUT MV_CC_HB_DECODE_PARAM* pstDecodeParam); + +/********************************************************************//** + * @~chinese + * @brief ͼϻƾο + * @param handle [IN] 豸 + * @param pRectInfo [IN] θߵϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڽ֧windowsƽ̨ + + * @~english + * @brief Draw Rect Auxiliary Line + * @param handle [IN] Device handle + * @param pRectInfo [IN] Rect Auxiliary Line Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface only supports windows platform. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DrawRect(IN void* handle, IN MVCC_RECT_INFO* pRectInfo); + +/********************************************************************//** + * @~chinese + * @brief ͼϻԲθ + * @param handle [IN] 豸 + * @param pCircleInfo [IN] ԲθߵϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڽ֧windowsƽ̨ + + * @~english + * @brief Draw Circle Auxiliary Line + * @param handle [IN] Device Handle + * @param pCircleInfo [IN] Circle Auxiliary Line Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface only supports windows platform. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DrawCircle(IN void* handle, IN MVCC_CIRCLE_INFO* pCircleInfo); + +/********************************************************************//** + * @~chinese + * @brief ͼϻ + * @param handle [IN] 豸 + * @param pLinesInfo [IN] Ϣ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڽ֧windowsƽ̨ + + * @~english + * @brief Draw Line Auxiliary Line + * @param handle [IN] Device Handle + * @param pLinesInfo [IN] Linear Auxiliary Line Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface only supports windows platform. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DrawLines(IN void* handle, IN MVCC_LINES_INFO* pLinesInfo); + +/********************************************************************//** + * @~chinese + * @brief ʼ¼ + * @param handle [IN] 豸 + * @param pstRecordParam [IN] ¼ṹ + * @return ɹMV_OK󣬷ش + ýӿ֧Width*HeightΪ8000*8000СᵼµMV_CC_InputOneFrameӿڴ + + * @~english + * @brief Start Record + * @param handle [IN] Device handle + * @param pstRecordParam [IN] Record param structure + * @return Success, return MV_OK. Failure, return error code + The maximum supported width * height of this interface is 8000 * 8000, otherwise it will result in calling MV_ CC_ InputOneFrame interface error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam); + +/********************************************************************//** + * @~chinese + * @brief ¼ + * @param handle [IN] 豸 + * @param pstInputFrameInfo [IN] ¼ݽṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Input RAW data to Record + * @param handle [IN] Device handle + * @param pstInputFrameInfo [IN] Record data structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo); + +/********************************************************************//** + * @~chinese + * @brief ֹͣ¼ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Stop Record + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StopRecord(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief 򿪻ȡGUI + * @param handle [IN] 豸 + * @return ɹMV_OKʧܣش롣 + * @remarks ͨMV_CC_OpenDevice豸󣬿ͨýӿڻȡ豸 + * @remarks ƣͬһ߳жͬʱøýӿڣֻܴ򿪵ǰһGUI棬ҪرյǰGUI󣬲ſɴһGUI棨汾Ż + ýӿڽ֧windowsƽ̨ + + * @~english + * @brief Open the GUI interface for getting or setting camera parameters + * @param handle [IN] Device handle + * @return Success, return MV_OK, Failure, return error code. + * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to get or set device params. + * @remarks Limit: calling this interface multiple times in the same thread can only open one GUI interface. + You need to wait until the previous GUI interface is closed before opening the next GUI interface.(Subsequent version optimization) + This interface only supports windows platform. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_OpenParamsGUI(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief عͼ(ڷʱع⹦) + * @param handle [IN] 豸 + * @param pstReconstructParam [IN][OUT] عͼ + * @return ɹMV_OKʧܣش롣 + * @remarks ͼָ֧ظʽͼָӦġMultiLightControlڵʹãýڵöͬعֵMultiLightControl=2, + ὫͬعֵӦͼ񽻵ϲΪһͼ(ʵʸ߶Ϊͼĸ߶)͸ϲӦó + øýӿڲʱعֵnExposureNumΪ2ɽ͵һͼָΪ2ͼͼֱӦһعֵ + ʹͨδġMultiLightControlڵ㣬ͼָ壬ֻǽͼзָΪ234ͼ + ÿͼĸ߶ȱΪԭͼ1/21/31/4(nExposureNum) + + * @~english + * @brief Reconstruct Image(For time-division exposure function) + * @param handle [IN] Device handle + * @param pstReconstructParam [IN][OUT] Reconstruct image parameters + * @return Success, return MV_OK, Failure, return error code. + * @remarks Image segmentation supports any pixel format. Image segmentation should be used with the "MultiLightControl" node of the linear array camera. This node can set multiple different exposure values, such as MultiLightControl=2, + The camera will overlap and merge two images corresponding to two different exposure values into one image (the actual height is the height of the two images) and send it to the upper application. + Call the interface and pass in nExposureNum is two. One image sent by the camera can be divided into two images, each of which corresponds to an exposure value. + If an ordinary camera is used or the "MultiLightControl" node of the linear array camera is not turned on, the image segmentation is meaningless, but the image is divided into 2, 3, and 4 images by line. + The height of each image becomes 1/2, 1/3, 1/4 of the original image (determined by nExposureNum). + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ReconstructImage(IN void* handle, IN OUT MV_RECONSTRUCT_IMAGE_PARAM* pstReconstructParam); #ifdef __cplusplus } -#endif +#endif -#endif //_MV_CAMERA_CTRL_H_ +#endif //_MV_CAMERA_CTRL_H_ diff --git a/hnurm_camera/include/hnurm_camera/MvErrorDefine.h b/hnurm_camera/include/hnurm_camera/MvErrorDefine.h index bece0938ffad225b3195d20329c6fd07202dcc44..f0cdaaa8ee5c5d97574e6d4fb31416f0267028a1 100755 --- a/hnurm_camera/include/hnurm_camera/MvErrorDefine.h +++ b/hnurm_camera/include/hnurm_camera/MvErrorDefine.h @@ -2,115 +2,108 @@ #ifndef _MV_ERROR_DEFINE_H_ #define _MV_ERROR_DEFINE_H_ +#include "MvISPErrorDefine.h" + /********************************************************************/ /// \~chinese -/// \name 正确码定义 +/// \name ȷ붨 /// @{ /// \~english /// \name Definition of correct code /// @{ -#define MV_OK 0x00000000 ///< \~chinese 成功,无错误 \~english Successed, no error +#define MV_OK 0x00000000 ///< \~chinese ɹ޴ \~english Successed, no error /// @} /********************************************************************/ /// \~chinese -/// \name 通用错误码定义:范围0x80000000-0x800000FF +/// \name ͨô붨:Χ0x80000000-0x800000FF /// @{ /// \~english /// \name Definition of General error code /// @{ -#define MV_E_HANDLE 0x80000000 ///< \~chinese 错误或无效的句柄 \~english Error or invalid handle -#define MV_E_SUPPORT 0x80000001 ///< \~chinese 不支持的功能 \~english Not supported function -#define MV_E_BUFOVER 0x80000002 ///< \~chinese 缓存已满 \~english Buffer overflow -#define MV_E_CALLORDER 0x80000003 ///< \~chinese 函数调用顺序错误 \~english Function calling order error -#define MV_E_PARAMETER 0x80000004 ///< \~chinese 错误的参数 \~english Incorrect parameter -#define MV_E_RESOURCE 0x80000006 ///< \~chinese 资源申请失败 \~english Applying resource failed -#define MV_E_NODATA 0x80000007 ///< \~chinese 无数据 \~english No data -#define MV_E_PRECONDITION \ - 0x80000008 ///< \~chinese 前置条件有误,或运行环境已发生变化 \~english Precondition error, or running - ///< environment changed -#define MV_E_VERSION 0x80000009 ///< \~chinese 版本不匹配 \~english Version mismatches -#define MV_E_NOENOUGH_BUF 0x8000000A ///< \~chinese 传入的内存空间不足 \~english Insufficient memory -#define MV_E_ABNORMAL_IMAGE \ - 0x8000000B ///< \~chinese 异常图像,可能是丢包导致图像不完整 \~english Abnormal image, maybe incomplete image - ///< because of lost packet -#define MV_E_LOAD_LIBRARY 0x8000000C ///< \~chinese 动态导入DLL失败 \~english Load library failed -#define MV_E_NOOUTBUF 0x8000000D ///< \~chinese 没有可输出的缓存 \~english No Avaliable Buffer -#define MV_E_UNKNOW 0x800000FF ///< \~chinese 未知的错误 \~english Unknown error +#define MV_E_HANDLE 0x80000000 ///< \~chinese Чľ \~english Error or invalid handle +#define MV_E_SUPPORT 0x80000001 ///< \~chinese ֵ֧Ĺ \~english Not supported function +#define MV_E_BUFOVER 0x80000002 ///< \~chinese \~english Buffer overflow +#define MV_E_CALLORDER 0x80000003 ///< \~chinese ˳ \~english Function calling order error +#define MV_E_PARAMETER 0x80000004 ///< \~chinese IJ \~english Incorrect parameter +#define MV_E_RESOURCE 0x80000006 ///< \~chinese Դʧ \~english Applying resource failed +#define MV_E_NODATA 0x80000007 ///< \~chinese \~english No data +#define MV_E_PRECONDITION 0x80000008 ///< \~chinese ǰ󣬻лѷ仯 \~english Precondition error, or running environment changed +#define MV_E_VERSION 0x80000009 ///< \~chinese 汾ƥ \~english Version mismatches +#define MV_E_NOENOUGH_BUF 0x8000000A ///< \~chinese ڴռ䲻 \~english Insufficient memory +#define MV_E_ABNORMAL_IMAGE 0x8000000B ///< \~chinese 쳣ͼ񣬿Ƕͼ \~english Abnormal image, maybe incomplete image because of lost packet +#define MV_E_LOAD_LIBRARY 0x8000000C ///< \~chinese ̬DLLʧ \~english Load library failed +#define MV_E_NOOUTBUF 0x8000000D ///< \~chinese ûпĻ \~english No Avaliable Buffer +#define MV_E_ENCRYPT 0x8000000E ///< \~chinese ܴ \~english Encryption error +#define MV_E_OPENFILE 0x8000000F ///< \~chinese ļִ \~english open file error +#define MV_E_UNKNOW 0x800000FF ///< \~chinese δ֪Ĵ \~english Unknown error /// @} /********************************************************************/ /// \~chinese -/// \name GenICam系列错误:范围0x80000100-0x800001FF +/// \name GenICamϵд:Χ0x80000100-0x800001FF /// @{ /// \~english /// \name GenICam Series Error Codes: Range from 0x80000100 to 0x800001FF /// @{ -#define MV_E_GC_GENERIC 0x80000100 ///< \~chinese 通用错误 \~english General error -#define MV_E_GC_ARGUMENT 0x80000101 ///< \~chinese 参数非法 \~english Illegal parameters -#define MV_E_GC_RANGE 0x80000102 ///< \~chinese 值超出范围 \~english The value is out of range -#define MV_E_GC_PROPERTY 0x80000103 ///< \~chinese 属性 \~english Property -#define MV_E_GC_RUNTIME 0x80000104 ///< \~chinese 运行环境有问题 \~english Running environment error -#define MV_E_GC_LOGICAL 0x80000105 ///< \~chinese 逻辑错误 \~english Logical error -#define MV_E_GC_ACCESS 0x80000106 ///< \~chinese 节点访问条件有误 \~english Node accessing condition error -#define MV_E_GC_TIMEOUT 0x80000107 ///< \~chinese 超时 \~english Timeout -#define MV_E_GC_DYNAMICCAST 0x80000108 ///< \~chinese 转换异常 \~english Transformation exception -#define MV_E_GC_UNKNOW 0x800001FF ///< \~chinese GenICam未知错误 \~english GenICam unknown error +#define MV_E_GC_GENERIC 0x80000100 ///< \~chinese ͨô \~english General error +#define MV_E_GC_ARGUMENT 0x80000101 ///< \~chinese Ƿ \~english Illegal parameters +#define MV_E_GC_RANGE 0x80000102 ///< \~chinese ֵΧ \~english The value is out of range +#define MV_E_GC_PROPERTY 0x80000103 ///< \~chinese \~english Property +#define MV_E_GC_RUNTIME 0x80000104 ///< \~chinese л \~english Running environment error +#define MV_E_GC_LOGICAL 0x80000105 ///< \~chinese ߼ \~english Logical error +#define MV_E_GC_ACCESS 0x80000106 ///< \~chinese ڵ \~english Node accessing condition error +#define MV_E_GC_TIMEOUT 0x80000107 ///< \~chinese ʱ \~english Timeout +#define MV_E_GC_DYNAMICCAST 0x80000108 ///< \~chinese ת쳣 \~english Transformation exception +#define MV_E_GC_UNKNOW 0x800001FF ///< \~chinese GenICamδ֪ \~english GenICam unknown error /// @} /********************************************************************/ /// \~chinese -/// \name GigE_STATUS对应的错误码:范围0x80000200-0x800002FF +/// \name GigE_STATUSӦĴ:Χ0x80000200-0x800002FF /// @{ /// \~english /// \name GigE_STATUS Error Codes: Range from 0x80000200 to 0x800002FF /// @{ -#define MV_E_NOT_IMPLEMENTED \ - 0x80000200 ///< \~chinese 命令不被设备支持 \~english The command is not supported by device -#define MV_E_INVALID_ADDRESS \ - 0x80000201 ///< \~chinese 访问的目标地址不存在 \~english The target address being accessed does not exist -#define MV_E_WRITE_PROTECT \ - 0x80000202 ///< \~chinese 目标地址不可写 \~english The target address is not writable -#define MV_E_ACCESS_DENIED 0x80000203 ///< \~chinese 设备无访问权限 \~english No permission -#define MV_E_BUSY 0x80000204 ///< \~chinese 设备忙,或网络断开 \~english Device is busy, or network disconnected -#define MV_E_PACKET 0x80000205 ///< \~chinese 网络包数据错误 \~english Network data packet error -#define MV_E_NETER 0x80000206 ///< \~chinese 网络相关错误 \~english Network error -#define MV_E_IP_CONFLICT 0x80000221 ///< \~chinese 设备IP冲突 \~english Device IP conflict +#define MV_E_NOT_IMPLEMENTED 0x80000200 ///< \~chinese 豸֧ \~english The command is not supported by device +#define MV_E_INVALID_ADDRESS 0x80000201 ///< \~chinese ʵĿַ \~english The target address being accessed does not exist +#define MV_E_WRITE_PROTECT 0x80000202 ///< \~chinese Ŀַд \~english The target address is not writable +#define MV_E_ACCESS_DENIED 0x80000203 ///< \~chinese 豸޷Ȩ \~english No permission +#define MV_E_BUSY 0x80000204 ///< \~chinese 豸æϿ \~english Device is busy, or network disconnected +#define MV_E_PACKET 0x80000205 ///< \~chinese ݴ \~english Network data packet error +#define MV_E_NETER 0x80000206 ///< \~chinese ش \~english Network error +#define MV_E_KEY_VERIFICATION 0x8000020F ///< \~chinese ԿУ \~english SwitchKey error +#define MV_E_IP_CONFLICT 0x80000221 ///< \~chinese 豸IPͻ \~english Device IP conflict /// @} /********************************************************************/ /// \~chinese -/// \name USB_STATUS对应的错误码:范围0x80000300-0x800003FF +/// \name USB_STATUSӦĴ:Χ0x80000300-0x800003FF /// @{ /// \~english /// \name USB_STATUS Error Codes: Range from 0x80000300 to 0x800003FF /// @{ -#define MV_E_USB_READ 0x80000300 ///< \~chinese 读usb出错 \~english Reading USB error -#define MV_E_USB_WRITE 0x80000301 ///< \~chinese 写usb出错 \~english Writing USB error -#define MV_E_USB_DEVICE 0x80000302 ///< \~chinese 设备异常 \~english Device exception -#define MV_E_USB_GENICAM 0x80000303 ///< \~chinese GenICam相关错误 \~english GenICam error -#define MV_E_USB_BANDWIDTH \ - 0x80000304 ///< \~chinese 带宽不足 该错误码新增 \~english Insufficient bandwidth, this error code is newly added -#define MV_E_USB_DRIVER 0x80000305 ///< \~chinese 驱动不匹配或者未装驱动 \~english Driver mismatch or unmounted drive -#define MV_E_USB_UNKNOW 0x800003FF ///< \~chinese USB未知的错误 \~english USB unknown error +#define MV_E_USB_READ 0x80000300 ///< \~chinese usb \~english Reading USB error +#define MV_E_USB_WRITE 0x80000301 ///< \~chinese дusb \~english Writing USB error +#define MV_E_USB_DEVICE 0x80000302 ///< \~chinese 豸쳣 \~english Device exception +#define MV_E_USB_GENICAM 0x80000303 ///< \~chinese GenICamش \~english GenICam error +#define MV_E_USB_BANDWIDTH 0x80000304 ///< \~chinese \~english Insufficient bandwidth +#define MV_E_USB_DRIVER 0x80000305 ///< \~chinese ƥδװ \~english Driver mismatch or unmounted drive +#define MV_E_USB_UNKNOW 0x800003FF ///< \~chinese USBδ֪Ĵ \~english USB unknown error /// @} /********************************************************************/ /// \~chinese -/// \name 升级时对应的错误码:范围0x80000400-0x800004FF +/// \name ʱӦĴ:Χ0x80000400-0x800004FF /// @{ /// \~english /// \name Upgrade Error Codes: Range from 0x80000400 to 0x800004FF /// @{ -#define MV_E_UPG_FILE_MISMATCH 0x80000400 ///< \~chinese 升级固件不匹配 \~english Firmware mismatches -#define MV_E_UPG_LANGUSGE_MISMATCH \ - 0x80000401 ///< \~chinese 升级固件语言不匹配 \~english Firmware language mismatches -#define MV_E_UPG_CONFLICT \ - 0x80000402 ///< \~chinese 升级冲突(设备已经在升级了再次请求升级即返回此错误) \~english Upgrading conflicted - ///< (repeated upgrading requests during device upgrade) -#define MV_E_UPG_INNER_ERR \ - 0x80000403 ///< \~chinese 升级时相机内部出现错误 \~english Camera internal error during upgrade -#define MV_E_UPG_UNKNOW 0x800004FF ///< \~chinese 升级时未知错误 \~english Unknown error during upgrade +#define MV_E_UPG_FILE_MISMATCH 0x80000400 ///< \~chinese ̼ƥ \~english Firmware mismatches +#define MV_E_UPG_LANGUSGE_MISMATCH 0x80000401 ///< \~chinese ̼Բƥ \~english Firmware language mismatches +#define MV_E_UPG_CONFLICT 0x80000402 ///< \~chinese ͻ豸Ѿٴش˴ \~english Upgrading conflicted (repeated upgrading requests during device upgrade) +#define MV_E_UPG_INNER_ERR 0x80000403 ///< \~chinese ʱ豸ڲִ \~english Camera internal error during upgrade +#define MV_E_UPG_UNKNOW 0x800004FF ///< \~chinese ʱδ֪ \~english Unknown error during upgrade /// @} -#endif //_MV_ERROR_DEFINE_H_ +#endif //_MV_ERROR_DEFINE_H_ diff --git a/hnurm_camera/include/hnurm_camera/MvISPErrorDefine.h b/hnurm_camera/include/hnurm_camera/MvISPErrorDefine.h new file mode 100755 index 0000000000000000000000000000000000000000..8f4d09699bce353acfb62be703c3b502c58e1813 --- /dev/null +++ b/hnurm_camera/include/hnurm_camera/MvISPErrorDefine.h @@ -0,0 +1,93 @@ + +#ifndef _MV_ISP_ERROR_DEFINE_H_ +#define _MV_ISP_ERROR_DEFINE_H_ + +/************************************************************************ +* ISP㷨Ĵ +************************************************************************/ +// ͨ +#define MV_ALG_OK 0x00000000 //ȷ +#define MV_ALG_ERR 0x10000000 //ȷʹ + +// +#define MV_ALG_E_ABILITY_ARG 0x10000001 //дЧ + +// ڴ +#define MV_ALG_E_MEM_NULL 0x10000002 //ڴַΪ +#define MV_ALG_E_MEM_ALIGN 0x10000003 //ڴ벻Ҫ +#define MV_ALG_E_MEM_LACK 0x10000004 //ڴռС +#define MV_ALG_E_MEM_SIZE_ALIGN 0x10000005 //ڴռСҪ +#define MV_ALG_E_MEM_ADDR_ALIGN 0x10000006 //ڴַҪ + +// ͼ +#define MV_ALG_E_IMG_FORMAT 0x10000007 //ͼʽȷ߲֧ +#define MV_ALG_E_IMG_SIZE 0x10000008 //ͼ߲ȷ߳Χ +#define MV_ALG_E_IMG_STEP 0x10000009 //ͼstepƥ +#define MV_ALG_E_IMG_DATA_NULL 0x1000000A //ͼݴ洢ַΪ + +// +#define MV_ALG_E_CFG_TYPE 0x1000000B //û߻ȡͲȷ +#define MV_ALG_E_CFG_SIZE 0x1000000C //û߻ȡ롢ṹСȷ +#define MV_ALG_E_PRC_TYPE 0x1000000D //Ͳȷ +#define MV_ALG_E_PRC_SIZE 0x1000000E //ʱ롢Сȷ +#define MV_ALG_E_FUNC_TYPE 0x1000000F //ӴͲȷ +#define MV_ALG_E_FUNC_SIZE 0x10000010 //Ӵʱ롢Сȷ + +// в +#define MV_ALG_E_PARAM_INDEX 0x10000011 //indexȷ +#define MV_ALG_E_PARAM_VALUE 0x10000012 //valueȷ߳Χ +#define MV_ALG_E_PARAM_NUM 0x10000013 //param_numȷ + +// ӿڵü +#define MV_ALG_E_NULL_PTR 0x10000014 //ָΪ +#define MV_ALG_E_OVER_MAX_MEM 0x10000015 //޶ڴ +#define MV_ALG_E_CALL_BACK 0x10000016 //ص + +// 㷨ؼ +#define MV_ALG_E_ENCRYPT 0x10000017 //ܴ +#define MV_ALG_E_EXPIRE 0x10000018 //㷨ʹ޴ + +// ڲģ鷵صĻ +#define MV_ALG_E_BAD_ARG 0x10000019 //Χȷ +#define MV_ALG_E_DATA_SIZE 0x1000001A //ݴСȷ +#define MV_ALG_E_STEP 0x1000001B //stepȷ + +// cpuָִ֧ +#define MV_ALG_E_CPUID 0x1000001C //cpu֧Żеָ + +#define MV_ALG_WARNING 0x1000001D // + +#define MV_ALG_E_TIME_OUT 0x1000001E //㷨ⳬʱ +#define MV_ALG_E_LIB_VERSION 0x1000001F //㷨汾ų +#define MV_ALG_E_MODEL_VERSION 0x10000020 //ģͰ汾ų +#define MV_ALG_E_GPU_MEM_ALLOC 0x10000021 //GPUڴ +#define MV_ALG_E_FILE_NON_EXIST 0x10000022 //ļ +#define MV_ALG_E_NONE_STRING 0x10000023 //ַΪ +#define MV_ALG_E_IMAGE_CODEC 0x10000024 //ͼ +#define MV_ALG_E_FILE_OPEN 0x10000025 //ļ +#define MV_ALG_E_FILE_READ 0x10000026 //ļȡ +#define MV_ALG_E_FILE_WRITE 0x10000027 //ļд +#define MV_ALG_E_FILE_READ_SIZE 0x10000028 //ļȡС +#define MV_ALG_E_FILE_TYPE 0x10000029 //ļʹ +#define MV_ALG_E_MODEL_TYPE 0x1000002A //ģʹ +#define MV_ALG_E_MALLOC_MEM 0x1000002B //ڴ +#define MV_ALG_E_BIND_CORE_FAILED 0x1000002C //̰߳ʧ + +// д +#define MV_ALG_E_DENOISE_NE_IMG_FORMAT 0x10402001 //ͼʽ +#define MV_ALG_E_DENOISE_NE_FEATURE_TYPE 0x10402002 //ʹ +#define MV_ALG_E_DENOISE_NE_PROFILE_NUM 0x10402003 //Ը +#define MV_ALG_E_DENOISE_NE_GAIN_NUM 0x10402004 // +#define MV_ALG_E_DENOISE_NE_GAIN_VAL 0x10402005 //ֵ +#define MV_ALG_E_DENOISE_NE_BIN_NUM 0x10402006 // +#define MV_ALG_E_DENOISE_NE_INIT_GAIN 0x10402007 //Ƴʼô +#define MV_ALG_E_DENOISE_NE_NOT_INIT 0x10402008 //δʼ +#define MV_ALG_E_DENOISE_COLOR_MODE 0x10402009 //ɫռģʽ +#define MV_ALG_E_DENOISE_ROI_NUM 0x1040200a //ͼROI +#define MV_ALG_E_DENOISE_ROI_ORI_PT 0x1040200b //ͼROIԭ +#define MV_ALG_E_DENOISE_ROI_SIZE 0x1040200c //ͼROIС +#define MV_ALG_E_DENOISE_GAIN_NOT_EXIST 0x1040200d //治(Ѵ) +#define MV_ALG_E_DENOISE_GAIN_BEYOND_RANGE 0x1040200e //治ڷΧ +#define MV_ALG_E_DENOISE_NP_BUF_SIZE 0x1040200f //ڴС + +#endif //_MV_ISP_ERROR_DEFINE_H_ diff --git a/hnurm_camera/include/hnurm_camera/MvObsoleteInterfaces.h b/hnurm_camera/include/hnurm_camera/MvObsoleteInterfaces.h new file mode 100755 index 0000000000000000000000000000000000000000..88e64f146f985c160917140e9a67eba314f7acfe --- /dev/null +++ b/hnurm_camera/include/hnurm_camera/MvObsoleteInterfaces.h @@ -0,0 +1,1921 @@ + +#ifndef _MV_OBSOLETE_INTERFACES_H_ +#define _MV_OBSOLETE_INTERFACES_H_ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "ObsoleteCamParams.h" + +/** +* @brief ̬⵼뵼 +* @brief Import and export definition of the dynamic library +*/ +#ifndef MV_CAMCTRL_API + + #if (defined (_WIN32) || defined(WIN64)) + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __declspec(dllexport) + #else + #define MV_CAMCTRL_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MV_CAMCTRL_API + #define MV_CAMCTRL_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* ʹõĽӿ */ +/* Interfaces not recommended */ +/************************************************************************/ +/************************************************************************ + * @fn MV_CC_GetImageInfo + * @brief ȡͼϢ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظйͼϢṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CC_GetImageInfo + * @brief Get basic information of image + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of image basic information + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageInfo(IN void* handle, IN OUT MV_IMAGE_BASIC_INFO* pstInfo); + +/************************************************************************ + * @fn MV_CC_GetTlProxy + * @brief ȡGenICam + * @param handle [IN] ַ + * @return GenICamָ ֵNULL쳣NULL + + * @fn MV_CC_GetTlProxy + * @brief Get GenICam proxy + * @param handle [IN] Handle address + * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL + ************************************************************************/ +MV_CAMCTRL_API void* __stdcall MV_CC_GetTlProxy(IN void* handle); + +/*********************************************************************** + * @fn MV_XML_GetRootNode + * @brief ȡڵ + * @param handle [IN] + * @param pstNode [OUT] ڵϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetRootNode + * @brief Get root node + * @param handle [IN] Handle + * @param pstNode [OUT] Root node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetRootNode(IN void* handle, IN OUT MV_XML_NODE_FEATURE* pstNode); + +/*********************************************************************** + * @fn MV_XML_GetChildren + * @brief xmlлȡָڵӽڵ㣬ڵΪRoot + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstNodesList [OUT] ڵбṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetChildren + * @brief Get all children node of specific node from xml, root node is Root + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstNodesList [OUT] Node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetChildren(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT MV_XML_NODES_LIST* pstNodesList); + +/*********************************************************************** + * @fn MV_XML_GetNodeFeature + * @brief õǰڵ + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstFeature [OUT] ǰڵԽṹ壬 + pstFeature ṹݲο MV_XML_FEATURE_x + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetNodeFeature + * @brief Get current node feature + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstFeature [OUT] Current node feature structure + Details of pstFeature refer to MV_XML_FEATURE_x + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeFeature(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT void* pstFeature); + +/*********************************************************************** + * @fn MV_XML_UpdateNodeFeature + * @brief ½ڵ + * @param handle [IN] + * @param enType [IN] ڵ + * @param pstFeature [OUT] ǰڵԽṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_UpdateNodeFeature + * @brief Update node + * @param handle [IN] Handle + * @param enType [IN] Node type + * @param pstFeature [OUT] Current node feature structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_UpdateNodeFeature(IN void* handle, IN enum MV_XML_InterfaceType enType, IN void* pstFeature); + +// нڵҪʱĻص +// MV_XML_UpdateNodeFeatureӿڸ½ڵʱעĻصcbUpdatepstNodesListз֮Ľڵ +/*********************************************************************** + * @fn MV_XML_RegisterUpdateCallBack + * @brief ע»ص + * @param handle [IN] + * @param cbUpdate [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_RegisterUpdateCallBack + * @brief Register update callback + * @param handle [IN] Handle + * @param cbUpdate [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_RegisterUpdateCallBack(IN void* handle, + IN void(__stdcall* cbUpdate)(enum MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser), + IN void* pUser); + +/************************************************************************/ +/* õĽӿڣڸŻĽӿڿ滻 */ +/* Abandoned interface */ +/************************************************************************/ +/*********************************************************************** + * @fn MV_CC_GetOneFrame + * @brief ȡһ֡ͼ񣬴˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrame + * @brief Get one frame data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrame(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_GetOneFrameEx + * @brief ȡһ֡trunckݣ˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrameEx + * @brief Get one frame of trunck data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameEx(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_RegisterImageCallBack + * @brief עͼݻصýӿã MV_CC_RegisterImageCallBackExӿڣ + * @param handle [IN] + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_RegisterImageCallBack + * @brief Register image data callback (This interface is abandoned, it is recommended to use the MV_CC_RegisterImageCallBackEx) + * @param handle [IN] Handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBack(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser), + void* pUser); + +/************************************************************************ + * @fn MV_CC_SaveImage + * @brief ͼƬýӿڽ֧Windowsã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImage + * @brief Save image (This interface only supports on Windows, and is abandoned, it is recommended to use the MV_CC_SaveImageEx2) + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Input data pixel format + nWidth; // [IN] Width + nHeight; // [IN] Height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Provided output buffer size + enImageType; // [IN] Output image type + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM* pSaveParam); + +/************************************************************************ + * @fn MV_CC_SaveImageEx + * @brief ͼƬ֧BmpJpeg.50-99֮ǰ ýӿڽ֧Windowsã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + nJpgQuality; // [IN] , (50-99] + nReserved[4]; + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImageEx + * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] + This interface only supports on Windows, and is abandoned, it is recommended to use the MV_CC_SaveImageEx2 + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Pixel format of input data + nWidth; // [IN] Image width + nHeight; // [IN] Image height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Output buffer size provided + enImageType; // [IN] Output image format + nJpgQuality; // [IN] Encoding quality, (50-99] + nReserved[4]; + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX* pSaveParam); + +/********************************************************************//** + * @~chinese + * @brief BayerƣýӿãISP Toolʽб궨 + * @param handle [IN] 豸 + * @param pstNoiseEstimateParam [IN][OUT] BayerƲṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Noise estimate of Bayer format + * @param handle [IN] Device handle + * @param pstNoiseEstimateParam [IN][OUT] Noise estimate parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_BayerNoiseEstimate(IN void* handle, IN OUT MV_CC_BAYER_NOISE_ESTIMATE_PARAM* pstNoiseEstimateParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer루ýӿãISP Toolʽн룩 + * @param handle [IN] 豸 + * @param pstSpatialDenoiseParam [IN][OUT] Bayerṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Spatial Denoise of Bayer format + * @param handle [IN] Device handle + * @param pstSpatialDenoiseParam [IN][OUT] Spatial Denoise parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_BayerSpatialDenoise(IN void* handle, IN OUT MV_CC_BAYER_SPATIAL_DENOISE_PARAM* pstSpatialDenoiseParam); + +/********************************************************************//** + * @~chinese + * @brief BayerʽCLUTʹܺϢýӿãISP Toolʽã + * @param handle [IN] 豸 + * @param pstCLUTParam [IN] CLUT + * @return ɹMV_OK󣬷ش + * @remarks CLUTCLUTϢڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayer8/10/12/16ʽתRGB24/48 RGBA32/64BGR24/48BGRA32/64ʱЧ + + * @~english + * @brief Set CLUT param + * @param handle [IN] Device handle + * @param pstCLUTParam [IN] CLUT parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the CLUT and set CLUT, It work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer8/10/12/16 to RGB24/48 RGBA32/64BGR24/48BGRA32/64. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCLUTParam(IN void* handle, IN MV_CC_CLUT_PARAM* pstCLUTParam); + +/********************************************************************//** + * @~chinese + * @brief ͼ񻯣ýӿãISP Toolʽ񻯣 + * @param handle [IN] 豸 + * @param pstSharpenParam [IN] 񻯲 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Image sharpen + * @param handle [IN] Device handle + * @param pstSharpenParam [IN] Sharpen parameter structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ImageSharpen(IN void* handle, IN OUT MV_CC_SHARPEN_PARAM* pstSharpenParam); + +/********************************************************************//** + * @~chinese + * @brief ɫУCCMCLUTýӿãISP ToolʽУ + * @param handle [IN] 豸 + * @param pstColorCorrectParam [IN] ɫУ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֵ֧CCMCLUTҲ֧ͬʱCCMCLUTûͨCCMCLUTϢеʹܿؽѡ + + * @~english + * @brief Color Correct(include CCM and CLUT) + * @param handle [IN] Device handle + * @param pstColorCorrectParam [IN] Color Correct parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API supports CCM or CLUT alone, as well as CCM and CLUT at the same time. The user can select by means of the enable switch in CCM and CLUT information. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ColorCorrect(IN void* handle, IN OUT MV_CC_COLOR_CORRECT_PARAM* pstColorCorrectParam); + +/********************************************************************//** + * @~chinese + * @brief ƣýӿãISP Toolʽб궨 + * @param handle [IN] 豸 + * @param pstNoiseEstimateParam [IN] Ʋ + * @return ɹMV_OK󣬷ش + * @remarks ûѡȫͼƣnROINum0pstROIRectÿա + + * @~english + * @brief Noise Estimate + * @param handle [IN] Device handle + * @param pstNoiseEstimateParam [IN] Noise Estimate parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks If the user selects the full image, nROINum can be typed with 0 and pstROIRect empty. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_NoiseEstimate(IN void* handle, IN OUT MV_CC_NOISE_ESTIMATE_PARAM* pstNoiseEstimateParam); + +/********************************************************************//** + * @~chinese + * @brief 루ýӿãISP Toolʽн룩 + * @param handle [IN] 豸 + * @param pstSpatialDenoiseParam [IN] + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Spatial Denoise + * @param handle [IN] Device handle + * @param pstSpatialDenoiseParam [IN] Spatial Denoise parameter structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SpatialDenoise(IN void* handle, IN OUT MV_CC_SPATIAL_DENOISE_PARAM* pstSpatialDenoiseParam); + + +/********************************************************************//** + * @~chinese + * @brief LSC궨 + * @param handle [IN] 豸 + * @param pstLSCCalibParam [IN] 궨 + * @return ɹMV_OK󣬷ش + * @remarks + + * @~english + * @brief LSC Calib + * @param handle [IN] Device handle + * @param pstLSCCalibParam [IN] LSC Calib parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_LSCCalib(IN void* handle, IN OUT MV_CC_LSC_CALIB_PARAM* pstLSCCalibParam); + +/********************************************************************//** + * @~chinese + * @brief LSCУ + * @param handle [IN] 豸 + * @param pstLSCCorrectParam [IN] У + * @return ɹMV_OK󣬷ش + + * @~english + * @brief LSC Correct + * @param handle [IN] Device handle + * @param pstLSCCorrectParam [IN] LSC Correct parameter structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_LSCCorrect(IN void* handle, IN OUT MV_CC_LSC_CORRECT_PARAM* pstLSCCorrectParam); + +/************************************************************************ + * @fn MV_GIGE_ForceIp + * @brief ǿIPýӿã MV_GIGE_ForceIpExӿڣ + * @param handle豸 + * @param nIP [IN] õIP + * @return ش + + * @fn MV_GIGE_ForceIp + * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) + * @param handle Handle + * @param nIP [IN] IP to set + * @return Refer to error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIp(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CC_RegisterEventCallBack + * @brief ע¼صýӿã MV_CC_RegisterEventCallBackExӿڣýӿֻ֧豸֧UںGenTL豸 + * @param handle豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ش + + * @fn MV_CC_RegisterEventCallBack + * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the MV_CC_RegisterEventCallBackEx interface)only support GEV devicesdont support USB and GenTL Device. + * @param handle豸 + * @param cbEvent [IN] event callback pointer + * @param pUser [IN] User defined value + * @return ش +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBack(void* handle, void(__stdcall* cbEvent)(unsigned int nExternalEventId, void* pUser), void* pUser); + +/*********************************************************************** + * @fn MV_CC_Display + * @brief ʾͼעʾڣڲԶʾMV_CC_GetImageBufferͬʱʹãMV_CC_DisplayOneFrameӿڣ + * @param handle [IN] + * @param hWnd [IN] ʾھ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_Display + * @brief Display one frame image, register display window, automatic display internally + * @param handle [IN] Handle + * @param hWnd [IN] Display Window Handle + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_Display(IN void* handle, void* hWnd); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief ȡIntegerֵMV_CC_GetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйԽṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief Get Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to get width + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE *pIntValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief IntegerֵMV_CC_SetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief Set Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to set width + * const unsigned int nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + + +/************************************************************************/ +/* ȡãģнӿѷʹܽӿڴ */ +/* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ +/************************************************************************/ +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȵϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰĿֵ + * unsigned int nMax; // ʾõĿֵ + * unsigned int nMin; // ʾСõĿֵ + * unsigned int nInc; // ʾõĿnIncıЧ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image width + * @param void* handle [IN] Camera Handle + * MVCC_INTVALUE* pstValue [IN][OUT] Returns the information structure pointer about the camera's width for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // Represents the current width value of the camera + * unsigned int nMax; // Indicates the maximum settable width value allowed by the camera + * unsigned int nMin; // Indicates the minimum settable width value allowed by the camera + * unsigned int nInc; // Indicates that the width increment set by the camera must be a multiple of nInc, otherwise it is invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other Integer structure parameters interface can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); +* @brief ͼ +* @param void* handle [IN] +* const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ +* @return ɹ,MV_OK,ȽΪӦֵʧ,ش + +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + * @brief Set image width + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] To set the value of the camera width, note that the width value must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface + * @return Success, return MV_OK, and the camera width will change to the corresponding value. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ߶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظй߶ȵϢṹָ + * @return ɹ,MV_OK,߶ϢصṹУʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image height + * @param void* handle [IN] Camera handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera height to user + * @return Success, return MV_OK, and return height information to the structure. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief ͼ߶ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ + * @return ɹ,MV_OK,߶ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief Set image height + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera height value to set, note that this value must be times of nInc of pstValue returned by MV_CC_GetWidth + * @return Success, return MV_OK, and the camera height will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼXƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйXƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image X offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera X offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief Set image X offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera X offset value to set + * @return Success, return MV_OK, and the camera X offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼYƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйYƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image Y offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera Y offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + * @brief Set image Y offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera Y offset value to set + * @return Success, return MV_OK, and the camera Y offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure lower limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure lower to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure lower limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure lower to set + * @return Success, return MV_OK, and the camera exposure time lower limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure upper limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure upper to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure upper limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure upper to set + * @return Success, return MV_OK, and the camera exposure time upper limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡֵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get brightness + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera brightness to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief ֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief Set brightness + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Brightness upper to set + * @return Success, return MV_OK, and the camera brightness value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ֡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظй֡ʵϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Frame Rate + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera frame rate to user + * The meaning of returns pstValue structure + * float fCurValue; // Indicates the current frame rate of the camera + * float fMax; // Indicates the maximum frame rate allowed by the camera + * float fMin; // Indicates the minimum frame rate allowed by the camera + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief Set frame rate + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Camera frame rate to set + * @return Success, return MV_OK, and camera frame rate will be changed to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gain + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to gain to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current gain + * float fMax; // The maximum gain camera allowed + * float fMin; // The minimum gain camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief Set Gain + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Gain value to set + * @return Success, return MV_OK, and the camera gain value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡعʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйعʱϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get exposure time + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to exposure time to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current exposure time + * float fMax; // The maximum exposure time camera allowed + * float fMin; // The minimum exposure time camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief عʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief Set exposure time + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Exposure time to set + * @return Success, return MV_OK, and the camera exposure time value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡظʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйظʽϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰظʽö,˵PixelType_Gvsp_Mono8, õֵ,ֵPixelType.hMvGvspPixelTypeö + * unsigned int nSupportedNum; // ֵ֧ظʽĸ + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // ֵ֧ظʽӦֵбҪظʽʱеһ֣Ч + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + öͲӿڿɲմ˽ӿڣйӦöͶӦֵPixelType.h CameraParams.hӦĶ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Pixel Format + * @param void* handle [IN] Camera Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Returns the information structure pointer about pixel format for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // The current pixel format of the camera, is the enumeration type, such as PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to MvGvspPixelType enumeration type in PixelType.h + * unsigned int nSupportedNum; // Number of pixel formats supported by the camera + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this list, otherwise invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Other interface of Enumeration structure parameters can refer to this interface, look for the corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõظʽӦֵô˽ӿʱֱдöֵMV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return ɹ,MV_OK,ظʽΪӦֵʧ,ش + * + * ҪõöͱGetӿڷصnSupportValue[MV_MAX_XML_SYMBOLIC_NUM]еһ֣ʧ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief Set Pixel Format + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] The corresponding integer value for pixel format to be set, when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return Success, return MV_OK, and the camera pixel format will change to the corresponding value. Failure, return error code + * + * Other interface of Enumeration structure parameters can refer to this interface, the enumeration type to be set must be one of the nSupportValue [MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it will fail + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡɼģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйزɼģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_ACQUISITION_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get acquisition mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of acquisition mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_ACQUISITION_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõIJɼģʽӦֵ + * @return ɹ,MV_OK,ɼģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief Set acquisition mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to acquisition mode + * @return Success, return MV_OK, and the camera acquisition mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAIN_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get gain mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gain mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAIN_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief ģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief Set gain mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gain mode + * @return Success, return MV_OK, and the camera gain mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶعģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶعģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_EXPOSURE_AUTO_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get auto exposure mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto exposure mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_EXPOSURE_AUTO_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Զعģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶعģʽӦֵ + * @return ɹ,MV_OK,ԶعģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Set auto exposure mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto exposure mode + * @return Success, return MV_OK, and the camera auto exposure mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief ôģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger mode + * @return Success, return MV_OK, and the camera trigger mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйʱϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get tigger delay + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of trigger delay + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief ôʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõʱ + * @return ɹ,MV_OK,ʱΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief Set tigger delay + * @param void* handle [IN] Handle + * const float fValue [IN] Trigger delay to set + * @return Success, return MV_OK, and the camera trigger delay will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԴ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشԴϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_SOURCE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger source + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger source + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief ôԴ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴԴӦֵ + * @return ɹ,MV_OK,ԴΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger source + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger source + * @return Success, return MV_OK, and the camera trigger source will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief һΣӿڽѡĴԴΪʱЧ + * @param void* handle [IN] + * @return ɹ,MV_OK, ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) + * @param void* handle [IN] Handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡGamma + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйGamma͵Ϣṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAMMA_SELECTOR + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Gamma mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gamma mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Gamma + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõGammaͶӦֵ + * @return ɹ,MV_OK,GammaͽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Set Gamma mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gamma mode + * @return Success, return MV_OK, and the camera gamma mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡGammaֵ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйGammaֵϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gamma value + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of gamma value + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Gammaֵ + * @param void* handle [IN] + * const float fValue [IN] ҪõGammaֵ + * @return ɹ,MV_OK,GammaֵΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Set Gamma value + * @param void* handle [IN] Handle + * const float fValue [IN] Gamma value to set + * @return Success, return MV_OK, and the camera gamma value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get sharpness + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of sharpness + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief Set sharpness + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Sharpness to set + * @return Success, return MV_OK, and the camera sharpness will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡҶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйҶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Hue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Hue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief ûҶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĻҶ + * @return ɹ,MV_OK,ҶȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief Set Hue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Hue to set + * @return Success, return MV_OK, and the camera Hue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Saturation + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Saturation + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief ñͶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõıͶ + * @return ɹ,MV_OK,ͶȽΪӦֵʧ,ش + +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief Set Saturation + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Saturation to set + * @return Success, return MV_OK, and the camera Saturation will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶƽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶƽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_BALANCEWHITE_AUTO + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Auto white balance + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto white balance + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Զƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶƽӦֵ + * @return ɹ,MV_OK,Զƽ⽫ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Set Auto white balance + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto white balance + * @return Success, return MV_OK, and the camera auto white balance will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance red + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance red + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ 콫ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance red + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance red to set + * @return Success, return MV_OK, and the camera white balance red will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ̽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance green + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance green + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ̽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance green + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance green to set + * @return Success, return MV_OK, and the camera white balance green will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance blue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance blue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance blue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance blue to set + * @return Success, return MV_OK, and the camera white balance blue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡˮӡϢڰϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйˮӡϢڰϢͽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get information type included by frame stamp + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of information type included by frame stamp + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief ˮӡϢڰϢ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõˮӡϢڰϢ + * @return ɹ,MV_OK,ˮӡϢڰϢͻΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief Set information type included by frame stamp + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Information type included by frame stamp to set + * @return Success, return MV_OK, and the camera information type included by frame stamp will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief ȡ豸Զ + * @param void* handle [IN] + * MVCC_STRINGVALUE* pstValue [IN OUT] ظйֽṹָ + * @return ɹ,MV_OK,һȡԶ֣ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief Get device user defined name + * @param void* handle [IN] Handle + * MVCC_STRINGVALUE* pstValue [IN OUT] Structure pointer of device name + * @return Success, return MV_OK, and get the camera user defined name. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief 豸Զ + * @param void* handle [IN] + * IN const char* chValue [IN] 豸 + * @return ɹ,MV_OK,豸Զ֣ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief Set device user defined name + * @param void* handle [IN] Handle + * IN const char* chValue [IN] Device name + * @return Success, return MV_OK, and set the camera user defined name. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡһδ֡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйһδ֡ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get frame number trigger by once + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of frame number trigger by once + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief һδ֡ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõһδ֡ + * @return ɹ,MV_OK,һδ֡ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief Set frame number trigger by once + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Frame number trigger by once to set + * @return Success, return MV_OK, and the camera frame number trigger by once will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƵṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get line rate + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of line rate + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Ƶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõƵ + * @return ɹ,MV_OK,ƵΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Set line rate + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Line rate to set + * @return Success, return MV_OK, and the camera line rate will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get heartbeat information + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of heartbeat information + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Ϣ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõϢ + * @return ɹ,MV_OK,ϢΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Set heartbeat information + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Heartbeat information to set + * @return Success, return MV_OK, and the camera heartbeat information will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡС + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйСṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet size + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet size + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief С + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõС + * @return ɹ,MV_OK,СΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet size + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet size to set + * @return Success, return MV_OK, and change packet size to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͼṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet sending delay + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet sending delay + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief ͼ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõͼ + * @return ɹ,MV_OK,ͼΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet sending delay + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet delay to set + * @return Success, return MV_OK, and change packet delay to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief ȡնIPַ0xa9fe0102 ʾ 169.254.1.2 + * @param void* handle [IN] + * @param unsigned int* pnIP [IN][OUT] ظ߽նIPַ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 + * @param void* handle [IN] Handle + * @param unsigned int* pnIP [IN][OUT] Receiver IP address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief ýնIPַ + * @param void* handle [IN] + * unsigned int nIP [IN] ҪõĽնIPַ + * @return ɹ,MV_OK,նIPַΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief Set receiver IP address + * @param void* handle [IN] Handel + * unsigned int nIP [IN] Receiver IP address to set + * @return Success, return MV_OK, and change receiver IP address to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief ȡͶ˵Ķ˿ں + * @param void* handle [IN] + * @param unsigned int* pnPort [IN][OUT] ظ߷Ͷ˵Ķ˿ں + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief Get transmitter port number + * @param void* handle [IN] Handle + * @param unsigned int* pnPort [IN][OUT] Transmitter port number + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief ÷Ͷ˵Ķ˿ں + * @param void* handle [IN] + * unsigned int nPort [IN] ҪõķͶ˵Ķ˿ں + * @return ɹ,MV_OK,Ͷ˵Ķ˿ںŻΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief Set transmitter port number + * @param void* handle [IN] Handle + * unsigned int nPort [IN] Transmitter port number to set + * @return Success, return MV_OK, and change transmitter port number to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_SetDeviceBaudrateӿڣ + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_SetDeviceBaudrate) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetDeviceBaudrateӿڣ + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetDeviceBaudrate) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBauderate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetSupportBaudratesӿڣ + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetSupportBaudrates) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBauderates(IN void* handle,unsigned int* pnBaudrateAblity); + + + +/********************************************************************//** + * @~chinese + * @brief ͼƬ֧BmpJpeg. + * @param handle [IN] 豸 + * @param pstSaveParam [IN][OUT] ͼƬṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתJPEGBMPȸʽָڴУȻûԽתֱ֮ӱͼƬļ + ýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ + MV_CC_SaveImageEx2MV_CC_SaveImageExӲhandleΪ˱֤ӿڵͳһ + + * @~english + * @brief Save image, support Bmp and Jpeg. + * @param handle [IN] Device handle + * @param pstSaveParam [IN][OUT] Save image parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Once there is image data, you can call this API to convert the data. + You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. + Comparing with the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx2(IN void* handle, MV_SAVE_IMAGE_PARAM_EX* pstSaveParam); + + +/********************************************************************//** + * @~chinese + * @brief ͼļ + * @param handle [IN] 豸 + * @param pstSaveFileParam [IN][OUT] ͼƬļṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧BMP/JPEG/PNG/TIFF + + * @~english + * @brief Save the image file. + * @param handle [IN] Device handle + * @param pstSaveFileParam [IN][OUT] Save the image file parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support BMP/JPEG/PNG/TIFF. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageToFile(IN void* handle, MV_SAVE_IMG_TO_FILE_PARAM* pstSaveFileParam); + + +/********************************************************************//** + * @~chinese + * @brief ظʽת + * @param handle [IN] 豸 + * @param pstCvtParam [IN][OUT] ظʽתṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתûظʽָڴС + ýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûص + ȡһ֡ͼݣȻͨýӿתʽ豸ǰɼͼJPEGѹĸʽֵ֧øýӿڽת + + * @~english + * @brief Pixel format conversion + * @param handle [IN] Device handle + * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. + There is no order requirement to call this API, the transformation will execute when there is image data. + First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, + then call this API to transform the format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ConvertPixelType(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam); + +/********************************************************************//** +* @~chinese +* @brief SDK־· +* @param strSDKLogPath [IN] SDK־· +* @return ɹMV_OK󣬷ش +* @remarks ·֮󣬿ָ·־, V2.4.1汾־񣬿֮ýӿЧĬ־Ϊ״̬ + +* @~english +* @brief Set SDK log path +* @param strSDKLogPath [IN] SDK log path +* @return Access, return true. Not access, return false +* @remarks For version V2.4.1, added log service, this API is invalid when the service is enabled.And The logging service is enabled by default + This API is used to set the log file storing path. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSDKLogPath(IN const char * strSDKLogPath); + + +#ifdef __cplusplus +} +#endif + +#endif //_MV_OBSOLETE_INTERFACES_H_ diff --git a/hnurm_camera/include/hnurm_camera/ObsoleteCamParams.h b/hnurm_camera/include/hnurm_camera/ObsoleteCamParams.h new file mode 100755 index 0000000000000000000000000000000000000000..f59a260923f656e7f28c13d7b941b722f97f28c3 --- /dev/null +++ b/hnurm_camera/include/hnurm_camera/ObsoleteCamParams.h @@ -0,0 +1,612 @@ + +#ifndef _MV_OBSOLETE_CAM_PARAMS_H_ +#define _MV_OBSOLETE_CAM_PARAMS_H_ + +#include "PixelType.h" + +/// \~chinese ֡Ϣ \~english Output Frame Information +typedef struct _MV_FRAME_OUT_INFO_ +{ + unsigned short nWidth; ///< [OUT] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [OUT] \~chinese ͼ \~english Image Height + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel Type + + unsigned int nFrameNum; ///< [OUT] \~chinese ֡ \~english Frame Number + unsigned int nDevTimeStampHigh; ///< [OUT] \~chinese ʱ32λ \~english Timestamp high 32 bits + unsigned int nDevTimeStampLow; ///< [OUT] \~chinese ʱ32λ \~english Timestamp low 32 bits + unsigned int nReserved0; ///< [OUT] \~chinese 8ֽڶ \~english Reserved, 8-byte aligned + int64_t nHostTimeStamp; ///< [OUT] \~chinese ɵʱ \~english Host-generated timestamp + + unsigned int nFrameLen; + + unsigned int nLostPacket; // ֡ + unsigned int nReserved[2]; +}MV_FRAME_OUT_INFO; + +/// \~chinese ͼƬ \~english Save image type +typedef struct _MV_SAVE_IMAGE_PARAM_T_ +{ + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Input Data Pixel Format + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬС \~english Output Image Size + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + +}MV_SAVE_IMAGE_PARAM; + +typedef struct _MV_IMAGE_BASIC_INFO_ +{ + unsigned short nWidthValue; + unsigned short nWidthMin; + unsigned int nWidthMax; + unsigned int nWidthInc; + + unsigned int nHeightValue; + unsigned int nHeightMin; + unsigned int nHeightMax; + unsigned int nHeightInc; + + float fFrameRateValue; + float fFrameRateMin; + float fFrameRateMax; + + unsigned int enPixelType; ///< [OUT] \~chinese ǰظʽ \~english Current pixel format + unsigned int nSupportedPixelFmtNum; ///< [OUT] \~chinese ֵ֧ظʽ \~english Support pixel format + unsigned int enPixelList[MV_MAX_XML_SYMBOLIC_NUM]; + unsigned int nReserved[8]; + +}MV_IMAGE_BASIC_INFO; + + +/// \~chinese \~english Noise feature type +typedef enum _MV_CC_BAYER_NOISE_FEATURE_TYPE +{ + MV_CC_BAYER_NOISE_FEATURE_TYPE_INVALID = 0, ///< \~chinese Чֵ \~english Invalid + MV_CC_BAYER_NOISE_FEATURE_TYPE_PROFILE = 1, ///< \~chinese \~english Noise curve + MV_CC_BAYER_NOISE_FEATURE_TYPE_LEVEL = 2, ///< \~chinese ˮƽ \~english Noise level + MV_CC_BAYER_NOISE_FEATURE_TYPE_DEFAULT = 1, ///< \~chinese Ĭֵ \~english Default + +}MV_CC_BAYER_NOISE_FEATURE_TYPE; + +/// \~chinese BayerʽϢ \~english Denoise profile info +typedef struct _MV_CC_BAYER_NOISE_PROFILE_INFO_T_ +{ + unsigned int nVersion; ///< \~chinese 汾 \~english version + MV_CC_BAYER_NOISE_FEATURE_TYPE enNoiseFeatureType; ///< \~chinese \~english noise feature type + enum MvGvspPixelType enPixelType; ///< \~chinese ͼʽ \~english image format + int nNoiseLevel; ///< \~chinese ƽˮƽ \~english noise level + unsigned int nCurvePointNum; ///< \~chinese ߵ \~english curve point number + int* nNoiseCurve; ///< \~chinese \~english noise curve + int* nLumCurve; ///< \~chinese \~english luminance curve + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_NOISE_PROFILE_INFO; + +/// \~chinese BayerʽƲ \~english Bayer noise estimate param +typedef struct _MV_CC_BAYER_NOISE_ESTIMATE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(ڵ8) \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ(ڵ8) \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned int nNoiseThreshold; ///< [IN] \~chinese ֵ(0-4095) \~english Noise Threshold + + unsigned char* pCurveBuf; ///< [IN] \~chinese ڴ洢ߺߣҪⲿ䣬С4096 * sizeof(int) * 2 \~english Buffer used to store noise and brightness curves, size:4096 * sizeof(int) * 2) + MV_CC_BAYER_NOISE_PROFILE_INFO stNoiseProfile; ///< [OUT] \~chinese Ϣ \~english Denoise profile + + unsigned int nThreadNum; ///< [IN] \~chinese ߳0ʾ㷨ӲӦ1ʾ̣߳Ĭϣ1ʾ߳Ŀ \~english Thread number, 0 means that the library is adaptive to the hardware, 1 means single thread(Default value), Greater than 1 indicates the number of threads + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_NOISE_ESTIMATE_PARAM; + +/// \~chinese Bayerʽ \~english Bayer spatial Denoise param +typedef struct _MV_CC_BAYER_SPATIAL_DENOISE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(ڵ8) \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ(ڵ8) \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + MV_CC_BAYER_NOISE_PROFILE_INFO stNoiseProfile; ///< [IN] \~chinese Ϣ(Դ) \~english Denoise profile + unsigned int nDenoiseStrength; ///< [IN] \~chinese ǿ(0-100) \~english nDenoise Strength + unsigned int nSharpenStrength; ///< [IN] \~chinese ǿ(0-32) \~english Sharpen Strength + unsigned int nNoiseCorrect; ///< [IN] \~chinese Уϵ(0-1280) \~english Noise Correct + + unsigned int nThreadNum; ///< [IN] \~chinese ߳0ʾ㷨ӲӦ1ʾ̣߳Ĭϣ1ʾ߳Ŀ \~english Thread number, 0 means that the library is adaptive to the hardware, 1 means single thread(Default value), Greater than 1 indicates the number of threads + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_SPATIAL_DENOISE_PARAM; + +/// \~chinese CLUT \~english CLUT param +typedef struct _MV_CC_CLUT_PARAM_T_ +{ + bool bCLUTEnable; ///< [IN] \~chinese ǷCLUT \~english CLUT enable + unsigned int nCLUTScale; ///< [IN] \~chinese ϵ(2,65536) \~english Quantitative scale(Integer power of 2, <= 65536) + unsigned int nCLUTSize; ///< [IN] \~chinese CLUTС,Ŀǰ֧17 \~english CLUT size, currently only supports 17 + unsigned char* pCLUTBuf; ///< [IN] \~chinese CLUT \~english CLUT buffer + unsigned int nCLUTBufLen; ///< [IN] \~chinese CLUTС(nCLUTSize*nCLUTSize*nCLUTSize*sizeof(int)*3) \~english CLUT buffer length(nCLUTSize*nCLUTSize*nCLUTSize*sizeof(int)*3) + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_CLUT_PARAM; + +/// \~chinese 񻯽ṹ \~english Sharpen structure +typedef struct _MV_CC_SHARPEN_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(С8) \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶(С8) \~english Image Height + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݴС \~english Input data length + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + unsigned int nSharpenAmount; ///< [IN] \~chinese ȵǿȣ[0,500] \~english Sharpen amount,[0,500] // [nSharpenAmount ϣ ʹ nSharpenPosAmount & nSharpenNegAmount ] + unsigned int nSharpenRadius; ///< [IN] \~chinese ȵڰ뾶(뾶Խ󣬺ʱԽ)[1,21] \~english Sharpen radius(The larger the radius, the longer it takes),[1,21] + unsigned int nSharpenThreshold; ///< [IN] \~chinese ȵֵ[0,255] \~english Sharpen threshold,[0,255] + + + unsigned int nSharpenPosAmount; // [IN] ȵǿȣΧ:[0, 500] + unsigned int nSharpenNegAmount; // [IN] ȵڸǿȣΧ:[0, 500] + + unsigned int nRes[6]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_SHARPEN_PARAM; + +/// \~chinese ɫУṹ \~english Color correct structure +typedef struct _MV_CC_COLOR_CORRECT_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶ \~english Image Height + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݴС \~english Input data length + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + unsigned int nImageBit; ///< [IN] \~chinese Чͼλ(8,10,12,16) \~english Image bit(8 or 10 or 12 or 16) + MV_CC_GAMMA_PARAM stGammaParam; ///< [IN] \~chinese GammaϢ \~english Gamma info + MV_CC_CCM_PARAM_EX stCCMParam; ///< [IN] \~chinese CCMϢ \~english CCM info + MV_CC_CLUT_PARAM stCLUTParam; ///< [IN] \~chinese CLUTϢ \~english CLUT info + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_COLOR_CORRECT_PARAM; + +/// \~chinese ROIṹ \~english Rect ROI structure +typedef struct _MV_CC_RECT_I_ +{ + unsigned int nX; ///< \~chinese ϽX \~english X Position + unsigned int nY; ///< \~chinese ϽY \~english Y Position + unsigned int nWidth; ///< \~chinese ο \~english Rect Width + unsigned int nHeight; ///< \~chinese θ߶ \~english Rect Height + +}MV_CC_RECT_I; + +/// \~chinese ƽṹ \~english Noise estimate structure +typedef struct _MV_CC_NOISE_ESTIMATE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(С8) \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶(С8) \~english Image Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݴС \~english Input data length + + MV_CC_RECT_I* pstROIRect; ///< [IN] \~chinese ͼROI \~english Image ROI + unsigned int nROINum; ///< [IN] \~chinese ROI \~english ROI number + + ///< \~chinese BayerƲMono8/RGBЧ \~english Bayer Noise estimate param,Mono8/RGB formats are invalid + unsigned int nNoiseThreshold; ///< [IN] \~chinese ֵ[0,4095] \~english Noise threshold[0,4095] + ///< \~chinese ֵ:8bit,0xE0;10bit,0x380;12bit,0xE00 \~english Suggestive value:8bit,0xE0;10bit,0x380;12bit,0xE00 + + unsigned char* pNoiseProfile; ///< [OUT] \~chinese \~english Output Noise Profile + unsigned int nNoiseProfileSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nNoiseProfileLen; ///< [OUT] \~chinese Գ \~english Output Noise Profile length + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_NOISE_ESTIMATE_PARAM; + +/// \~chinese ṹ \~english Spatial denoise structure +typedef struct _MV_CC_SPATIAL_DENOISE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(С8) \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶(С8) \~english Image Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݴС \~english Input data length + + unsigned char* pDstBuf; ///< [OUT] \~chinese \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + unsigned char* pNoiseProfile; ///< [IN] \~chinese \~english Input Noise Profile + unsigned int nNoiseProfileLen; ///< [IN] \~chinese Գ \~english Input Noise Profile length + + ///< \~chinese BayerMono8/RGBЧ \~english Bayer Spatial denoise param,Mono8/RGB formats are invalid + unsigned int nBayerDenoiseStrength; ///< [IN] \~chinese ǿ[0,100] \~english Denoise Strength[0,100] + unsigned int nBayerSharpenStrength; ///< [IN] \~chinese ǿ[0,32] \~english Sharpen Strength[0,32] + unsigned int nBayerNoiseCorrect; ///< [IN] \~chinese Уϵ[0,1280] \~english Noise Correct[0,1280] + + ///< \~chinese Mono8/RGBBayerЧ \~english Mono8/RGB Spatial denoise param,Bayer formats are invalid + unsigned int nNoiseCorrectLum; ///< [IN] \~chinese Уϵ[1,2000] \~english Noise Correct Lum[1,2000] + unsigned int nNoiseCorrectChrom; ///< [IN] \~chinese ɫУϵ[1,2000] \~english Noise Correct Chrom[1,2000] + unsigned int nStrengthLum; ///< [IN] \~chinese Ƚǿ[0,100] \~english Strength Lum[0,100] + unsigned int nStrengthChrom; ///< [IN] \~chinese ɫǿ[0,100] \~english Strength Chrom[0,100] + unsigned int nStrengthSharpen; ///< [IN] \~chinese ǿ[1,1000] \~english Strength Sharpen[1,1000] + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_SPATIAL_DENOISE_PARAM; + +/// \~chinese LSC궨ṹ \~english LSC calib structure +typedef struct _MV_CC_LSC_CALIB_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ[16,65535] \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶[16-65535] \~english Image Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݳ \~english Input data length + + unsigned char* pCalibBuf; ///< [OUT] \~chinese 궨 \~english Output calib buffer + unsigned int nCalibBufSize; ///< [IN] \~chinese ṩı궨С(nWidth*nHeight*sizeof(unsigned short)) \~english Provided output buffer size + unsigned int nCalibBufLen; ///< [OUT] \~chinese 궨泤 \~english Output calib buffer length + + unsigned int nSecNumW; ///< [IN] \~chinese ȷֿ \~english Width Sec num + unsigned int nSecNumH; ///< [IN] \~chinese ߶ȷֿ \~english Height Sec num + unsigned int nPadCoef; ///< [IN] \~chinese Եϵ[1,5] \~english Pad Coef[1,5] + unsigned int nCalibMethod; ///< [IN] \~chinese 궨ʽ(0-Ϊ׼;1-Ϊ׼;2-ĿΪ׼) \~english Calib method + unsigned int nTargetGray; ///< [IN] \~chinese Ŀ(궨ʽΪ2ʱЧ) \~english Target Gray + ///< \~chinese 8λ,Χ[0,255] \~english 8bit,range:[0,255] + ///< \~chinese 10λ,Χ[0,1023] \~english 10bit,range:[0,1023] + ///< \~chinese 12λ,Χ[0,4095] \~english 12bit,range:[0,4095] + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_LSC_CALIB_PARAM; + +/// \~chinese LSCУṹ \~english LSC correct structure +typedef struct _MV_CC_LSC_CORRECT_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ[16,65535] \~english Image Width + unsigned int nHeight; ///< [IN] \~chinese ͼ߶[16,65535] \~english Image Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcBufLen; ///< [IN] \~chinese ݳ \~english Input data length + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + unsigned char* pCalibBuf; ///< [IN] \~chinese 궨 \~english Input calib buffer + unsigned int nCalibBufLen; ///< [IN] \~chinese 궨泤 \~english Input calib buffer length + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_LSC_CORRECT_PARAM; + +/// \~chinese ijڵӦӽڵֵ \~english The maximum number of child nodes corresponding to a node +#define MV_MAX_XML_NODE_NUM_C 128 + +/// \~chinese ڵַ󳤶 \~english The maximum length of node name string +#define MV_MAX_XML_NODE_STRLEN_C 64 + +/// \~chinese ڵStringֵ󳤶 \~english The maximum length of Node String +#define MV_MAX_XML_STRVALUE_STRLEN_C 64 + +/// \~chinese ڵֶ󳤶 \~english The maximum length of the node description field +#define MV_MAX_XML_DISC_STRLEN_C 512 + +/// \~chinese ĵԪ \~english The maximum number of units +#define MV_MAX_XML_ENTRY_NUM 10 + +/// \~chinese ڵ \~english The maximum number of parent nodes +#define MV_MAX_XML_PARENTS_NUM 8 + +/// \~chinese ÿѾʵֵԪƳ \~english The length of the name of each unit that has been implemented +#define MV_MAX_XML_SYMBOLIC_STRLEN_C 64 + +enum MV_XML_Visibility +{ + V_Beginner = 0, ///< Always visible + V_Expert = 1, ///< Visible for experts or Gurus + V_Guru = 2, ///< Visible for Gurus + V_Invisible = 3, ///< Not Visible + V_Undefined = 99 ///< Object is not yet initialized +}; + +/// \~chinese ڵ | en:Single Node Basic Attributes +typedef struct _MV_XML_NODE_FEATURE_ +{ + enum MV_XML_InterfaceType enType; ///< \~chinese ڵ \~english Node Type + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Is visibility + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + unsigned int nReserved[4]; +}MV_XML_NODE_FEATURE; + +/// \~chinese ڵб | en:Node List +typedef struct _MV_XML_NODES_LIST_ +{ + unsigned int nNodeNum; ///< \~chinese ڵ \~english Node Number + MV_XML_NODE_FEATURE stNodes[MV_MAX_XML_NODE_NUM_C]; +}MV_XML_NODES_LIST; + +typedef struct _MV_XML_FEATURE_Value_ +{ + enum MV_XML_InterfaceType enType; ///< \~chinese ڵ \~english Node Type + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + unsigned int nReserved[4]; +}MV_XML_FEATURE_Value; + +typedef struct _MV_XML_FEATURE_Base_ +{ + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode +}MV_XML_FEATURE_Base; + +typedef struct _MV_XML_FEATURE_Integer_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + int64_t nMinValue; ///< \~chinese Сֵ \~english Min Value + int64_t nMaxValue; ///< \~chinese ֵ \~english Max Value + int64_t nIncrement; ///< \~chinese \~english Increment + + unsigned int nReserved[4]; + +}MV_XML_FEATURE_Integer; + +typedef struct _MV_XML_FEATURE_Boolean_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + bool bValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Boolean; + +typedef struct _MV_XML_FEATURE_Command_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Command; + +typedef struct _MV_XML_FEATURE_Float_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + double dfValue; ///< \~chinese ǰֵ \~english Current Value + double dfMinValue; ///< \~chinese Сֵ \~english Min Value + double dfMaxValue; ///< \~chinese ֵ \~english Max Value + double dfIncrement; ///< \~chinese \~english Increment + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Float; + +typedef struct _MV_XML_FEATURE_String_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + char strValue[MV_MAX_XML_STRVALUE_STRLEN_C]; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_String; + +typedef struct _MV_XML_FEATURE_Register_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nAddrValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Register; + +typedef struct _MV_XML_FEATURE_Category_ +{ + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Category; + +typedef struct _MV_XML_FEATURE_EnumEntry_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + int bIsImplemented; + int nParentsNum; + MV_XML_NODE_FEATURE stParentsList[MV_MAX_XML_PARENTS_NUM]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int nReserved[8]; + +}MV_XML_FEATURE_EnumEntry; + +typedef struct _MV_XML_FEATURE_Enumeration_ +{ + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + int nSymbolicNum; ///< \~chinese ymbolic \~english Symbolic Number + char strCurrentSymbolic[MV_MAX_XML_SYMBOLIC_STRLEN_C];///< \~chinese ǰSymbolic \~english Current Symbolic Index + char strSymbolic[MV_MAX_XML_SYMBOLIC_NUM][MV_MAX_XML_SYMBOLIC_STRLEN_C]; + enum MV_XML_AccessMode enAccessMode; ////< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Enumeration; + +typedef struct _MV_XML_FEATURE_Port_ +{ + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Port; + +typedef struct _MV_XML_CAMERA_FEATURE_ +{ + enum MV_XML_InterfaceType enType; + union + { + MV_XML_FEATURE_Integer stIntegerFeature; + MV_XML_FEATURE_Float stFloatFeature; + MV_XML_FEATURE_Enumeration stEnumerationFeature; + MV_XML_FEATURE_String stStringFeature; + }SpecialFeature; + +}MV_XML_CAMERA_FEATURE; + + + +/// \~chinese ͼƬ \~english Save Image Parameters +typedef struct _MV_SAVE_IMAGE_PARAM_T_EX_ +{ + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݳ \~english Input Data length + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Input Data Pixel Format + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬ \~english Output Image length + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + unsigned int nJpgQuality; ///< [IN] \~chinese JPG(50-99]ʽЧ \~english Encoding quality(50-99]Other formats are invalid + + + unsigned int iMethodValue; ///< [IN] \~chinese ֵ 0- 1- 2-ţֵĬΪţ 3-+ \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal 3-Optimal+ + + unsigned int nReserved[3]; ///< \~chinese Ԥ \~english Reserved + +}MV_SAVE_IMAGE_PARAM_EX; + + + +/// \~chinese ͼƬ \~english Save Image Parameters +typedef struct _MV_SAVE_IMG_TO_FILE_PARAM_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chineseݵظʽ \~english The pixel format of the input data + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݳ \~english Input Data length + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Input Image Format + unsigned int nQuality; ///< [IN] \~chinese JPG(50-99]ʽЧ \~english JPG Encoding quality(50-99],Other formats are invalid + char pImagePath[256]; ///< [IN] \~chinese ļ· \~english Input file path + + int iMethodValue; ///< [IN] \~chinese ֵ 0- 1- 2-ţֵĬΪţ 3-+ \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal 3-Optimal+ + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_SAVE_IMG_TO_FILE_PARAM; + + +// \~chinese תṹ \~english Pixel convert structure +typedef struct _MV_CC_PIXEL_CONVERT_PARAM_ +{ + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Height + + enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese Դظʽ \~english Source pixel format + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݳ \~english Input data length + + enum MvGvspPixelType enDstPixelType; ///< [IN] \~chinese Ŀظʽ \~english Destination pixel format + unsigned char* pDstBuffer; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstLen; ///< [OUT] \~chinese ݳ \~english Output data length + unsigned int nDstBufferSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + + unsigned int nRes[4]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_PIXEL_CONVERT_PARAM; + + + + +#endif /* _MV_OBSOLETE_CAM_PARAMS_H_ */ diff --git a/hnurm_camera/include/hnurm_camera/PixelType.h b/hnurm_camera/include/hnurm_camera/PixelType.h index d7eccb3bcc22fc3c0d883c73be3eadf29577711d..f5e905f5ab3d5ed3adba229401fffef224ef42fa 100755 --- a/hnurm_camera/include/hnurm_camera/PixelType.h +++ b/hnurm_camera/include/hnurm_camera/PixelType.h @@ -2,159 +2,194 @@ #ifndef _MV_PIXEL_TYPE_H_ #define _MV_PIXEL_TYPE_H_ -// #include "Base/GCTypes.h" - /************************************************************************/ /* GigE Vision (2.0.03) PIXEL FORMATS */ /************************************************************************/ // Indicate if pixel is monochrome or RGB -#define MV_GVSP_PIX_MONO 0x01000000 -#define MV_GVSP_PIX_RGB 0x02000000 // deprecated in version 1.1 -#define MV_GVSP_PIX_COLOR 0x02000000 -#define MV_GVSP_PIX_CUSTOM 0x80000000 -#define MV_GVSP_PIX_COLOR_MASK 0xFF000000 +#define MV_GVSP_PIX_MONO 0x01000000 +#define MV_GVSP_PIX_RGB 0x02000000 // deprecated in version 1.1 +#define MV_GVSP_PIX_COLOR 0x02000000 +#define MV_GVSP_PIX_CUSTOM 0x80000000 +#define MV_GVSP_PIX_COLOR_MASK 0xFF000000 // Indicate effective number of bits occupied by the pixel (including padding). // This can be used to compute amount of memory required to store an image. -#define MV_PIXEL_BIT_COUNT(n) ((n) << 16) +#define MV_PIXEL_BIT_COUNT(n) ((n) << 16) -#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_MASK 0x00FF0000 -#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_SHIFT 16 +#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_MASK 0x00FF0000 +#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_SHIFT 16 // Pixel ID: lower 16-bit of the pixel formats -#define MV_GVSP_PIX_ID_MASK 0x0000FFFF -#define MV_GVSP_PIX_COUNT 0x46 // next Pixel ID available +#define MV_GVSP_PIX_ID_MASK 0x0000FFFF +#define MV_GVSP_PIX_COUNT 0x46 // next Pixel ID available enum MvGvspPixelType { - -// Undefined pixel type + // Undefined pixel type #ifdef WIN32 - PixelType_Gvsp_Undefined = 0xFFFFFFFF, + PixelType_Gvsp_Undefined = 0xFFFFFFFF, + #else - PixelType_Gvsp_Undefined = -1, + PixelType_Gvsp_Undefined = -1, + #endif // Mono buffer format defines - PixelType_Gvsp_Mono1p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(1) | 0x0037), - PixelType_Gvsp_Mono2p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(2) | 0x0038), - PixelType_Gvsp_Mono4p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(4) | 0x0039), - PixelType_Gvsp_Mono8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), - PixelType_Gvsp_Mono8_Signed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0002), - PixelType_Gvsp_Mono10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), - PixelType_Gvsp_Mono10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), - PixelType_Gvsp_Mono12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), - PixelType_Gvsp_Mono12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), - PixelType_Gvsp_Mono14 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0025), - PixelType_Gvsp_Mono16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), - - // Bayer buffer format defines - PixelType_Gvsp_BayerGR8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), - PixelType_Gvsp_BayerRG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), - PixelType_Gvsp_BayerGB8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), - PixelType_Gvsp_BayerBG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), - PixelType_Gvsp_BayerGR10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), - PixelType_Gvsp_BayerRG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), - PixelType_Gvsp_BayerGB10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), - PixelType_Gvsp_BayerBG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), - PixelType_Gvsp_BayerGR12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), - PixelType_Gvsp_BayerRG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), - PixelType_Gvsp_BayerGB12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), - PixelType_Gvsp_BayerBG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), - PixelType_Gvsp_BayerGR10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), - PixelType_Gvsp_BayerRG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), - PixelType_Gvsp_BayerGB10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), - PixelType_Gvsp_BayerBG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), - PixelType_Gvsp_BayerGR12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), - PixelType_Gvsp_BayerRG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), - PixelType_Gvsp_BayerGB12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), - PixelType_Gvsp_BayerBG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), - PixelType_Gvsp_BayerGR16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002E), - PixelType_Gvsp_BayerRG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002F), - PixelType_Gvsp_BayerGB16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0030), - PixelType_Gvsp_BayerBG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0031), - - // RGB Packed buffer format defines - PixelType_Gvsp_RGB8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), - PixelType_Gvsp_BGR8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), - PixelType_Gvsp_RGBA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), - PixelType_Gvsp_BGRA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), - PixelType_Gvsp_RGB10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0018), - PixelType_Gvsp_BGR10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0019), - PixelType_Gvsp_RGB12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001A), - PixelType_Gvsp_BGR12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001B), - PixelType_Gvsp_RGB16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033), - PixelType_Gvsp_RGB10V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001C), - PixelType_Gvsp_RGB10V2_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001D), - PixelType_Gvsp_RGB12V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(36) | 0X0034), - PixelType_Gvsp_RGB565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0035), - PixelType_Gvsp_BGR565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0X0036), - - // YUV Packed buffer format defines - PixelType_Gvsp_YUV411_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x001E), - PixelType_Gvsp_YUV422_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), - PixelType_Gvsp_YUV422_YUYV_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), - PixelType_Gvsp_YUV444_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0020), - PixelType_Gvsp_YCBCR8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003A), - PixelType_Gvsp_YCBCR422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003B), - PixelType_Gvsp_YCBCR422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0043), - PixelType_Gvsp_YCBCR411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003C), - PixelType_Gvsp_YCBCR601_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003D), - PixelType_Gvsp_YCBCR601_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003E), - PixelType_Gvsp_YCBCR601_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0044), - PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003F), - PixelType_Gvsp_YCBCR709_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0040), - PixelType_Gvsp_YCBCR709_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0041), - PixelType_Gvsp_YCBCR709_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0045), - PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x0042), - - // RGB Planar buffer format defines - PixelType_Gvsp_RGB8_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0021), - PixelType_Gvsp_RGB10_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0022), - PixelType_Gvsp_RGB12_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0023), - PixelType_Gvsp_RGB16_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0024), - - // 自定义的图片格式 - PixelType_Gvsp_Jpeg = (MV_GVSP_PIX_CUSTOM | MV_PIXEL_BIT_COUNT(24) | 0x0001), - - PixelType_Gvsp_Coord3D_ABC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C0), // 0x026000C0 - PixelType_Gvsp_Coord3D_ABC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C1), // 0x026000C1 - - // 该值被废弃,请参考PixelType_Gvsp_Coord3D_AC32f_64; the value is discarded - PixelType_Gvsp_Coord3D_AC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(40) | 0x00C2), - // 该值被废弃; the value is discarded (已放入Chunkdata) - PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(28) | 0x0001), - - PixelType_Gvsp_Coord3D_ABC32 - = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x3001), // 0x82603001 - PixelType_Gvsp_Coord3D_AB32f - = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3002), // 0x82403002 - PixelType_Gvsp_Coord3D_AB32 - = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3003), // 0x82403003 - PixelType_Gvsp_Coord3D_AC32f_64 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C2), // 0x024000C2 - PixelType_Gvsp_Coord3D_AC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C3), // 0x024000C3 - PixelType_Gvsp_Coord3D_AC32 - = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3004), // 0x82403004 - PixelType_Gvsp_Coord3D_A32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BD), // 0x012000BD - PixelType_Gvsp_Coord3D_A32 - = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3005), // 0x81203005 - PixelType_Gvsp_Coord3D_C32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BF), // 0x012000BF - PixelType_Gvsp_Coord3D_C32 - = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3006), // 0x81203006 - - PixelType_Gvsp_Coord3D_ABC16 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x00B9), // 0x023000B9 + PixelType_Gvsp_Mono1p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(1) | 0x0037), + PixelType_Gvsp_Mono2p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(2) | 0x0038), + PixelType_Gvsp_Mono4p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(4) | 0x0039), + PixelType_Gvsp_Mono8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), + PixelType_Gvsp_Mono8_Signed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0002), + PixelType_Gvsp_Mono10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), + PixelType_Gvsp_Mono10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), + PixelType_Gvsp_Mono12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), + PixelType_Gvsp_Mono12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), + PixelType_Gvsp_Mono14 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0025), + PixelType_Gvsp_Mono16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), + + // Bayer buffer format defines + PixelType_Gvsp_BayerGR8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), + PixelType_Gvsp_BayerRG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), + PixelType_Gvsp_BayerGB8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), + PixelType_Gvsp_BayerBG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), + PixelType_Gvsp_BayerRBGG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0046), + PixelType_Gvsp_BayerGR10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), + PixelType_Gvsp_BayerRG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), + PixelType_Gvsp_BayerGB10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), + PixelType_Gvsp_BayerBG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), + PixelType_Gvsp_BayerGR12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), + PixelType_Gvsp_BayerRG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), + PixelType_Gvsp_BayerGB12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), + PixelType_Gvsp_BayerBG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), + PixelType_Gvsp_BayerGR10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), + PixelType_Gvsp_BayerRG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), + PixelType_Gvsp_BayerGB10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), + PixelType_Gvsp_BayerBG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), + PixelType_Gvsp_BayerGR12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), + PixelType_Gvsp_BayerRG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), + PixelType_Gvsp_BayerGB12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), + PixelType_Gvsp_BayerBG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), + PixelType_Gvsp_BayerGR16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002E), + PixelType_Gvsp_BayerRG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002F), + PixelType_Gvsp_BayerGB16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0030), + PixelType_Gvsp_BayerBG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0031), + + // RGB Packed buffer format defines + PixelType_Gvsp_RGB8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), + PixelType_Gvsp_BGR8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), + PixelType_Gvsp_RGBA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), + PixelType_Gvsp_BGRA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), + PixelType_Gvsp_RGB10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0018), + PixelType_Gvsp_BGR10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0019), + PixelType_Gvsp_RGB12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001A), + PixelType_Gvsp_BGR12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001B), + PixelType_Gvsp_RGB16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033), + PixelType_Gvsp_BGR16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x004B), + PixelType_Gvsp_RGBA16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x0064), + PixelType_Gvsp_BGRA16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x0051), + PixelType_Gvsp_RGB10V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001C), + PixelType_Gvsp_RGB10V2_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001D), + PixelType_Gvsp_RGB12V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(36) | 0X0034), + PixelType_Gvsp_RGB565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0035), + PixelType_Gvsp_BGR565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0X0036), + + // YUV Packed buffer format defines + PixelType_Gvsp_YUV411_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x001E), + PixelType_Gvsp_YUV422_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), + PixelType_Gvsp_YUV422_YUYV_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), + PixelType_Gvsp_YUV444_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0020), + PixelType_Gvsp_YCBCR8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003A), + PixelType_Gvsp_YCBCR422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003B), + PixelType_Gvsp_YCBCR422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0043), + PixelType_Gvsp_YCBCR411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003C), + PixelType_Gvsp_YCBCR601_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003D), + PixelType_Gvsp_YCBCR601_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003E), + PixelType_Gvsp_YCBCR601_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0044), + PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003F), + PixelType_Gvsp_YCBCR709_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0040), + PixelType_Gvsp_YCBCR709_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0041), + PixelType_Gvsp_YCBCR709_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0045), + PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x0042), + + // YUV420 + PixelType_Gvsp_YUV420SP_NV12 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x8001), + PixelType_Gvsp_YUV420SP_NV21 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x8002), + + // RGB Planar buffer format defines + PixelType_Gvsp_RGB8_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0021), + PixelType_Gvsp_RGB10_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0022), + PixelType_Gvsp_RGB12_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0023), + PixelType_Gvsp_RGB16_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0024), + + // ԶͼƬʽ + PixelType_Gvsp_Jpeg = (MV_GVSP_PIX_CUSTOM | MV_PIXEL_BIT_COUNT(24) | 0x0001), + + PixelType_Gvsp_Coord3D_ABC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C0),//0x026000C0 + PixelType_Gvsp_Coord3D_ABC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C1),//0x026000C1 + + // ֵοPixelType_Gvsp_Coord3D_AC32f_64; the value is discarded + PixelType_Gvsp_Coord3D_AC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(40) | 0x00C2), + // ֵ; the value is discarded (ѷChunkdata) + PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(28) | 0x0001), + + PixelType_Gvsp_Coord3D_ABC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x3001),//0x82603001 + PixelType_Gvsp_Coord3D_AB32f = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3002),//0x82403002 + PixelType_Gvsp_Coord3D_AB32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3003),//0x82403003 + PixelType_Gvsp_Coord3D_AC32f_64 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C2),//0x024000C2 + PixelType_Gvsp_Coord3D_AC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C3),//0x024000C3 + PixelType_Gvsp_Coord3D_AC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3004),//0x82403004 + PixelType_Gvsp_Coord3D_A32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BD),//0x012000BD + PixelType_Gvsp_Coord3D_A32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3005),//0x81203005 + PixelType_Gvsp_Coord3D_C32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BF),//0x012000BF + PixelType_Gvsp_Coord3D_C32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3006),//0x81203006 + PixelType_Gvsp_Coord3D_ABC16 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x00B9),//0x023000B9 + PixelType_Gvsp_Coord3D_C16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x00B8),//0x011000B8 + + PixelType_Gvsp_Float32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x0001),//0x81200001 + + //ѹظʽ + PixelType_Gvsp_HB_Mono8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), + PixelType_Gvsp_HB_Mono10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), + PixelType_Gvsp_HB_Mono10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), + PixelType_Gvsp_HB_Mono12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), + PixelType_Gvsp_HB_Mono12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), + PixelType_Gvsp_HB_Mono16 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), + PixelType_Gvsp_HB_BayerGR8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), + PixelType_Gvsp_HB_BayerRG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), + PixelType_Gvsp_HB_BayerGB8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), + PixelType_Gvsp_HB_BayerBG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), + PixelType_Gvsp_HB_BayerRBGG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0046), + PixelType_Gvsp_HB_BayerGR10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), + PixelType_Gvsp_HB_BayerRG10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), + PixelType_Gvsp_HB_BayerGB10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), + PixelType_Gvsp_HB_BayerBG10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), + PixelType_Gvsp_HB_BayerGR12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), + PixelType_Gvsp_HB_BayerRG12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), + PixelType_Gvsp_HB_BayerGB12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), + PixelType_Gvsp_HB_BayerBG12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), + PixelType_Gvsp_HB_BayerGR10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), + PixelType_Gvsp_HB_BayerRG10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), + PixelType_Gvsp_HB_BayerGB10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), + PixelType_Gvsp_HB_BayerBG10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), + PixelType_Gvsp_HB_BayerGR12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), + PixelType_Gvsp_HB_BayerRG12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), + PixelType_Gvsp_HB_BayerGB12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), + PixelType_Gvsp_HB_BayerBG12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), + PixelType_Gvsp_HB_YUV422_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), + PixelType_Gvsp_HB_YUV422_YUYV_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), + PixelType_Gvsp_HB_RGB8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), + PixelType_Gvsp_HB_BGR8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), + PixelType_Gvsp_HB_RGBA8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), + PixelType_Gvsp_HB_BGRA8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), + PixelType_Gvsp_HB_RGB16_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033), + PixelType_Gvsp_HB_BGR16_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x004B), + PixelType_Gvsp_HB_RGBA16_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x0064), + PixelType_Gvsp_HB_BGRA16_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x0051), }; -// enum MvUsbPixelType -//{ -// -// }; - -// 跨平台定义 -// Cross Platform Definition #ifdef WIN32 -typedef __int64 int64_t; +typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else #include diff --git a/hnurm_camera/include/hnurm_camera/camera_node.hpp b/hnurm_camera/include/hnurm_camera/camera_node.hpp index 028c8618b3a8b60b5fba31b4d77e24845213274b..ed0e3405c14cb0a2f8a331e63511d2be0d94831a 100644 --- a/hnurm_camera/include/hnurm_camera/camera_node.hpp +++ b/hnurm_camera/include/hnurm_camera/camera_node.hpp @@ -1,6 +1,9 @@ #pragma once #include "hnurm_camera/Camera.h" #include + +#include +#include #include namespace hnurm @@ -8,21 +11,31 @@ namespace hnurm class CameraNode : public rclcpp::Node { public: - CameraNode() : Node("camera_node"), cam_(nullptr), logger_(get_logger()) {}; - void run(); + explicit CameraNode(const rclcpp::NodeOptions &options) + : Node("camera_node", options), + cam_(nullptr), + logger_(get_logger()) {}; + CameraNode(const CameraNode &) = delete; CameraNode &operator=(const CameraNode &) = delete; CameraNode(CameraNode &&) = delete; CameraNode &operator=(CameraNode &&) = delete; - ~CameraNode() override = default; + void run(); + private: - rclcpp::Publisher::SharedPtr pub_; - rclcpp::TimerBase::SharedPtr timer_; - rclcpp::Logger logger_; + image_transport::Publisher pub_img_; + std::unique_ptr cam_info_; + // msgs + sensor_msgs::msg::Image img_msg_; + sensor_msgs::msg::CameraInfo cam_info_msg_; + + rclcpp::TimerBase::SharedPtr timer_; + rclcpp::Logger logger_; std::shared_ptr cam_; + std::thread capture_thread_; private: void timer_callback(); diff --git a/hnurm_camera/lib/linux/MvFGProducerCML.cti b/hnurm_camera/lib/linux/MvFGProducerCML.cti new file mode 100755 index 0000000000000000000000000000000000000000..3c2353e02241c0f8e8b6ac46b02a23af5640bd65 Binary files /dev/null and b/hnurm_camera/lib/linux/MvFGProducerCML.cti differ diff --git a/hnurm_camera/lib/linux/MvFGProducerCXP.cti b/hnurm_camera/lib/linux/MvFGProducerCXP.cti new file mode 100755 index 0000000000000000000000000000000000000000..6da8fbfd400245fd301c6fe19b7ba20405fd7d54 Binary files /dev/null and b/hnurm_camera/lib/linux/MvFGProducerCXP.cti differ diff --git a/hnurm_camera/lib/linux/MvFGProducerGEV.cti b/hnurm_camera/lib/linux/MvFGProducerGEV.cti new file mode 100755 index 0000000000000000000000000000000000000000..584fce86662829b91544fca17e4c01aedd449952 Binary files /dev/null and b/hnurm_camera/lib/linux/MvFGProducerGEV.cti differ diff --git a/hnurm_camera/lib/linux/MvFGProducerXoF.cti b/hnurm_camera/lib/linux/MvFGProducerXoF.cti new file mode 100755 index 0000000000000000000000000000000000000000..49577834b4103a1b0efdc38095667b188014550e Binary files /dev/null and b/hnurm_camera/lib/linux/MvFGProducerXoF.cti differ diff --git a/hnurm_camera/lib/linux/MvProducerGEV.cti b/hnurm_camera/lib/linux/MvProducerGEV.cti new file mode 100755 index 0000000000000000000000000000000000000000..07ab56402c04b048be6f36a5037c39c08dfb101f Binary files /dev/null and b/hnurm_camera/lib/linux/MvProducerGEV.cti differ diff --git a/hnurm_camera/lib/linux/MvProducerU3V.cti b/hnurm_camera/lib/linux/MvProducerU3V.cti new file mode 100755 index 0000000000000000000000000000000000000000..490f668a04affbb7c3a5a5a8ac439c6b98229205 Binary files /dev/null and b/hnurm_camera/lib/linux/MvProducerU3V.cti differ diff --git a/hnurm_camera/lib/linux/libCLAllSerial_gcc447_v3_0.so b/hnurm_camera/lib/linux/libCLAllSerial_gcc447_v3_0.so new file mode 100755 index 0000000000000000000000000000000000000000..24aa9a9c60eecd7fe9c85d627f0a50f42e18c8f1 Binary files /dev/null and b/hnurm_camera/lib/linux/libCLAllSerial_gcc447_v3_0.so differ diff --git a/hnurm_camera/lib/linux/libCLProtocol_gcc447_v3_0.so b/hnurm_camera/lib/linux/libCLProtocol_gcc447_v3_0.so new file mode 100755 index 0000000000000000000000000000000000000000..aee03e0858dae5c35827fe37ea3ffd70e5667888 Binary files /dev/null and b/hnurm_camera/lib/linux/libCLProtocol_gcc447_v3_0.so differ diff --git a/hnurm_camera/lib/linux/libCLSerCOM.so b/hnurm_camera/lib/linux/libCLSerCOM.so new file mode 100755 index 0000000000000000000000000000000000000000..669ada7db26f8a93d77dc78feab13a86dcc9f8ea Binary files /dev/null and b/hnurm_camera/lib/linux/libCLSerCOM.so differ diff --git a/hnurm_camera/lib/linux/libCLSerHvc.so b/hnurm_camera/lib/linux/libCLSerHvc.so new file mode 100755 index 0000000000000000000000000000000000000000..c4ff976ba4fdc6947b1545c42790d53f861473a7 Binary files /dev/null and b/hnurm_camera/lib/linux/libCLSerHvc.so differ diff --git a/hnurm_camera/lib/linux/libFormatConversion.so b/hnurm_camera/lib/linux/libFormatConversion.so index 10d4e0b49aa83e5aaccd46df60c7e43ab364c837..bb5f9cf42b4fd502adffd01dadf13f6f04de9fd6 100755 Binary files a/hnurm_camera/lib/linux/libFormatConversion.so and b/hnurm_camera/lib/linux/libFormatConversion.so differ diff --git a/hnurm_camera/lib/linux/libGCBase_gcc447_v3_0.so b/hnurm_camera/lib/linux/libGCBase_gcc447_v3_0.so new file mode 100755 index 0000000000000000000000000000000000000000..a657da3fddbc523b022e2fee64ce01e5a0f3ef9c Binary files /dev/null and b/hnurm_camera/lib/linux/libGCBase_gcc447_v3_0.so differ diff --git a/hnurm_camera/lib/linux/libGenCP_gcc447_v3_0.so b/hnurm_camera/lib/linux/libGenCP_gcc447_v3_0.so new file mode 100755 index 0000000000000000000000000000000000000000..cb28339f9e53873811ff3cf92fa0d9802d3b5755 Binary files /dev/null and b/hnurm_camera/lib/linux/libGenCP_gcc447_v3_0.so differ diff --git a/hnurm_camera/lib/linux/libLog_gcc447_v3_0.so b/hnurm_camera/lib/linux/libLog_gcc447_v3_0.so new file mode 100755 index 0000000000000000000000000000000000000000..b6979e72f17fb8472ab19e5e04acbc7c2c412eac Binary files /dev/null and b/hnurm_camera/lib/linux/libLog_gcc447_v3_0.so differ diff --git a/hnurm_camera/lib/linux/libMvCameraControl.so.3.2.0.3 b/hnurm_camera/lib/linux/libMVFGControl.so similarity index 43% rename from hnurm_camera/lib/linux/libMvCameraControl.so.3.2.0.3 rename to hnurm_camera/lib/linux/libMVFGControl.so index 64e393e91c710a29593c9234ddf5b54ba56e074e..6f02545af4e05cae87748bb210a56907237f96ed 100755 Binary files a/hnurm_camera/lib/linux/libMvCameraControl.so.3.2.0.3 and b/hnurm_camera/lib/linux/libMVFGControl.so differ diff --git a/hnurm_camera/lib/linux/libMVGigEVisionSDK.so b/hnurm_camera/lib/linux/libMVGigEVisionSDK.so deleted file mode 120000 index 34cfef6995cd3f1d07dcd1dc10d1bc7409345bcd..0000000000000000000000000000000000000000 --- a/hnurm_camera/lib/linux/libMVGigEVisionSDK.so +++ /dev/null @@ -1 +0,0 @@ -libMVGigEVisionSDK.so.3.2.0.3 \ No newline at end of file diff --git a/hnurm_camera/lib/linux/libMVGigEVisionSDK.so b/hnurm_camera/lib/linux/libMVGigEVisionSDK.so new file mode 100755 index 0000000000000000000000000000000000000000..3eaa489d05b7cebe8e6cc0b1f8fc0071ff7629ed Binary files /dev/null and b/hnurm_camera/lib/linux/libMVGigEVisionSDK.so differ diff --git a/hnurm_camera/lib/linux/libMVGigEVisionSDK.so.4.3.0.3 b/hnurm_camera/lib/linux/libMVGigEVisionSDK.so.4.3.0.3 new file mode 100755 index 0000000000000000000000000000000000000000..3eaa489d05b7cebe8e6cc0b1f8fc0071ff7629ed Binary files /dev/null and b/hnurm_camera/lib/linux/libMVGigEVisionSDK.so.4.3.0.3 differ diff --git a/hnurm_camera/lib/linux/libMVRender.so b/hnurm_camera/lib/linux/libMVRender.so index 464cd473fd40882265dbb5ecfb5fbe28a910cb66..a9c2224a66f095a42d72bdcb7ec04a433b4324ba 100755 Binary files a/hnurm_camera/lib/linux/libMVRender.so and b/hnurm_camera/lib/linux/libMVRender.so differ diff --git a/hnurm_camera/lib/linux/libMediaProcess.so b/hnurm_camera/lib/linux/libMediaProcess.so index 1e992665695bfe5adc0e204844e01fbf00e23187..c8a223a04141f70d0d5c94c4b2abc4a70f01f2c0 100755 Binary files a/hnurm_camera/lib/linux/libMediaProcess.so and b/hnurm_camera/lib/linux/libMediaProcess.so differ diff --git a/hnurm_camera/lib/linux/libMVGigEVisionSDK.so.3.2.0.3 b/hnurm_camera/lib/linux/libMvCamLVision.so similarity index 42% rename from hnurm_camera/lib/linux/libMVGigEVisionSDK.so.3.2.0.3 rename to hnurm_camera/lib/linux/libMvCamLVision.so index f2f434c20baee51715ffb1eb742bbd62092749aa..410fd8ec6b7a8459622c31e42453c8069578657e 100755 Binary files a/hnurm_camera/lib/linux/libMVGigEVisionSDK.so.3.2.0.3 and b/hnurm_camera/lib/linux/libMvCamLVision.so differ diff --git a/hnurm_camera/lib/linux/libMvUsb3vTL.so.3.2.0.3 b/hnurm_camera/lib/linux/libMvCamLVision.so.4.3.0.3 similarity index 41% rename from hnurm_camera/lib/linux/libMvUsb3vTL.so.3.2.0.3 rename to hnurm_camera/lib/linux/libMvCamLVision.so.4.3.0.3 index c7d85aff5a6f195a78ffaab07fb5edbe69b5fb5c..410fd8ec6b7a8459622c31e42453c8069578657e 100755 Binary files a/hnurm_camera/lib/linux/libMvUsb3vTL.so.3.2.0.3 and b/hnurm_camera/lib/linux/libMvCamLVision.so.4.3.0.3 differ diff --git a/hnurm_camera/lib/linux/libMvCameraControl.so b/hnurm_camera/lib/linux/libMvCameraControl.so deleted file mode 120000 index 52382b1a64970739c70c4ca85f65fbbfcbc04ac8..0000000000000000000000000000000000000000 --- a/hnurm_camera/lib/linux/libMvCameraControl.so +++ /dev/null @@ -1 +0,0 @@ -libMvCameraControl.so.3.2.0.3 \ No newline at end of file diff --git a/hnurm_camera/lib/linux/libMvCameraControl.so b/hnurm_camera/lib/linux/libMvCameraControl.so new file mode 100755 index 0000000000000000000000000000000000000000..c04b88e10a5ffe478043b21351175e6e27d2db05 Binary files /dev/null and b/hnurm_camera/lib/linux/libMvCameraControl.so differ diff --git a/hnurm_camera/lib/linux/libMvCameraControl.so.4.3.0.4 b/hnurm_camera/lib/linux/libMvCameraControl.so.4.3.0.4 new file mode 100755 index 0000000000000000000000000000000000000000..c04b88e10a5ffe478043b21351175e6e27d2db05 Binary files /dev/null and b/hnurm_camera/lib/linux/libMvCameraControl.so.4.3.0.4 differ diff --git a/hnurm_camera/lib/linux/libMvCameraControlWrapper.so b/hnurm_camera/lib/linux/libMvCameraControlWrapper.so new file mode 100755 index 0000000000000000000000000000000000000000..6177bcd56994e1f356907754df1e49954ca2c78f Binary files /dev/null and b/hnurm_camera/lib/linux/libMvCameraControlWrapper.so differ diff --git a/hnurm_camera/lib/linux/libMvCameraControlWrapper.so.4.3.0.3 b/hnurm_camera/lib/linux/libMvCameraControlWrapper.so.4.3.0.3 new file mode 100755 index 0000000000000000000000000000000000000000..6177bcd56994e1f356907754df1e49954ca2c78f Binary files /dev/null and b/hnurm_camera/lib/linux/libMvCameraControlWrapper.so.4.3.0.3 differ diff --git a/hnurm_camera/lib/linux/libMvUsb3vTL.so b/hnurm_camera/lib/linux/libMvUsb3vTL.so deleted file mode 120000 index 099cbdd66bbadbdc3891e4d8adaf01444b943282..0000000000000000000000000000000000000000 --- a/hnurm_camera/lib/linux/libMvUsb3vTL.so +++ /dev/null @@ -1 +0,0 @@ -libMvUsb3vTL.so.3.2.0.3 \ No newline at end of file diff --git a/hnurm_camera/lib/linux/libMvUsb3vTL.so b/hnurm_camera/lib/linux/libMvUsb3vTL.so new file mode 100755 index 0000000000000000000000000000000000000000..a2c684a9f3a685dc2e8fc969405eb5b62fd865bb Binary files /dev/null and b/hnurm_camera/lib/linux/libMvUsb3vTL.so differ diff --git a/hnurm_camera/lib/linux/libMvUsb3vTL.so.4.3.0.3 b/hnurm_camera/lib/linux/libMvUsb3vTL.so.4.3.0.3 new file mode 100755 index 0000000000000000000000000000000000000000..a2c684a9f3a685dc2e8fc969405eb5b62fd865bb Binary files /dev/null and b/hnurm_camera/lib/linux/libMvUsb3vTL.so.4.3.0.3 differ diff --git a/hnurm_camera/lib/linux/libavutil.so b/hnurm_camera/lib/linux/libavutil.so new file mode 100755 index 0000000000000000000000000000000000000000..1cb8dce2cda673a06b27ca3fd541988e4ca02d73 Binary files /dev/null and b/hnurm_camera/lib/linux/libavutil.so differ diff --git a/hnurm_camera/lib/linux/liblog4cpp_gcc447_v3_0.so b/hnurm_camera/lib/linux/liblog4cpp_gcc447_v3_0.so new file mode 100755 index 0000000000000000000000000000000000000000..2052b10d664d3ae3fcce56c8d24302dd12d5d96b Binary files /dev/null and b/hnurm_camera/lib/linux/liblog4cpp_gcc447_v3_0.so differ diff --git a/hnurm_camera/lib/linux/libswscale.so b/hnurm_camera/lib/linux/libswscale.so new file mode 100755 index 0000000000000000000000000000000000000000..b157b2ca97b7504d4ef7137dae8082b940cd313e Binary files /dev/null and b/hnurm_camera/lib/linux/libswscale.so differ diff --git a/hnurm_camera/lib/linux/libusb-1.0.so.0 b/hnurm_camera/lib/linux/libusb-1.0.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..a27578feba56c5c621be3727766b01d65bf76f80 Binary files /dev/null and b/hnurm_camera/lib/linux/libusb-1.0.so.0 differ diff --git a/hnurm_camera/package.xml b/hnurm_camera/package.xml index 2d922bfa26d60c8de4210c9570ee6f0559b654fb..35511b178947eb6b72c1060f1db29386d0252713 100644 --- a/hnurm_camera/package.xml +++ b/hnurm_camera/package.xml @@ -13,6 +13,8 @@ cv_bridge rclcpp sensor_msgs + image_transport + camera_info_manager ament_lint_auto ament_lint_common diff --git a/hnurm_camera/params/default.yaml b/hnurm_camera/params/default.yaml index a0bce9549d23bd9633bf1188595fa88a224924cc..dcd54ff4b81aa96a1570d8551e0008937555d790 100644 --- a/hnurm_camera/params/default.yaml +++ b/hnurm_camera/params/default.yaml @@ -2,19 +2,23 @@ ros__parameters: image_orientation: 0 # 图像宽度:步进16 - nWidth: 1280 + nWidth: 1440 # 图像高度:步进2 - nHeight: 720 + nHeight: 1080 # 水平偏移 nOffsetX: 0 # 垂直偏移 - nOffsetY: 152 + nOffsetY: 0 # 水平镜像 bReverseX: false # 垂直镜像 bReverseY: false # 像素格式 - nPixelFormat: 0x02180015 #0x0108000A + # 013: 0x0108000A bayer gb8 + # 013: 0x01100012 bayer gb12 + # 016: 0x01080009 bayer rg8 + # 016: 0x01100011 bayer rg12 + nPixelFormat: 0x1080009 # 水平合并 nBinningHorizontal: 1 # 垂直合并 @@ -32,16 +36,19 @@ # 曝光时间 fExposureTime: 3000.0000 #4000.0 # 增益 - fGain: 12.0000 + fGain: 16.0000 # 自动增益 nGainAuto: 0 # 黑电平 nBlackLevelValue: 30 # 黑电平使能 - bEnableBlackLevel: 1 + bEnableBlackLevel: false # 伽马校正 fGammaValue: 0.7 # 伽马校正使能 bEnableGamma: 1 + # Bayer转换质量 0: fast 3: best+ + nBayerCvtQuality: 3 + camera_img_topic: "image" diff --git a/hnurm_camera/src/Camera.cpp b/hnurm_camera/src/Camera.cpp index aba2227f3ae5c1f64295446ca3fffe81761099f1..4d2e665d1a33aadae03da61c0a2297041b9b7c0a 100755 --- a/hnurm_camera/src/Camera.cpp +++ b/hnurm_camera/src/Camera.cpp @@ -13,11 +13,11 @@ using namespace std; namespace hnurm { -HKcam::HKcam(std::shared_ptr node) : _node(node), _logger(node->get_logger()) +HKcam::HKcam(const std::shared_ptr &node) : _node(node), _logger(node->get_logger()) { - nRet = MV_OK; - handle = nullptr; - pData = nullptr; + nRet = MV_OK; + handle = nullptr; + pData = nullptr; init_params(); std::string camera_id = _node->declare_parameter("camera_id", ""); @@ -55,11 +55,16 @@ void HKcam::init_params() _fExposureTime = static_cast(_node->declare_parameter("fExposureTime", 5000.)); _fGain = static_cast(_node->declare_parameter("fGain", 8.)); _nBlackLevelValue = static_cast(_node->declare_parameter("nBlackLevelValue", 30)); - _bEnableBlackLevel = _node->declare_parameter("_bEnableBlackLevel", false); + _bEnableBlackLevel = _node->declare_parameter("bEnableBlackLevel", false); + _nBayerCvtQuality = static_cast(_node->declare_parameter("nBayerCvtQuality", 3)); + + MV_CC_SetBayerCvtQuality(handle, 3); } void HKcam::SetParam() { + MV_CC_SetEnumValue(handle, "ExposureMode", 1); + nRet = MV_CC_SetIntValue(handle, "Width", _nWidth); if(MV_OK == nRet) printf("set Width = %d OK!\n", _nWidth); @@ -318,7 +323,7 @@ bool HKcam::CloseCam() } } -bool HKcam::GetFrame(cv::Mat &img) +bool HKcam::GetFrame(std::vector &img) { nRet = MV_OK; // todo get time stamp for imu alignment @@ -329,26 +334,26 @@ bool HKcam::GetFrame(cv::Mat &img) { return false; } + img.resize(stImageInfo.nHeight * stImageInfo.nWidth * 3); + // convert bayer + prepare_convert(img.data()); - img = cv::Mat(stImageInfo.nHeight, stImageInfo.nWidth, CV_8UC3, pData); - // cvtColor(tmp_bayer, img.img, cv::COLOR_BayerGB2RGB); + // do conversion + nRet = MV_CC_ConvertPixelTypeEx(handle, &stConvertParam); - // 根据参数对img旋转 - switch(_nImageOrientation) - { - case 0: - break; - case 1: - cv::rotate(img, img, cv::ROTATE_90_CLOCKWISE); - break; - case 2: - cv::rotate(img, img, cv::ROTATE_180); - break; - case 3: - cv::rotate(img, img, cv::ROTATE_90_COUNTERCLOCKWISE); - break; - } return true; } +void HKcam::prepare_convert(uint8_t *dstData) +{ + stConvertParam.enSrcPixelType = stImageInfo.enPixelType; + stConvertParam.enDstPixelType = PixelType_Gvsp_BGR8_Packed; + stConvertParam.pSrcData = pData; + stConvertParam.nSrcDataLen = stImageInfo.nFrameLen; + stConvertParam.nWidth = stImageInfo.nWidth; + stConvertParam.nHeight = stImageInfo.nHeight; + stConvertParam.nDstBufferSize = stImageInfo.nWidth * stImageInfo.nHeight * 3; + stConvertParam.pDstBuffer = dstData; +} + } // namespace hnurm diff --git a/hnurm_camera/src/camera_node.cpp b/hnurm_camera/src/camera_node.cpp index 37dc7087c8a1ffe3b913f8cb5f7dc8eaaa545595..0fa9ef64695f3597b88cb95c1d5f2d042f91af79 100644 --- a/hnurm_camera/src/camera_node.cpp +++ b/hnurm_camera/src/camera_node.cpp @@ -10,29 +10,41 @@ void CameraNode::run() { RCLCPP_INFO(logger_, "CameraNode is running"); std::string camera_img_topic = this->declare_parameter("camera_img_topic", "image"); - cam_ = std::make_shared(shared_from_this()); - pub_ = create_publisher(camera_img_topic, rclcpp::SensorDataQoS()); - timer_ - = create_wall_timer(std::chrono::milliseconds(5), std::bind(&CameraNode::timer_callback, shared_from_this())); + cam_ = std::make_shared(shared_from_this()); + + pub_img_ = image_transport::create_publisher(this, camera_img_topic); + cam_info_ = std::make_unique(this, "camera"); + + capture_thread_ = std::thread([this]() { + while(rclcpp::ok()) + { + timer_callback(); + } + }); } void CameraNode::timer_callback() { - cv::Mat img; - static long long img_cnt = 0; - auto start = std::chrono::high_resolution_clock::now(); + std::vector img; + static long long img_cnt = 0; + static auto prev = this->now(); if(cam_->GetFrame(img)) { - std_msgs::msg::Header header; - header.frame_id = "camera"; - header.stamp = now(); - sensor_msgs::msg::Image::SharedPtr msg - = cv_bridge::CvImage(header, sensor_msgs::image_encodings::BGR8, img).toImageMsg(); - pub_->publish(*msg); - auto end = std::chrono::high_resolution_clock::now(); - std::chrono::duration duration = end - start; - float fps = 1/duration.count(); - RCLCPP_INFO(logger_, "FPS: %f", fps); + img_msg_.data = img; + img_msg_.header.stamp = now(); + img_msg_.header.frame_id = "camera"; + img_msg_.encoding = sensor_msgs::image_encodings::BGR8; + img_msg_.height = cam_->_nHeight; + img_msg_.width = cam_->_nWidth; + img_msg_.is_bigendian = 0; + img_msg_.step = cam_->_nWidth * 3; + + // pub_->publish(msg); + pub_img_.publish(img_msg_); + + auto now = this->now(); + RCLCPP_INFO(this->get_logger(), "Capture FPS: %f", 1.0 / (now - prev).seconds()); + prev = now; } } } \ No newline at end of file diff --git a/hnurm_camera/src/main.cpp b/hnurm_camera/src/main.cpp index 5e6f76a27fae4a6cb85aab0154f49ce983f285a1..906ff91b1c13bf7c4338a62ad1905770b88aa828 100644 --- a/hnurm_camera/src/main.cpp +++ b/hnurm_camera/src/main.cpp @@ -4,8 +4,9 @@ int main(int argc, char *argv[]) { rclcpp::init(argc, argv); - - auto node = std::make_shared(); + rclcpp::NodeOptions options; + options.use_intra_process_comms(true); + auto node = std::make_shared(options); node->run(); rclcpp::spin(node); rclcpp::shutdown(); diff --git a/hnurm_detect/CMakeLists.txt b/hnurm_detect/CMakeLists.txt index 7bcbf8826777ad44839462fdda822c43b3677c18..33d50844bb81af3750e86668baf40419451ed888 100644 --- a/hnurm_detect/CMakeLists.txt +++ b/hnurm_detect/CMakeLists.txt @@ -3,63 +3,17 @@ project(hnurm_detect) set(CMAKE_CXX_STANDARD 17) -find_package(ament_cmake REQUIRED) +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() -find_package(rclcpp REQUIRED) -find_package(cv_bridge REQUIRED) -find_package(sensor_msgs REQUIRED) -find_package(std_msgs REQUIRED) -find_package(message_filters REQUIRED) -find_package(rosidl_default_generators REQUIRED) +ament_auto_add_library(hnurm_detect src/detect_node.cpp src/detector.cpp src/number_classifier.cpp) -find_package(OpenCV REQUIRED) -find_package(Eigen3 REQUIRED) +ament_auto_add_executable(hnurm_detect_node src/main.cpp) +target_link_libraries(hnurm_detect_node hnurm_detect) -find_package(hnurm_uart REQUIRED) - -set(dependencies - rclcpp - cv_bridge - sensor_msgs - std_msgs - message_filters - hnurm_uart -) - -rosidl_generate_interfaces(${PROJECT_NAME} - msg/Light.msg - msg/Point2D32.msg - msg/ArmorType.msg - msg/Armor.msg - msg/ArmorArray.msg - DEPENDENCIES std_msgs sensor_msgs hnurm_uart +ament_auto_package( + INSTALL_TO_SHARE + launch + params + model ) - -rosidl_get_typesupport_target(cpp_typesupport_target - ${PROJECT_NAME} rosidl_typesupport_cpp) - -add_library(hnurm_detector SHARED src/detector.cpp src/number_classifier.cpp) -target_include_directories(hnurm_detector PUBLIC - $ - $) -ament_target_dependencies(hnurm_detector ${dependencies}) -target_link_libraries(hnurm_detector ${cpp_typesupport_target} Eigen3::Eigen ${OpenCV_LIBS}) - -add_executable(${PROJECT_NAME}_node src/main.cpp src/detect_node.cpp) -ament_target_dependencies(${PROJECT_NAME}_node ${dependencies}) -target_link_libraries(${PROJECT_NAME}_node hnurm_detector ${cpp_typesupport_target} Eigen3::Eigen ${OpenCV_LIBS}) - -install(TARGETS - hnurm_detector - DESTINATION lib -) -install(TARGETS - ${PROJECT_NAME}_node - DESTINATION lib/${PROJECT_NAME} -) -install(DIRECTORY - launch params model - DESTINATION share/${PROJECT_NAME} -) - -ament_package() diff --git a/hnurm_detect/include/hnurm_detect/armor.hpp b/hnurm_detect/include/hnurm_detect/armor.hpp index cd88d46005a64c173f0451f68aa8518acb1bd8e7..0e2c71136ef4c5c2c049a831a549729b3b44f695 100755 --- a/hnurm_detect/include/hnurm_detect/armor.hpp +++ b/hnurm_detect/include/hnurm_detect/armor.hpp @@ -16,7 +16,7 @@ namespace hnurm { const int RED = 0; const int BLUE = 1; -const int PURPLE=2; + enum ArmorType { SMALL = 0, @@ -29,7 +29,7 @@ struct Light : public cv::RotatedRect explicit Light(const cv::RotatedRect &box) : cv::RotatedRect(box) { - cv::Point2f p[4]; + box.points(p); std::sort(p, p + 4, [](const cv::Point2f &a, const cv::Point2f &b) { return a.y < b.y; }); top = (p[0] + p[1]) / 2; @@ -47,6 +47,7 @@ struct Light : public cv::RotatedRect double length; double width; float tilt_angle; + cv::Point2f p[4]; }; struct Armor @@ -71,10 +72,10 @@ struct Armor points2d[2] = right_light.bottom; points2d[3] = right_light.top; - points2d[4] = (left_light.top+right_light.top)/2; - points2d[5] = (left_light.top+left_light.bottom)/2; - points2d[6] = (left_light.bottom+right_light.bottom)/2; - points2d[7] = (right_light.bottom+right_light.top)/2; + points2d[4] = (left_light.top + right_light.top) / 2; + points2d[5] = (left_light.top + left_light.bottom) / 2; + points2d[6] = (left_light.bottom + right_light.bottom) / 2; + points2d[7] = (right_light.bottom + right_light.top) / 2; points2d[8] = center; } @@ -104,15 +105,16 @@ struct Armor std::string classification_result; ArmorType armor_type = ArmorType::SMALL; - // double distance_to_image_center{}; - // todo - // Eigen::Vector3d position; - // Eigen::Matrix3d rotation; - // Eigen::Matrix3d _r1;//相机坐标系到云台坐标系 - // Eigen::Matrix3d _r2;//先对pitch进行旋转 - // Eigen::Matrix3d _r3;//再对yaw的旋转,变为世界坐标系(pitch、yaw为0) - // Eigen::Matrix3d _rmat; - // Eigen::Vector3d _translation; + double distance_to_image_center {}; + // todo + Eigen::Vector3d position; + Eigen::Matrix3d rotation; + Eigen::Matrix3d _r1; // 相机坐标系到云台坐标系 + Eigen::Matrix3d _r2; // 先对pitch进行旋转 + Eigen::Matrix3d _r3; // 再对yaw的旋转,变为世界坐标系(pitch、yaw为0) + Eigen::Matrix3d _R; // 本体系到相机系 + Eigen::Matrix3d _rmat; + Eigen::Vector3d _translation; }; } // namespace hnurm diff --git a/hnurm_detect/include/hnurm_detect/detect_node.hpp b/hnurm_detect/include/hnurm_detect/detect_node.hpp index 95557b90d78d8e91fc87af760c82656d3c250c2c..6973fff53a746db932222a5c981e05497a1fc474 100644 --- a/hnurm_detect/include/hnurm_detect/detect_node.hpp +++ b/hnurm_detect/include/hnurm_detect/detect_node.hpp @@ -2,9 +2,10 @@ #include "hnurm_detect/detector.hpp" -#include -#include +#include +#include +#include #include #include @@ -16,7 +17,7 @@ namespace hnurm { -hnurm_detect::msg::Armor toROSMsg(const Armor &armor); +hnurm_interfaces::msg::Armor toROSMsg(const Armor &armor); class DetectNode : public rclcpp::Node { @@ -26,23 +27,25 @@ public: void init_params(); private: - void detect_callback(sensor_msgs::msg::Image::SharedPtr img_msg, - hnurm_uart::msg::VisionRecvData::SharedPtr uart_msg); + void detect_callback( + sensor_msgs::msg::Image::SharedPtr img_msg, hnurm_interfaces::msg::VisionRecvData::SharedPtr uart_msg + ); private: - using ApproximateTimePolicy - = message_filters::sync_policies::ApproximateTime; + using ApproximateTimePolicy = message_filters::sync_policies:: + ApproximateTime; // subs - std::shared_ptr> sub_img_; - std::shared_ptr> sub_uart_; - std::shared_ptr> sync_; + std::shared_ptr> sub_img_; + std::shared_ptr> sub_uart_; + std::shared_ptr> sync_; - rclcpp::Publisher::SharedPtr pub_res_img_; - rclcpp::Publisher::SharedPtr pub_num_img_; - rclcpp::Publisher::SharedPtr pub_bin_img_; - rclcpp::Publisher::SharedPtr pub_res_armor_; + image_transport::Publisher pub_res_img_; + image_transport::Publisher pub_num_img_; + image_transport::Publisher pub_bin_img_; + rclcpp::Publisher::SharedPtr pub_res_armor_; // debug pubs + bool pub_debug_info_ = true; rclcpp::Publisher::SharedPtr pub_detect_time_; // topics @@ -59,6 +62,5 @@ private: Detector::LightParams light_params_ {}; Detector::ArmorParams armor_params_ {}; Detector::ClassifierParams classifier_params_ {}; - }; } diff --git a/hnurm_detect/include/hnurm_detect/detector.hpp b/hnurm_detect/include/hnurm_detect/detector.hpp index 5c4812e72f1c617fb68748c542e01a23d3ac4503..47e66e941b4c1f0ae2d2e3e3b6a4c643250ec28e 100755 --- a/hnurm_detect/include/hnurm_detect/detector.hpp +++ b/hnurm_detect/include/hnurm_detect/detector.hpp @@ -91,6 +91,18 @@ private: int min_lightness {}; LightParams light_params {}; ArmorParams armor_params {}; + + cv::Point2d calculateMean(const std::vector &points); + + std::vector centralizeData(const std::vector &points, const cv::Point2d &mean); + + Eigen::Matrix2d calculateCovarianceMatrix(const std::vector ¢ralized); + + cv::Point2d performPCA(const std::vector &points, const cv::Point2d &mean); + + bool + computeLineIntersection(const cv::Point2d &p1, const cv::Point2d &p2, const cv::Point2d &p3, const cv::Point2d &p4, + cv::Point2d &intersection); }; } // namespace hnurm diff --git a/hnurm_detect/launch/hnurm_detect.launch.py b/hnurm_detect/launch/hnurm_detect.launch.py index d859b0d4ce678d0460c4c8caebf9f66c772e0a3f..a3222860c784948f0962701210e772bb6f3828af 100644 --- a/hnurm_detect/launch/hnurm_detect.launch.py +++ b/hnurm_detect/launch/hnurm_detect.launch.py @@ -10,6 +10,8 @@ def generate_launch_description(): detect_dir = get_package_share_directory('hnurm_detect') params_file = LaunchConfiguration('params_file') + print(detect_dir) + return LaunchDescription([ DeclareLaunchArgument( 'params_file', diff --git a/hnurm_detect/package.xml b/hnurm_detect/package.xml index 8688e9e51c81c6e7c66cbbdfd0a386bfc478bb65..d561300583b139f7b0ca9225cb430229a1e2c045 100644 --- a/hnurm_detect/package.xml +++ b/hnurm_detect/package.xml @@ -5,21 +5,23 @@ 0.0.0 TODO: Package description yc - TODO: License declaration + MIT License ament_cmake rosidl_default_generators - rosidl_default_runtime + + rclcpp std_msgs sensor_msgs cv_bridge - rclcpp message_filters tf2_ros + tf2_eigen + image_transport OpenCV Eigen3 - hnurm_uart + hnurm_interfaces ament_lint_auto ament_lint_common diff --git a/hnurm_detect/params/default.yaml b/hnurm_detect/params/default.yaml index 6b1ee4cb678c95feb881f7b0e77f3336820e2a9a..4552396f26817500b124ea95320ec109c0f5b344 100644 --- a/hnurm_detect/params/default.yaml +++ b/hnurm_detect/params/default.yaml @@ -10,33 +10,35 @@ res_armor_topic: "armor" debug_info_topic: "/debug/detect_time" - min_lightness: 170 + pub_debug_info: false + + min_lightness: 80 #light_params - min_ratio: 0.12 + min_ratio: 0.16 max_ratio: 0.35 - light_max_angle: 40.0 - + light_max_angle: 30.0 + #armor_params min_light_ratio: 0.6 min_small_center_distance: 0.8 - max_small_center_distance: 3.0 + max_small_center_distance: 3.2 min_large_center_distance: 3.2 max_large_center_distance: 5.0 armor_max_angle: 35.0 #classifier_params - label_path: "src/hnurm_detect/model/label.txt" - model_path: "src/hnurm_detect/model/mlp.onnx" + label_path: "/home/rm/hnuvision/src/hnurm_detect/model/label.txt" + model_path: "/home/rm/hnuvision/src/hnurm_detect/model/mlp.onnx" threshold: 0.7 # do not uncomment this during debugging ignore_classes: - negative -# - outpost -# - base -# - guard -# - "1" -# - "2" -# - "3" -# - "4" -# - "5" + # - outpost + # - base + # - guard + # - "1" + # - "2" + # - "3" + # - "4" + # - "5" \ No newline at end of file diff --git a/hnurm_detect/src/detect_node.cpp b/hnurm_detect/src/detect_node.cpp index f67488e3c2a74d868101fe0f007dd55afc5ca85a..682452ef4f580233ddb127ddf72d8022328d7318 100644 --- a/hnurm_detect/src/detect_node.cpp +++ b/hnurm_detect/src/detect_node.cpp @@ -5,7 +5,7 @@ namespace hnurm { -DetectNode::DetectNode(const rclcpp::NodeOptions &options) : rclcpp::Node("detect_node") +DetectNode::DetectNode(const rclcpp::NodeOptions &options) : rclcpp::Node("detect_node", options) { init_params(); // init detector @@ -15,25 +15,27 @@ DetectNode::DetectNode(const rclcpp::NodeOptions &options) : rclcpp::Node("detec auto qos = rclcpp::SensorDataQoS(); auto prof = qos.get_rmw_qos_profile(); sub_img_ = std::make_shared>(this, image_topic_, prof); - sub_uart_ = std::make_shared>(this, recv_topic_, prof); - sync_ = std::make_shared>( - ApproximateTimePolicy(1024), *sub_img_, *sub_uart_ + sub_uart_ + = std::make_shared>(this, recv_topic_, prof); + sync_ = std::make_shared>( + ApproximateTimePolicy(4'096), *sub_img_, *sub_uart_ ); sync_->registerCallback(&DetectNode::detect_callback, this); // pubs - pub_res_img_ = this->create_publisher(res_img_topic_, qos); - pub_num_img_ = this->create_publisher(num_img_topic_, qos); - pub_bin_img_ = this->create_publisher(bin_img_topic_, qos); - pub_res_armor_ = this->create_publisher(res_armor_topic_, qos); + pub_res_img_ = image_transport::create_publisher(this, res_img_topic_); + pub_num_img_ = image_transport::create_publisher(this, num_img_topic_); + pub_bin_img_ = image_transport::create_publisher(this, bin_img_topic_); + pub_res_armor_ = this->create_publisher(res_armor_topic_, qos); // debug pubs std::string debug_topic = this->declare_parameter("debug_info_topic", "/debug/detect_time"); - pub_detect_time_ = this->create_publisher(debug_topic, qos); + pub_detect_time_ = this->create_publisher(debug_topic, qos); } void DetectNode::init_params() { + auto f = // topics recv_topic_ = this->declare_parameter("vision_recv_topic", "vision_recv_data"); image_topic_ = this->declare_parameter("img_topic", "image"); @@ -42,6 +44,8 @@ void DetectNode::init_params() bin_img_topic_ = this->declare_parameter("bin_img_topic", "bin_img"); res_armor_topic_ = this->declare_parameter("res_armor_topic", "armor"); + pub_debug_info_ = this->declare_parameter("pub_debug_info", false); + // detector params min_lightness_ = static_cast(this->declare_parameter("min_lightness", 120)); @@ -63,23 +67,29 @@ void DetectNode::init_params() } void DetectNode::detect_callback( - const sensor_msgs::msg::Image::SharedPtr img_msg, const hnurm_uart::msg::VisionRecvData::SharedPtr uart_msg + const sensor_msgs::msg::Image::SharedPtr img_msg, const hnurm_interfaces::msg::VisionRecvData::SharedPtr uart_msg ) { + static auto last_time = this->now(); + auto this_time = this->now(); + auto call_dt = (this_time - last_time).seconds(); + RCLCPP_INFO(this->get_logger(), "Callback FPS: %f", 1.0 / call_dt); + last_time = this_time; + // first get cloud - //串口中,0==无,1==红,2==蓝 - //检测任务中,0==红,1==蓝,2==紫 + // 串口中,0==无,1==红,2==蓝 + // 检测任务中,0==红,1==蓝,2==紫 auto self_color = uart_msg->self_color.data; - if(self_color == hnurm_uart::msg::SelfColor::RED) + if(self_color == hnurm_interfaces::msg::SelfColor::RED) self_color = hnurm::RED; else self_color = hnurm::BLUE; // get image - cv_bridge::CvImagePtr cv_ptr; + static cv_bridge::CvImageConstPtr cv_ptr; try { - cv_ptr = cv_bridge::toCvCopy(img_msg, sensor_msgs::image_encodings::BGR8); + cv_ptr = cv_bridge::toCvShare(img_msg, sensor_msgs::image_encodings::BGR8); } catch(cv_bridge::Exception &e) { @@ -88,37 +98,41 @@ void DetectNode::detect_callback( } // do detect - rclcpp::Time start = this->now(); - static long detect_cnt = 0; + rclcpp::Time start = this->now(); + static long detect_cnt = 0; detector_->detect(cv_ptr->image, self_color); auto dt = (this->now() - start).seconds(); - RCLCPP_INFO(this->get_logger(), "detect time: %f; %ld", dt, detect_cnt); + + // pub res std_msgs::msg::Float64 dt_; dt_.data = dt * 1000.0; pub_detect_time_->publish(dt_); // publish res images - cv::Mat res_img = cv_ptr->image.clone(); - detector_->drawResults(res_img); - auto res_img_msg - = cv_bridge::CvImage(std_msgs::msg::Header(), sensor_msgs::image_encodings::BGR8, res_img).toImageMsg(); - pub_res_img_->publish(*res_img_msg); - - // publish num images - auto num_img = detector_->getAllNumbersImage().clone(); - auto num_img_msg - = cv_bridge::CvImage(std_msgs::msg::Header(), sensor_msgs::image_encodings::MONO8, num_img).toImageMsg(); - pub_num_img_->publish(*num_img_msg); - - // publish binary images - auto bin_img = detector_->binary_img; - auto bin_img_msg - = cv_bridge::CvImage(std_msgs::msg::Header(), sensor_msgs::image_encodings::MONO8, bin_img).toImageMsg(); - pub_bin_img_->publish(*bin_img_msg); + if(pub_debug_info_) + { + cv::Mat res_img = cv_ptr->image.clone(); + detector_->drawResults(res_img); + auto res_img_msg + = cv_bridge::CvImage(std_msgs::msg::Header(), sensor_msgs::image_encodings::BGR8, res_img).toImageMsg(); + pub_res_img_.publish(*res_img_msg); + + // publish num images + auto num_img = detector_->getAllNumbersImage().clone(); + auto num_img_msg + = cv_bridge::CvImage(std_msgs::msg::Header(), sensor_msgs::image_encodings::MONO8, num_img).toImageMsg(); + pub_num_img_.publish(*num_img_msg); + + // publish binary images + auto bin_img = detector_->binary_img; + auto bin_img_msg + = cv_bridge::CvImage(std_msgs::msg::Header(), sensor_msgs::image_encodings::MONO8, bin_img).toImageMsg(); + pub_bin_img_.publish(*bin_img_msg); + } // publish armors - hnurm_detect::msg::ArmorArray armor_msg; + hnurm_interfaces::msg::ArmorArray armor_msg; armor_msg.recv_uart = *uart_msg; armor_msg.header.stamp = now(); armor_msg.header.frame_id = "armor"; @@ -131,9 +145,9 @@ void DetectNode::detect_callback( pub_res_armor_->publish(armor_msg); } -hnurm_detect::msg::Armor toROSMsg(const Armor &armor) +hnurm_interfaces::msg::Armor toROSMsg(const Armor &armor) { - hnurm_detect::msg::Armor msg; + hnurm_interfaces::msg::Armor msg; msg.left_light.color = armor.left_light.color; msg.left_light.top.x = armor.left_light.top.x; msg.left_light.top.y = armor.left_light.top.y; diff --git a/hnurm_detect/src/detector.cpp b/hnurm_detect/src/detector.cpp index 8d841ad068fe5ae5862d045a3cc432b303376e7e..7415b3e4da4b57dff5041329934bee3db9d16c89 100755 --- a/hnurm_detect/src/detector.cpp +++ b/hnurm_detect/src/detector.cpp @@ -13,247 +13,334 @@ #include #include -// #include "ThreadManager.h" #include "hnurm_detect/armor.hpp" #include "hnurm_detect/detector.hpp" -constexpr int CHANNEL_BLUE=0; -constexpr int CHANNEL_RED=2; +constexpr int CHANNEL_BLUE = 0; +constexpr int CHANNEL_RED = 2; namespace hnurm { -Detector::Detector( - int min_lightness, - const LightParams &light_params, - const ArmorParams &armor_params, - const ClassifierParams &classifier_params -) - : min_lightness(min_lightness), - light_params(light_params), - armor_params(armor_params) -{ - auto &[model_path, label_path, ignore_classes, threshold] = classifier_params; - this->classifier = std::make_unique(model_path, label_path, threshold, ignore_classes); -} - -void Detector::detect(const cv::Mat &input, int self_color) -{ - binary_img = preprocessImage(input); - lights_ = findLights(input, binary_img); - armors_ = matchLights(lights_, self_color); - - if(!armors_.empty()) + Detector::Detector( + int min_lightness, + const LightParams &light_params, + const ArmorParams &armor_params, + const ClassifierParams &classifier_params + ) + : min_lightness(min_lightness), + light_params(light_params), + armor_params(armor_params) { - classifier->extractNumbers(input, armors_); - classifier->classify(armors_,self_color); + auto &[model_path, label_path, ignore_classes, threshold] = classifier_params; + this->classifier = std::make_unique(model_path, label_path, threshold, ignore_classes); } -} -cv::Mat Detector::getAllNumbersImage() -{ - if(armors_.empty()) + void Detector::detect(const cv::Mat &input, int self_color) { - return {cv::Size(20, 28), CV_8UC1}; + binary_img = preprocessImage(input); + lights_ = findLights(input, binary_img); + armors_ = matchLights(lights_, self_color); + + if (!armors_.empty()) + { + classifier->extractNumbers(input, armors_); + classifier->classify(armors_, self_color); + } } - else + + cv::Mat Detector::getAllNumbersImage() { - std::vector number_imgs; - number_imgs.reserve(armors_.size()); - for(auto &armor : armors_) + if (armors_.empty()) + { + return {cv::Size(20, 28), CV_8UC1}; + } + else { - number_imgs.emplace_back(armor.number_img); + std::vector number_imgs; + number_imgs.reserve(armors_.size()); + for (auto &armor: armors_) + { + number_imgs.emplace_back(armor.number_img); + } + cv::Mat all_num_img; + cv::vconcat(number_imgs, all_num_img); + return all_num_img; } - cv::Mat all_num_img; - cv::vconcat(number_imgs, all_num_img); - return all_num_img; } -} -void Detector::drawResults(cv::Mat &img) -{ - // Draw Lights - for(const auto &light : lights_) + void Detector::drawResults(cv::Mat &img) { - cv::circle(img, light.top, 3, cv::Scalar(255, 255, 255), 1); - cv::circle(img, light.bottom, 3, cv::Scalar(255, 255, 255), 1); - auto line_color = light.color == RED ? cv::Scalar(255, 255, 0) : cv::Scalar(255, 0, 255); - cv::line(img, light.top, light.bottom, line_color, 1); + // Draw Lights + for (const auto &light: lights_) + { + cv::circle(img, light.top, 3, cv::Scalar(255, 255, 255), 1); + cv::circle(img, light.bottom, 3, cv::Scalar(255, 255, 255), 1); + auto line_color = light.color == RED ? cv::Scalar(255, 255, 0) : cv::Scalar(255, 0, 255); + cv::line(img, light.top, light.bottom, line_color, 1); + } + + // Draw armors + for (const auto &armor: armors_) + { + cv::line(img, armor.left_light.top, armor.right_light.bottom, cv::Scalar(0, 255, 0), 2); + cv::line(img, armor.left_light.bottom, armor.right_light.top, cv::Scalar(0, 255, 0), 2); + } + + // Show numbers and confidence + for (const auto &armor: armors_) + { + cv::putText( + img, + armor.classification_result, + armor.left_light.top, + cv::FONT_HERSHEY_SIMPLEX, + 0.8, + cv::Scalar(0, 255, 255), + 2 + ); + } } - // Draw armors - for(const auto &armor : armors_) + cv::Mat Detector::preprocessImage(const cv::Mat &rgb_img) const { - cv::line(img, armor.left_light.top, armor.right_light.bottom, cv::Scalar(0, 255, 0), 2); - cv::line(img, armor.left_light.bottom, armor.right_light.top, cv::Scalar(0, 255, 0), 2); + cv::Mat gray_img; + cv::cvtColor(rgb_img, gray_img, cv::COLOR_RGB2GRAY); + + cv::Mat _binary_img; + cv::threshold(gray_img, _binary_img, min_lightness, 255, cv::THRESH_BINARY); + + return _binary_img; + } + cv::Point2d Detector::calculateMean(const std::vector &points) + { + cv::Point2d mean(0.0, 0.0); + for (const auto &point: points) + { + mean.x += point.x; + mean.y += point.y; + } + mean.x /= points.size(); + mean.y /= points.size(); + return mean; } - // Show numbers and confidence - for(const auto &armor : armors_) + std::vector Detector::centralizeData(const std::vector &points, const cv::Point2d &mean) { - cv::putText( - img, - armor.classification_result, - armor.left_light.top, - cv::FONT_HERSHEY_SIMPLEX, - 0.8, - cv::Scalar(0, 255, 255), - 2 - ); + std::vector centralized; + for (const auto &point: points) + { + centralized.push_back(cv::Point2d(point.x - mean.x, point.y - mean.y)); + } + return centralized; } -} -cv::Mat Detector::preprocessImage(const cv::Mat &rgb_img) const -{ - cv::Mat gray_img; - cv::cvtColor(rgb_img, gray_img, cv::COLOR_RGB2GRAY); +// 计算协方差矩阵 + Eigen::Matrix2d Detector::calculateCovarianceMatrix(const std::vector ¢ralized) + { + Eigen::Matrix2d covarianceMatrix; + covarianceMatrix.setZero(); + for (const auto &point: centralized) + { + covarianceMatrix(0, 0) += point.x * point.x; + covarianceMatrix(0, 1) += point.x * point.y; + covarianceMatrix(1, 0) += point.y * point.x; + covarianceMatrix(1, 1) += point.y * point.y; + } + covarianceMatrix /= centralized.size(); + return covarianceMatrix; + } + cv::Point2d Detector::performPCA(const std::vector &points, const cv::Point2d &mean) + { - cv::Mat _binary_img; - cv::threshold(gray_img, _binary_img, min_lightness, 255, cv::THRESH_BINARY); + std::vector centralized = centralizeData(points, mean); + Eigen::Matrix2d covarianceMatrix = calculateCovarianceMatrix(centralized); - return _binary_img; -} + // 计算特征值和特征向量 + Eigen::SelfAdjointEigenSolver < Eigen::Matrix2d > solver(covarianceMatrix); + Eigen::Matrix2d eigenvectors = solver.eigenvectors(); +// Eigen::Vector2d eigenvalues = solver.eigenvalues(); -std::vector Detector::findLights(const cv::Mat &rbg_img, const cv::Mat &_binary_img) -{ - using std::vector; - vector> contours; - cv::findContours(_binary_img, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); + // 输出主成分方向 +// std::cout << "Principal Component 1: " << eigenvectors.col(1).transpose() << std::endl; +// std::cout << "Principal Component 2: " << eigenvectors.col(0).transpose() << std::endl; + cv::Point2d p1 = mean + cv::Point2d(eigenvectors(0, 1), eigenvectors(1, 1)); + return p1; + } + bool Detector::computeLineIntersection(const cv::Point2d &p1, + const cv::Point2d &p2, + const cv::Point2d &p3, + const cv::Point2d &p4, + cv::Point2d &intersection) + { + double A1 = p2.y - p1.y; + double B1 = p1.x - p2.x; + double C1 = A1 * p1.x + B1 * p1.y; - vector lights; + double A2 = p4.y - p3.y; + double B2 = p3.x - p4.x; + double C2 = A2 * p3.x + B2 * p3.y; - for(const auto &contour : contours) + double det = A1 * B2 - A2 * B1; + if (det == 0) + { + return false; // 平行线或重合线 + } + else + { + intersection.x = (B2 * C1 - B1 * C2) / det; + intersection.y = (A1 * C2 - A2 * C1) / det; + return true; + } + } + std::vector Detector::findLights(const cv::Mat &rbg_img, const cv::Mat &_binary_img) { - if(contour.size() < 5) - continue; + using std::vector; + vector> contours; + cv::findContours(_binary_img, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_NONE); - auto r_rect = cv::minAreaRect(contour); - auto light = Light(r_rect); + vector lights; - if(isLight(light)) + for (const auto &contour: contours) { - auto rect = light.boundingRect(); - if (// Avoid assertion failed - 0 <= rect.x && 0 <= rect.width && rect.x + rect.width <= rbg_img.cols && 0 <= rect.y && - 0 <= rect.height && rect.y + rect.height <= rbg_img.rows) + if (contour.size() < 5) + continue; + cv::Point2d mean = calculateMean(contour); + cv::Point2d p1 = performPCA(contour, mean); + auto r_rect = cv::minAreaRect(contour); + auto light = Light(r_rect); + + if (isLight(light)) { - int sum_r = 0, sum_b = 0; - auto roi = rbg_img(rect); - // Iterate through the ROI - for(int row = 0; row < roi.rows; row++) + auto rect = light.boundingRect(); + if (// Avoid assertion failed + 0 <= rect.x && 0 <= rect.width && rect.x + rect.width <= rbg_img.cols && 0 <= rect.y && + 0 <= rect.height && rect.y + rect.height <= rbg_img.rows) { - for(int j = 0; j < roi.cols; j++) + int sum_r = 0, sum_b = 0; + auto roi = rbg_img(rect); + // Iterate through the ROI + for (int row = 0; row < roi.rows; row++) { - if(cv::pointPolygonTest(contour, cv::Point2f(j + rect.x, row + rect.y), false) >= 0) + for (int j = 0; j < roi.cols; j++) { - // if point is inside contour - sum_r += roi.at(row, j)[CHANNEL_RED]; - sum_b += roi.at(row, j)[CHANNEL_BLUE]; + if (cv::pointPolygonTest(contour, cv::Point2f(j + rect.x, row + rect.y), false) >= 0) + { + // if point is inside contour + sum_r += roi.at(row, j)[CHANNEL_RED]; + sum_b += roi.at(row, j)[CHANNEL_BLUE]; + } } } - } - //步兵不需要识别紫色的基地装甲 - // float sum_br=float(sum_b)/sum_r; - // if( sum_br > 0.99 && sum_br < 1.20){ - // light.color=PURPLE; - // lights.emplace_back(light); - // continue; - // } - - - // Sum of red pixels > sum of blue pixels ? - light.color = sum_r > sum_b ? RED : BLUE; - lights.emplace_back(light); + light.color = sum_r > sum_b ? RED : BLUE; + lights.emplace_back(light); + } + vector intersections; + cv::Point2d intersection; + if (computeLineIntersection(mean, p1, light.p[0], light.p[1], intersection)) + { + intersections.push_back(intersection); + } + light.top = intersection; + if (computeLineIntersection(mean, p1, light.p[2], light.p[3], intersection)) + { + intersections.push_back(intersection); + } + light.bottom = intersection; + light.center = mean; + light.tilt_angle = + std::atan2(std::abs(light.top.x - light.bottom.x), std::abs(light.top.y - light.bottom.y)); + light.tilt_angle = light.tilt_angle / CV_PI * 180; } - } - }; - - return lights; -} + }; + return lights; + } -bool Detector::isLight(const Light &light) const -{ - // The ratio of light (short side / long side) - auto ratio = static_cast((light.width / light.length)); - bool ratio_ok = light_params.min_ratio < ratio && ratio < light_params.max_ratio; - bool angle_ok = light.tilt_angle < light_params.max_angle; - bool size_ok = light.width * light.length > 20; - return ratio_ok && angle_ok && size_ok; -} - -std::vector Detector::matchLights(const std::vector &lights, int self_color) -{ - std::vector armors; + bool Detector::isLight(const Light &light) const + { + // The ratio of light (short side / long side) + auto ratio = static_cast((light.width / light.length)); + bool ratio_ok = light_params.min_ratio < ratio && ratio < light_params.max_ratio; + bool angle_ok = light.tilt_angle < light_params.max_angle; + bool size_ok = light.width * light.length > 40; + return ratio_ok && angle_ok && size_ok; + } - // Loop all the pairing of lights - for(int i = 0; i < lights.size(); i++) + std::vector Detector::matchLights(const std::vector &lights, int self_color) { - for(int j = i + 1; j < lights.size(); j++) - { - if(lights[i].color == self_color || lights[j].color == self_color) - continue; + std::vector armors; - if(containLight(lights[i], lights[j], lights)) - { + // Loop all the pairing of lights + for (int i = 0; i < lights.size(); i++) + { + if (lights[i].color == self_color) continue; - } - auto armor = Armor(lights[i], lights[j]); - if(isArmor(armor)) + for (int j = i + 1; j < lights.size(); j++) { - armors.emplace_back(armor); + if (lights[j].color == self_color) + continue; + + if (containLight(lights[i], lights[j], lights)) + { + continue; + } + auto armor = Armor(lights[i], lights[j]); + if (isArmor(armor)) + { + armors.emplace_back(armor); + } } } - } - return armors; -} + return armors; + } // Check if there is another light in the boundingRect formed by the 2 lights -bool Detector::containLight(const Light &light_1, const Light &light_2, const std::vector &lights) -{ - auto points = std::vector {light_1.top, light_1.bottom, light_2.top, light_2.bottom}; - auto bounding_rect = cv::boundingRect(points); - - for(const auto &test_light : lights) + bool Detector::containLight(const Light &light_1, const Light &light_2, const std::vector &lights) { - if(test_light.center == light_1.center || test_light.center == light_2.center) - continue; + auto points = std::vector{light_1.top, light_1.bottom, light_2.top, light_2.bottom}; + auto bounding_rect = cv::boundingRect(points); - if(bounding_rect.contains(test_light.top) || bounding_rect.contains(test_light.bottom) - || bounding_rect.contains(test_light.center)) + for (const auto &test_light: lights) { - return true; + if (test_light.center == light_1.center || test_light.center == light_2.center) + continue; + + if (bounding_rect.contains(test_light.top) || bounding_rect.contains(test_light.bottom) + || bounding_rect.contains(test_light.center)) + { + return true; + } } - } - return false; -} + return false; + } -bool Detector::isArmor(Armor &armor) const -{ - Light light_1 = armor.left_light; - Light light_2 = armor.right_light; - // Ratio of the length of 2 lights (short side / long side) - auto light_length_ratio - = light_1.length < light_2.length ? light_1.length / light_2.length : light_2.length / light_1.length; - bool light_ratio_ok = light_length_ratio > armor_params.min_light_ratio; - - // Distance between the center of 2 lights (unit : light length) - auto avg_light_length = (light_1.length + light_2.length) / 2; - auto center_distance = cv::norm(light_1.center - light_2.center) / avg_light_length; - bool center_distance_ok = (armor_params.min_small_center_distance < center_distance - && center_distance < armor_params.max_small_center_distance) - || (armor_params.min_large_center_distance < center_distance - && center_distance < armor_params.max_large_center_distance); - - // Angle of light center connection - cv::Point2f diff = light_1.center - light_2.center; - auto angle = std::abs(std::atan(diff.y / diff.x)) / CV_PI * 180; - bool angle_ok = angle < armor_params.max_angle; - - bool is_armor = light_ratio_ok && center_distance_ok && angle_ok; - armor.armor_type = center_distance > armor_params.min_large_center_distance ? LARGE : SMALL; - return is_armor; -} + bool Detector::isArmor(Armor &armor) const + { + Light light_1 = armor.left_light; + Light light_2 = armor.right_light; + // Ratio of the length of 2 lights (short side / long side) + auto light_length_ratio + = light_1.length < light_2.length ? light_1.length / light_2.length : light_2.length / light_1.length; + bool light_ratio_ok = light_length_ratio > armor_params.min_light_ratio; + + // Distance between the center of 2 lights (unit : light length) + auto avg_light_length = (light_1.length + light_2.length) / 2; + auto center_distance = cv::norm(light_1.center - light_2.center) / avg_light_length; + bool center_distance_ok = (armor_params.min_small_center_distance < center_distance + && center_distance < armor_params.max_small_center_distance) + || (armor_params.min_large_center_distance < center_distance + && center_distance < armor_params.max_large_center_distance); + + // Angle of light center connection + cv::Point2f diff = light_1.center - light_2.center; + auto angle = std::abs(std::atan(diff.y / diff.x)) / CV_PI * 180; + bool angle_ok = angle < armor_params.max_angle; + bool abs_angle = abs(light_1.tilt_angle - light_2.tilt_angle) < 24; + bool is_armor = light_ratio_ok && center_distance_ok && angle_ok && abs_angle; + armor.armor_type = center_distance > armor_params.min_large_center_distance ? LARGE : SMALL; + return is_armor; + } } // namespace hnurm diff --git a/hnurm_detect/src/main.cpp b/hnurm_detect/src/main.cpp index 392b20ec90acfdb7bf4a61b92967c63300b6663b..26ccf8e3e87d61c3b71ab4ce2fc037e6e98d2562 100644 --- a/hnurm_detect/src/main.cpp +++ b/hnurm_detect/src/main.cpp @@ -1,5 +1,4 @@ #include "hnurm_detect/detect_node.hpp" -#include int main(int argc, char **argv) { diff --git a/hnurm_detect/src/number_classifier.cpp b/hnurm_detect/src/number_classifier.cpp index b76229cefe286d4a19cff0d570be96412559b112..be7223f1acae64ad50f0b28d10a90a1dfa728ac9 100755 --- a/hnurm_detect/src/number_classifier.cpp +++ b/hnurm_detect/src/number_classifier.cpp @@ -6,8 +6,6 @@ #include #include #include -#include -#include #include #include @@ -133,7 +131,8 @@ void NumberClassifier::classify(std::vector &armors,int self_color) armors.erase( std::remove_if( armors.begin(), armors.end(), - [this,self_color](const Armor &armor) { + [this](const Armor &armor) + { // 去除置信度太低的 if (armor.confidence < threshold) { @@ -147,10 +146,7 @@ void NumberClassifier::classify(std::vector &armors,int self_color) } } - //如果目标是紫色,只可能是基地 - // if(armor.number!="base"&&armor.left_light.color==2&&self_color==0){ - // return true; - // } + // 如果是大装甲板,去除"outpost"(前哨站),"2"(工程),"guard"(哨兵),“3”、“5”(其中平步4是大装甲板) // 如果是小装甲板,去除"1"(英雄)和"base"(基地) diff --git a/hnurm_interfaces/CMakeLists.txt b/hnurm_interfaces/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..acf6c21a17d03736fb4f19b230dac7db79d2eb07 --- /dev/null +++ b/hnurm_interfaces/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.8) +project(hnurm_interfaces) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +file(GLOB msg_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} msg/*/*.msg) +rosidl_generate_interfaces( + ${PROJECT_NAME} + ${msg_files} + DEPENDENCIES ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS} +) + +ament_auto_package() diff --git a/hnurm_interfaces/LICENSE b/hnurm_interfaces/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..30e8e2ece557688ae98a9f6f0e1b4cf450a85ae2 --- /dev/null +++ b/hnurm_interfaces/LICENSE @@ -0,0 +1,17 @@ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/hnurm_armor/msg/Target.msg b/hnurm_interfaces/msg/armor/Target.msg similarity index 84% rename from hnurm_armor/msg/Target.msg rename to hnurm_interfaces/msg/armor/Target.msg index fc9926bdc5ad6d0b2a2725d0b15bab2967140887..2d74f7bad0a40f5d218d8993a0524ae44e5a22c0 100644 --- a/hnurm_armor/msg/Target.msg +++ b/hnurm_interfaces/msg/armor/Target.msg @@ -9,3 +9,5 @@ float64 v_yaw float64 radius_1 float64 radius_2 float64 dz +float64 armor_pitch +float64 armor_yaw \ No newline at end of file diff --git a/hnurm_armor/msg/TrackerInfo.msg b/hnurm_interfaces/msg/armor/TrackerInfo.msg similarity index 100% rename from hnurm_armor/msg/TrackerInfo.msg rename to hnurm_interfaces/msg/armor/TrackerInfo.msg diff --git a/hnurm_detect/msg/Armor.msg b/hnurm_interfaces/msg/detect/Armor.msg similarity index 100% rename from hnurm_detect/msg/Armor.msg rename to hnurm_interfaces/msg/detect/Armor.msg diff --git a/hnurm_detect/msg/ArmorArray.msg b/hnurm_interfaces/msg/detect/ArmorArray.msg similarity index 49% rename from hnurm_detect/msg/ArmorArray.msg rename to hnurm_interfaces/msg/detect/ArmorArray.msg index 7e97e7f6868505ca3a6d17881de7805c1e7be119..71633463b2ebe36371a447e17e80e4115f7476bd 100644 --- a/hnurm_detect/msg/ArmorArray.msg +++ b/hnurm_interfaces/msg/detect/ArmorArray.msg @@ -2,4 +2,4 @@ std_msgs/Header header Armor[] armors -hnurm_uart/VisionRecvData recv_uart \ No newline at end of file +hnurm_interfaces/VisionRecvData recv_uart \ No newline at end of file diff --git a/hnurm_detect/msg/ArmorType.msg b/hnurm_interfaces/msg/detect/ArmorType.msg similarity index 100% rename from hnurm_detect/msg/ArmorType.msg rename to hnurm_interfaces/msg/detect/ArmorType.msg diff --git a/hnurm_detect/msg/Light.msg b/hnurm_interfaces/msg/detect/Light.msg similarity index 100% rename from hnurm_detect/msg/Light.msg rename to hnurm_interfaces/msg/detect/Light.msg diff --git a/hnurm_detect/msg/Point2D32.msg b/hnurm_interfaces/msg/detect/Point2D32.msg similarity index 100% rename from hnurm_detect/msg/Point2D32.msg rename to hnurm_interfaces/msg/detect/Point2D32.msg diff --git a/hnurm_uart/msg/BulletSpeed.msg b/hnurm_interfaces/msg/uart/BulletSpeed.msg similarity index 100% rename from hnurm_uart/msg/BulletSpeed.msg rename to hnurm_interfaces/msg/uart/BulletSpeed.msg diff --git a/hnurm_uart/msg/SelfColor.msg b/hnurm_interfaces/msg/uart/SelfColor.msg similarity index 100% rename from hnurm_uart/msg/SelfColor.msg rename to hnurm_interfaces/msg/uart/SelfColor.msg diff --git a/hnurm_uart/msg/TargetState.msg b/hnurm_interfaces/msg/uart/TargetState.msg similarity index 100% rename from hnurm_uart/msg/TargetState.msg rename to hnurm_interfaces/msg/uart/TargetState.msg diff --git a/hnurm_uart/msg/TargetType.msg b/hnurm_interfaces/msg/uart/TargetType.msg similarity index 100% rename from hnurm_uart/msg/TargetType.msg rename to hnurm_interfaces/msg/uart/TargetType.msg diff --git a/hnurm_uart/msg/VisionRecvData.msg b/hnurm_interfaces/msg/uart/VisionRecvData.msg similarity index 100% rename from hnurm_uart/msg/VisionRecvData.msg rename to hnurm_interfaces/msg/uart/VisionRecvData.msg diff --git a/hnurm_uart/msg/VisionSendData.msg b/hnurm_interfaces/msg/uart/VisionSendData.msg similarity index 100% rename from hnurm_uart/msg/VisionSendData.msg rename to hnurm_interfaces/msg/uart/VisionSendData.msg diff --git a/hnurm_uart/msg/WorkMode.msg b/hnurm_interfaces/msg/uart/WorkMode.msg similarity index 100% rename from hnurm_uart/msg/WorkMode.msg rename to hnurm_interfaces/msg/uart/WorkMode.msg diff --git a/hnurm_interfaces/package.xml b/hnurm_interfaces/package.xml new file mode 100644 index 0000000000000000000000000000000000000000..06c2673f822d6221fc8bffa58f4516cd38550058 --- /dev/null +++ b/hnurm_interfaces/package.xml @@ -0,0 +1,27 @@ + + + + hnurm_interfaces + 0.0.0 + TODO: Package description + rm + MIT + + ament_cmake + ament_cmake_auto + rosidl_default_generators + + std_msgs + nav_msgs + sensor_msgs + + ament_lint_auto + ament_lint_common + + rosidl_default_runtime + rosidl_interface_packages + + + ament_cmake + + diff --git a/hnurm_uart/CMakeLists.txt b/hnurm_uart/CMakeLists.txt index 22c143d93ae052476e14af15e36c6a3e2b6e7aa8..7f85e944a1d1235f06a90acf8abc93a135cdba19 100644 --- a/hnurm_uart/CMakeLists.txt +++ b/hnurm_uart/CMakeLists.txt @@ -3,83 +3,21 @@ project(hnurm_uart) set(CMAKE_CXX_STANDARD 17) -find_package(ament_cmake REQUIRED) -find_package(rosidl_default_generators REQUIRED) -find_package(rclcpp REQUIRED) -find_package(std_msgs REQUIRED) -find_package(geometry_msgs REQUIRED) -find_package(nav_msgs REQUIRED) -find_package(tf2_ros REQUIRED) -find_package(tf2_eigen REQUIRED) -find_package(angles REQUIRED) +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() -find_package(Eigen3 REQUIRED) - -set(dependencies - rclcpp - std_msgs - geometry_msgs - nav_msgs - tf2_ros - tf2_eigen - angles -) - -rosidl_generate_interfaces(${PROJECT_NAME} - msg/TargetState.msg - msg/TargetType.msg - msg/VisionSendData.msg - msg/SelfColor.msg - msg/WorkMode.msg - msg/BulletSpeed.msg - msg/VisionRecvData.msg - DEPENDENCIES std_msgs -) - -rosidl_get_typesupport_target(cpp_typesupport_target - ${PROJECT_NAME} rosidl_typesupport_cpp) - -add_library(hnurm_crc SHARED src/CRC/bsp_crc8.cpp src/CRC/bsp_crc16.cpp) -target_include_directories(hnurm_crc PUBLIC - $ - $ -) - -add_library(hnurm_protocol SHARED src/Protocol/protocol.cpp) -target_include_directories(hnurm_protocol PRIVATE - $ - $ -) -target_link_libraries(hnurm_protocol ${cpp_typesupport_target}) - -add_library(hnurm_serial SHARED src/Serial/serial.cpp src/Serial/Serialcodec.cpp) -target_include_directories(hnurm_serial PRIVATE - $ - $ -) -ament_target_dependencies(hnurm_serial ${dependencies}) -target_link_libraries(hnurm_serial hnurm_protocol hnurm_crc ${cpp_typesupport_target}) +ament_auto_add_library(hnurm_crc SHARED DIRECTORY src/CRC/) +ament_auto_add_library(hnurm_protocol SHARED DIRECTORY src/Protocol/) +ament_auto_add_library(hnurm_serial SHARED DIRECTORY src/Serial/) +ament_auto_add_library(hnurm_uart src/uart_node.cpp) +target_link_libraries(hnurm_uart hnurm_crc hnurm_protocol hnurm_serial) -add_executable(${PROJECT_NAME}_node src/uart_node.cpp src/main.cpp) -target_link_directories(${PROJECT_NAME}_node PUBLIC - $ - $ -) -ament_target_dependencies(${PROJECT_NAME}_node ${dependencies}) -target_link_libraries(${PROJECT_NAME}_node hnurm_crc hnurm_protocol hnurm_serial ${cpp_typesupport_target} Eigen3::Eigen) +ament_auto_add_executable(hnurm_uart_node src/uart_node.cpp src/main.cpp) +target_link_libraries(hnurm_uart_node hnurm_uart) - -install(TARGETS hnurm_crc hnurm_protocol hnurm_serial - DESTINATION lib -) -install(TARGETS ${PROJECT_NAME}_node - DESTINATION lib/${PROJECT_NAME} +ament_auto_package( + INSTALL_TO_SHARE + launch + params ) - - -install(DIRECTORY launch params - DESTINATION share/${PROJECT_NAME} -) - -ament_package() diff --git a/hnurm_uart/include/hnurm_uart/Serialcodec.h b/hnurm_uart/include/hnurm_uart/Serialcodec.h index f2ab988f2bf1564bf9aa6847674562a6f6d5cba0..ac060454bb06137ba11780c2b879796f125b1385 100755 --- a/hnurm_uart/include/hnurm_uart/Serialcodec.h +++ b/hnurm_uart/include/hnurm_uart/Serialcodec.h @@ -34,8 +34,8 @@ #include "hnurm_uart/protocol.h" #include "hnurm_uart/serial.h" // #include -#include -#include +#include +#include #include namespace hnurm @@ -54,6 +54,10 @@ public: explicit SerialCodec(rclcpp::Node::SharedPtr node); + void init_params(rclcpp::Node::SharedPtr node); + + void init_port(); + /** * @breif try to get a frame of data for vision * @param recv_data received data @@ -62,7 +66,7 @@ public: */ // bool try_get_recv_data_for(VisionRecvData &recv_data, int milli_secs = 10); - bool try_get_recv_data_for(hnurm_uart::msg::VisionRecvData &recv_data, int milli_secs = 5); + bool try_get_recv_data_for(hnurm_interfaces::msg::VisionRecvData &recv_data, int milli_secs = 5); /** * @brief encode and send data to the serial port @@ -74,7 +78,7 @@ public: */ // bool send_data(VisionSendData data); - bool send_data(hnurm_uart::msg::VisionSendData data); + bool send_data(hnurm_interfaces::msg::VisionSendData data); /** * @brief set enemy color diff --git a/hnurm_uart/include/hnurm_uart/protocol.h b/hnurm_uart/include/hnurm_uart/protocol.h index 9aac4f95f4c6fc29957c8d7c0da65b0e299c0eb3..146de1a7f4ce947c3e1493088243d0a9fdeec386 100755 --- a/hnurm_uart/include/hnurm_uart/protocol.h +++ b/hnurm_uart/include/hnurm_uart/protocol.h @@ -2,8 +2,8 @@ // #define __packed __attribute__((packed)) #pragma once -#include -#include +#include +#include #include #include @@ -31,10 +31,10 @@ public: uint16_t frame_tail; } protocol; - static std::string encode(const hnurm_uart::msg::VisionSendData &data); // 尝试使用rosidl生成的消息类型 + static std::string encode(const hnurm_interfaces::msg::VisionSendData &data); // 尝试使用rosidl生成的消息类型 // static std::string encode(const VisionSendData& data); // Encode data from VisionSendData to std::string static bool - decode(const std::string &s, hnurm_uart::msg::VisionRecvData &decoded_data); // 尝试使用rosidl生成的消息类型 + decode(const std::string &s, hnurm_interfaces::msg::VisionRecvData &decoded_data); // 尝试使用rosidl生成的消息类型 // static bool decode(const std::string& s,VisionRecvData & decoded_data); // Decode data from std::string to // VisionRecvData diff --git a/hnurm_uart/include/hnurm_uart/uart_node.hpp b/hnurm_uart/include/hnurm_uart/uart_node.hpp index cdec95964835b4722ed38ddca470c68d0fb77823..a83130feb26fbec40e5ed89c05ca21f9f7023530 100644 --- a/hnurm_uart/include/hnurm_uart/uart_node.hpp +++ b/hnurm_uart/include/hnurm_uart/uart_node.hpp @@ -1,9 +1,6 @@ #pragma once #include "hnurm_uart/Serialcodec.h" -#include "hnurm_uart/msg/vision_recv_data.hpp" -#include "hnurm_uart/msg/vision_send_data.hpp" - #include #include @@ -20,7 +17,7 @@ class UartNode : public rclcpp::Node public: using UartNodePtr = std::shared_ptr; - UartNode() : rclcpp::Node("hnurm_uart_node"), logger(get_logger()), serial_codec_(nullptr) + UartNode(const rclcpp::NodeOptions& options) : rclcpp::Node("hnurm_uart_node", options), logger(get_logger()), serial_codec_(nullptr) { } @@ -36,29 +33,34 @@ public: void run(); private: - void sub_callback(hnurm_uart::msg::VisionSendData::SharedPtr msg); + void sub_callback(hnurm_interfaces::msg::VisionSendData::SharedPtr msg); void sub_twist_callback(geometry_msgs::msg::Twist::SharedPtr msg); void timer_callback(); + void re_launch(); private: rclcpp::CallbackGroup::SharedPtr callback_group1_; rclcpp::CallbackGroup::SharedPtr callback_group2_; - rclcpp::Subscription::SharedPtr sub_; - rclcpp::Subscription::SharedPtr sub_twist_; - rclcpp::Publisher::SharedPtr pub_; + rclcpp::Subscription::SharedPtr sub_; + rclcpp::Subscription::SharedPtr sub_twist_; + rclcpp::Publisher::SharedPtr pub_; + std::thread uart_thread_; // tf broadcaster std::shared_ptr tf_broadcaster_; - rclcpp::TimerBase::SharedPtr timer_; - rclcpp::Logger logger; - SerialCodec *serial_codec_; + rclcpp::TimerBase::SharedPtr timer_; + rclcpp::Logger logger; + SerialCodec *serial_codec_; // topics std::string recv_topic_; std::string send_topic_; - float control_id_ = 0; + float control_id_ = 0; + + bool stop_flag_ = false; + int error_cnt_ = 0; protected: UartNodePtr shared_from_this() diff --git a/hnurm_uart/package.xml b/hnurm_uart/package.xml index 414be7d89581de9c88285c9bfe692dcbb534b7e2..886fd6575cbb40449f9c80fbf95978af691a0e4c 100644 --- a/hnurm_uart/package.xml +++ b/hnurm_uart/package.xml @@ -4,23 +4,25 @@ hnurm_uart 0.0.1 hnurm_uart - yc + Kai Wang MIT License ament_cmake rosidl_default_generators rclcpp - std_msgs tf2_ros tf2_eigen angles + Eigen3 + hnurm_interfaces rosidl_default_runtime ament_lint_auto ament_lint_common + rosidl_default_runtime rosidl_interface_packages diff --git a/hnurm_uart/src/Protocol/protocol.cpp b/hnurm_uart/src/Protocol/protocol.cpp index d6013fa26a5b74eb4234b93b3f5c64c027a4d4c7..2dddbd92d1161bd349b7d970164c70cffca5c8c2 100755 --- a/hnurm_uart/src/Protocol/protocol.cpp +++ b/hnurm_uart/src/Protocol/protocol.cpp @@ -53,7 +53,7 @@ namespace hnurm // return s; // } -std::string Protocol::encode(const hnurm_uart::msg::VisionSendData &data) +std::string Protocol::encode(const hnurm_interfaces::msg::VisionSendData &data) { static char ch_arr[255]; static float f_arr[6]; @@ -129,7 +129,7 @@ std::string Protocol::encode(const hnurm_uart::msg::VisionSendData &data) // return true; // } -bool Protocol::decode(const std::string &s, hnurm_uart::msg::VisionRecvData &decoded_data) +bool Protocol::decode(const std::string &s, hnurm_interfaces::msg::VisionRecvData &decoded_data) { static char ch_arr[1024]; static uint16_t msg; @@ -161,8 +161,8 @@ bool Protocol::decode(const std::string &s, hnurm_uart::msg::VisionRecvData &dec decoded_data.self_color.data = msg & 0xf; decoded_data.work_mode.data = (msg >> 4) & 0xf; decoded_data.bullet_speed.data = (msg >> 8) & 0xff; - decoded_data.yaw = f_arr[0]; - decoded_data.pitch = f_arr[1]; + decoded_data.pitch = f_arr[0]; + decoded_data.yaw = f_arr[1]; decoded_data.roll = f_arr[2]; decoded_data.vel_x = f_arr[3]; decoded_data.vel_y = f_arr[4]; diff --git a/hnurm_uart/src/Serial/Serialcodec.cpp b/hnurm_uart/src/Serial/Serialcodec.cpp index b207d0786e929647677e8c9345a9666efd8434c5..b716184110ce0ca06d9fc0b7aa5fcfb961ae139a 100755 --- a/hnurm_uart/src/Serial/Serialcodec.cpp +++ b/hnurm_uart/src/Serial/Serialcodec.cpp @@ -2,11 +2,12 @@ #define MIN_DATA_LENGTH 10 // #include -#include +#include #include "hnurm_uart/Serialcodec.h" #include +#include namespace hnurm { @@ -15,12 +16,21 @@ namespace hnurm * @brief init the serial and try to open port specified by serial_id * @param cfg_node */ +void SerialCodec::init_params(rclcpp::Node::SharedPtr node) +{ + channel_delay = static_cast(node->declare_parameter("channel_delay", 0.0)); +} + SerialCodec::SerialCodec(rclcpp::Node::SharedPtr node) { - std::string serial_id; + init_params(std::move(node)); - channel_delay = static_cast(node->declare_parameter("channel_delay", 0.0)); + init_port(); +} +void SerialCodec::init_port() +{ + std::string serial_id; for(const auto &entry : std::filesystem::directory_iterator("/dev/serial/by-id/")) { if(entry.path().filename().string().find("YueLuEmbedded") != std::string::npos) @@ -52,16 +62,15 @@ SerialCodec::SerialCodec(rclcpp::Node::SharedPtr node) // return Serial::send(data_str) > 0; // } -bool SerialCodec::send_data(hnurm_uart::msg::VisionSendData data) +bool SerialCodec::send_data(hnurm_interfaces::msg::VisionSendData data) { // visionSendData should be modified auto data_str = Protocol::encode(data); return Serial::send(data_str) > 0; } -bool SerialCodec::try_get_recv_data_for(hnurm_uart::msg::VisionRecvData &recv_data, int milli_secs) +bool SerialCodec::try_get_recv_data_for(hnurm_interfaces::msg::VisionRecvData &recv_data, int milli_secs) { - try { auto start = clk::now(); @@ -192,17 +201,12 @@ bool SerialCodec::try_get_recv_data_for(hnurm_uart::msg::VisionRecvData &recv_da return false; } - catch(std::exception &e) - { - std::cerr << e.what() << std::endl; - return false; - } } bool SerialCodec::set_color() { - hnurm_uart::msg::VisionRecvData recvData; - int err_cnt = 0; + hnurm_interfaces::msg::VisionRecvData recvData; + int err_cnt = 0; do { @@ -219,8 +223,8 @@ bool SerialCodec::set_color() return false; } } - while(recvData.self_color.data != hnurm_uart::msg::SelfColor::RED - && recvData.self_color.data != hnurm_uart::msg::SelfColor::BLUE); + while(recvData.self_color.data != hnurm_interfaces::msg::SelfColor::RED + && recvData.self_color.data != hnurm_interfaces::msg::SelfColor::BLUE); _enemy_color = ((int)recvData.self_color.data) == 1 ? 0 : 1; diff --git a/hnurm_uart/src/Serial/serial.cpp b/hnurm_uart/src/Serial/serial.cpp index 211f48d23aaaa08b4e93bdabd4fd6041e77cf3d4..1c093840a22e2636c8df432caa5a331c28efe970 100755 --- a/hnurm_uart/src/Serial/serial.cpp +++ b/hnurm_uart/src/Serial/serial.cpp @@ -118,7 +118,7 @@ bool Serial::try_recv_for(std::string &s, int milli_secs) auto start = clk::now(); s.clear(); - static char buf_[1024]; + static char buf_[128]; while(s.empty()) { diff --git a/hnurm_uart/src/main.cpp b/hnurm_uart/src/main.cpp index 2068446da3ace52f9b5272f3674aecaf7144f874..f2ed53a3f215268463efe5b0351e42a7fcb20e0e 100644 --- a/hnurm_uart/src/main.cpp +++ b/hnurm_uart/src/main.cpp @@ -3,11 +3,9 @@ int main(int argc, char *argv[]) { rclcpp::init(argc, argv); - - rclcpp::executors::MultiThreadedExecutor executor(rclcpp::ExecutorOptions(), 2); - auto node = std::make_shared(); + auto options = rclcpp::NodeOptions().use_intra_process_comms(true); + auto node = std::make_shared(options); node->run(); - executor.add_node(node); - executor.spin(); + rclcpp::spin(node); rclcpp::shutdown(); } \ No newline at end of file diff --git a/hnurm_uart/src/uart_node.cpp b/hnurm_uart/src/uart_node.cpp index a64679046a3685a97056d7fd95e1c3c9ccf4718e..1149b9ec8064782bcbebf37a69e1dbd6a02c525f 100644 --- a/hnurm_uart/src/uart_node.cpp +++ b/hnurm_uart/src/uart_node.cpp @@ -7,11 +7,21 @@ #include #include +#include + +using namespace std::chrono_literals; namespace hnurm { void UartNode::run() { + // check if /dev/serial/by-id/ is created + while(!std::filesystem::exists("/dev/serial/by-id/")) + { + RCLCPP_WARN(logger, "Waiting for /dev/serial/by-id/ to be created"); + std::this_thread::sleep_for(1s); + } + recv_topic_ = this->declare_parameter("recv_topic", "vision_recv_data"); send_topic_ = this->declare_parameter("send_topic", "vision_send_data"); control_id_ = static_cast(this->declare_parameter("control_id", 1.0f)); @@ -19,13 +29,11 @@ void UartNode::run() serial_codec_ = new SerialCodec(shared_from_this()); callback_group1_ = create_callback_group(rclcpp::CallbackGroupType::Reentrant); callback_group2_ = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive); - pub_ = create_publisher(recv_topic_, rclcpp::SensorDataQoS()); - timer_ = create_wall_timer( - std::chrono::milliseconds(10), std::bind(&UartNode::timer_callback, shared_from_this()), callback_group1_ - ); + pub_ = create_publisher(recv_topic_, rclcpp::SensorDataQoS()); + auto sub_option = rclcpp::SubscriptionOptions(); sub_option.callback_group = callback_group2_; - sub_ = create_subscription( + sub_ = create_subscription( send_topic_, rclcpp::ServicesQoS(), std::bind(&UartNode::sub_callback, shared_from_this(), std::placeholders::_1), @@ -40,12 +48,20 @@ void UartNode::run() // tf tf_broadcaster_ = std::make_shared(shared_from_this()); + + uart_thread_ = std::thread([this]() { + while(rclcpp::ok() && !stop_flag_) + { + timer_callback(); + } + RCLCPP_WARN(logger, "uart thread exit"); + }); } -void UartNode::sub_callback(hnurm_uart::msg::VisionSendData::SharedPtr msg) -{ - msg->vel_x = 2000.0; - msg->vel_y = 2000.0; +void UartNode::sub_callback(hnurm_interfaces::msg::VisionSendData::SharedPtr msg) +{ + msg->vel_x = 2000.0; + msg->vel_y = 2000.0; msg->vel_yaw = 2000.0; if(serial_codec_->send_data(*msg)) RCLCPP_INFO(logger, "send data"); @@ -53,7 +69,7 @@ void UartNode::sub_callback(hnurm_uart::msg::VisionSendData::SharedPtr msg) void UartNode::sub_twist_callback(geometry_msgs::msg::Twist::SharedPtr msg) { - hnurm_uart::msg::VisionSendData send_data; + hnurm_interfaces::msg::VisionSendData send_data; send_data.vel_x = static_cast(msg->linear.x); send_data.vel_y = static_cast(msg->linear.y); send_data.vel_yaw = static_cast(msg->angular.z); @@ -63,18 +79,10 @@ void UartNode::sub_twist_callback(geometry_msgs::msg::Twist::SharedPtr msg) void UartNode::timer_callback() { - hnurm_uart::msg::VisionRecvData recv_data; + hnurm_interfaces::msg::VisionRecvData recv_data; if(serial_codec_->try_get_recv_data_for(recv_data)) { - - //单云台机器人不需要验证 -// if(control_id_ != recv_data.control_id) -// { -// RCLCPP_WARN(logger, "control id not match, ignoring this msg %f[expected]!=%f[recv]", control_id_, recv_data.control_id); -// return; -// } - - if(recv_data.self_color.data == hnurm_uart::msg::SelfColor::COLOR_NONE) + if(recv_data.self_color.data == hnurm_interfaces::msg::SelfColor::COLOR_NONE) { RCLCPP_WARN(logger, "self color not set, ignoring this msg"); return; @@ -85,28 +93,39 @@ void UartNode::timer_callback() recv_data.header.frame_id = "serial"; pub_->publish(recv_data); RCLCPP_INFO(logger, "recv data: %f, %f, %f", recv_data.pitch, recv_data.yaw, recv_data.roll); - // pub transform - geometry_msgs::msg::TransformStamped transform; - transform.header.stamp = now(); - transform.header.frame_id = "gimbal_link"; - transform.child_frame_id = "imu_link"; - - tf2::Quaternion q; - Eigen::Quaternionf q_eigen; - q.setEuler( - angles::from_degrees(recv_data.yaw), // - angles::from_degrees(recv_data.pitch), // - angles::from_degrees(recv_data.roll) - ); - transform.transform.rotation.x = q.x(); - transform.transform.rotation.y = q.y(); - transform.transform.rotation.z = q.z(); - transform.transform.rotation.w = q.w(); - transform.transform.translation.x = 0.0; - transform.transform.translation.y = 0.0; - transform.transform.translation.z = 0.0; - // pub - tf_broadcaster_->sendTransform(transform); + } + else + { + if(error_cnt_++ > 100) + { + std::thread([this]() { re_launch(); }).detach(); + } + std::this_thread::sleep_for(10ms); } } + +void UartNode::re_launch() +{ + stop_flag_ = true; + uart_thread_.join(); + stop_flag_ = false; + + // check if /dev/serial/by-id/ is created + while(!std::filesystem::exists("/dev/serial/by-id/")) + { + RCLCPP_WARN(logger, "Waiting for /dev/serial/by-id/ to be created"); + std::this_thread::sleep_for(1s); + } + + error_cnt_ = 0; + serial_codec_->init_port(); + uart_thread_ = std::thread([this]() { + while(rclcpp::ok() && !stop_flag_) + { + timer_callback(); + } + RCLCPP_WARN(logger, "uart thread exit"); + }); +} + } // namespace hnurm