Compare commits
5 Commits
eb32ca121d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e21138668 | |||
| 8728fd88e5 | |||
| 593cb37cf7 | |||
| 79c07e85bb | |||
| 3aff16a9e0 |
@@ -75,4 +75,7 @@ make -j$(nproc)
|
|||||||
1. 检查相机是否正确连接
|
1. 检查相机是否正确连接
|
||||||
2. 确认MindVision相机驱动是否正确安装
|
2. 确认MindVision相机驱动是否正确安装
|
||||||
3. 验证相机ID是否正确
|
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**
|
||||||
|
|||||||
@@ -319,8 +319,8 @@ bool MindVisionCamera::set_resolution(int width, int height){
|
|||||||
res.iIndex = 0xFF;
|
res.iIndex = 0xFF;
|
||||||
res.iWidth = width;
|
res.iWidth = width;
|
||||||
res.iHeight = height;
|
res.iHeight = height;
|
||||||
res.iWidthFOV = res.iWidth;
|
res.iWidthFOV = capability.sResolutionRange.iWidthMax;
|
||||||
res.iHeightFOV = res.iHeight;
|
res.iHeightFOV = capability.sResolutionRange.iHeightMax;
|
||||||
res.iHOffsetFOV = 0;
|
res.iHOffsetFOV = 0;
|
||||||
res.iVOffsetFOV = 0;
|
res.iVOffsetFOV = 0;
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ bool MindVisionCamera::set_resolution(int width, int height){
|
|||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
image_resolution = res;
|
image_resolution = res;
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -29,8 +30,14 @@ void output_control_data(const cv::Point2f* ballistic_point,
|
|||||||
std::ostringstream send_str;
|
std::ostringstream send_str;
|
||||||
|
|
||||||
// Calculate offset (based on actual image center)
|
// Calculate offset (based on actual image center)
|
||||||
int ballistic_offset_x = static_cast<int>(ballistic_point->x - img_center.x);
|
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);
|
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
|
// Color simplification mapping
|
||||||
std::string simplified_color = target_color;
|
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";
|
else if (target_color == "blue") simplified_color = "b";
|
||||||
|
|
||||||
// Construct send string
|
// 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
|
// Send data
|
||||||
if (ttl_communicator != nullptr) {
|
if (ttl_communicator != nullptr) {
|
||||||
@@ -62,11 +69,20 @@ void set_camera_resolution(MindVisionCamera& camera, int width, int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int /*argc*/, char* /*argv*/[]) {
|
int main(int /*argc*/, char* /*argv*/[]) {
|
||||||
|
static int Numbe = 0;
|
||||||
std::string target_color = "red";
|
std::string target_color = "red";
|
||||||
int cam_id = 0;
|
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
|
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)
|
// Define optional resolution list (adjust based on camera support)
|
||||||
std::vector<cv::Size> resolutions = {
|
std::vector<cv::Size> resolutions = {
|
||||||
cv::Size(320, 240), // Low resolution, high frame rate
|
cv::Size(320, 240), // Low resolution, high frame rate
|
||||||
@@ -129,6 +145,7 @@ int main(int /*argc*/, char* /*argv*/[]) {
|
|||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
// 使用新的颜色过滤方法同时获取图像和原始掩码
|
// 使用新的颜色过滤方法同时获取图像和原始掩码
|
||||||
|
|
||||||
cv::Mat raw_mask;
|
cv::Mat raw_mask;
|
||||||
if (!camera.read_frame_with_color_filter(frame, raw_mask, target_color)) {
|
if (!camera.read_frame_with_color_filter(frame, raw_mask, target_color)) {
|
||||||
std::cout << "Cannot read from MindVision camera, exiting!,HERERER" << std::endl;
|
std::cout << "Cannot read from MindVision camera, exiting!,HERERER" << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user