修正了每次ttl权限不足的问题
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -62,11 +63,28 @@ 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(1280, 720);
|
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 命令(注意安全风险!)
|
||||||
|
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)
|
// 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 +147,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