Compare commits

5 Commits

Author SHA1 Message Date
lyf
1e21138668 格式修正 2025-12-04 22:48:31 +08:00
lyf
8728fd88e5 坐标变化 2025-12-04 20:26:55 +08:00
593cb37cf7 修正了每次ttl权限不足的问题 2025-12-04 19:58:14 +08:00
lyf
79c07e85bb 添加一个SDK获取代码 2025-12-04 13:04:31 +08:00
3aff16a9e0 解决了画面不全的问题,并且提高了分辨率,画面更全 2025-12-02 21:28:58 +08:00
3 changed files with 28 additions and 8 deletions

View File

@@ -75,4 +75,7 @@ make -j$(nproc)
1. 检查相机是否正确连接
2. 确认MindVision相机驱动是否正确安装
3. 验证相机ID是否正确
4. 检查权限可能需要将用户添加到video组
4. 检查权限可能需要将用户添加到video组
## MindVision-SDK
`Linux`: >**wget https://www.mindvision.com.cn/wp-content/uploads/2023/08/linuxSDK_V2.1.0.37.tar.gz**

View File

@@ -319,8 +319,8 @@ bool MindVisionCamera::set_resolution(int width, int height){
res.iIndex = 0xFF;
res.iWidth = width;
res.iHeight = height;
res.iWidthFOV = res.iWidth;
res.iHeightFOV = res.iHeight;
res.iWidthFOV = capability.sResolutionRange.iWidthMax;
res.iHeightFOV = capability.sResolutionRange.iHeightMax;
res.iHOffsetFOV = 0;
res.iVOffsetFOV = 0;
@@ -329,7 +329,7 @@ bool MindVisionCamera::set_resolution(int width, int height){
this->width = width;
this->height = height;
image_resolution = res;
return false;
return true;
}
return false;
}

View File

@@ -1,3 +1,4 @@
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
@@ -29,8 +30,14 @@ void output_control_data(const cv::Point2f* ballistic_point,
std::ostringstream send_str;
// Calculate offset (based on actual image center)
int ballistic_offset_x = static_cast<int>(ballistic_point->x - img_center.x);
int ballistic_offset_y = static_cast<int>(img_center.y - ballistic_point->y);
int ballistic_offset_x = -static_cast<int>(ballistic_point->x - img_center.x);
if ( abs(ballistic_offset_x) > 320){
ballistic_offset_x = ( ballistic_offset_x / abs( ballistic_offset_x ) ) * 320 ;
}
int ballistic_offset_y = -static_cast<int>(img_center.y - ballistic_point->y);
if ( abs(ballistic_offset_y) > 180 ) {
ballistic_offset_y = ( ballistic_offset_x / abs( ballistic_offset_x ) ) * 180 ;
}
// Color simplification mapping
std::string simplified_color = target_color;
@@ -38,7 +45,7 @@ void output_control_data(const cv::Point2f* ballistic_point,
else if (target_color == "blue") simplified_color = "b";
// Construct send string
send_str << "s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y) << "\n";
send_str << "#s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y) << "*\n";
// Send data
if (ttl_communicator != nullptr) {
@@ -62,11 +69,20 @@ void set_camera_resolution(MindVisionCamera& camera, int width, int height) {
}
int main(int /*argc*/, char* /*argv*/[]) {
static int Numbe = 0;
std::string target_color = "red";
int cam_id = 0;
cv::Size default_resolution(640, 480);
cv::Size default_resolution(1280, 720);
bool use_ttl = false; // Set to false to disable TTL communication
if (Numbe == 0) {
// 执行 shell 命令(注意安全风险!)
std::system("sudo chmod 777 /dev/tty*");
Numbe++;
}
return 0;
// Define optional resolution list (adjust based on camera support)
std::vector<cv::Size> resolutions = {
cv::Size(320, 240), // Low resolution, high frame rate
@@ -129,6 +145,7 @@ int main(int /*argc*/, char* /*argv*/[]) {
try {
while (true) {
// 使用新的颜色过滤方法同时获取图像和原始掩码
cv::Mat raw_mask;
if (!camera.read_frame_with_color_filter(frame, raw_mask, target_color)) {
std::cout << "Cannot read from MindVision camera, exiting!HERERER" << std::endl;