修正了每次ttl权限不足的问题

This commit is contained in:
2025-12-04 19:58:14 +08:00
parent 79c07e85bb
commit 593cb37cf7

View File

@@ -1,3 +1,4 @@
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
@@ -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<cv::Size> 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;