From 593cb37cf71ce4f0ad0a8e557acad7466298a47d Mon Sep 17 00:00:00 2001 From: LLida <3199335945@qq.com> Date: Thu, 4 Dec 2025 19:58:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=E6=AF=8F=E6=AC=A1tt?= =?UTF-8?q?l=E6=9D=83=E9=99=90=E4=B8=8D=E8=B6=B3=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MindVisionMain.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/MindVisionMain.cpp b/src/MindVisionMain.cpp index 4b706b2..35b7f09 100644 --- a/src/MindVisionMain.cpp +++ b/src/MindVisionMain.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -62,11 +63,28 @@ 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(1280, 720); bool use_ttl = false; // Set to false to disable TTL communication + + if (Numbe == 0) { + // 执行 shell 命令(注意安全风险!) + int result = std::system("soude chmod 777 /dev/tty*"); + + // 可选:检查命令是否成功执行 + if (result == -1) { + std::cerr << "Failed to execute system command.\n"; + } else { + std::cout << "Permissions updated (if any tty devices exist).\n"; + } + + Numbe++; + } + + return 0; // Define optional resolution list (adjust based on camera support) std::vector resolutions = { cv::Size(320, 240), // Low resolution, high frame rate @@ -129,6 +147,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;