免费试用:最火的人工智能查询工具
     最强AI人工智能聊天工具
     对话机器人解答疑难问题
星外智问直连原始API接口(GPT-4o)
➡️未登录受限条数,请登陆使用完整服务>>>➡️
请输入您要问的问题:


查下百度  查下必应

以下是单个问题的回复:

问:/sky/code/argo_gst_oatpp_zh/grabImage.cpp: In member function ‘int grabImage::start_get_img(const string&, const key_t&)’: /sky/code/argo_gst_oatpp_zh/grabImage.cpp:46:30: error: no match for ‘operator[]’ (operand types are ‘cv::Mat’ and ‘int’) 46 | putText(frame[1],"Commutation success ", Point(200,200), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0,255,0), 2);
GPT答: 7i24.cn
The error message is indicating that there is no `operator[]` defined for the `cv::Mat` object on line 46. 

In this line, you are trying to access the second channel of the `frame` matrix using the subscript operator (`[]`). However, OpenCV's `cv::Mat` does not support direct access to individual channels using this operator.

To fix this error, you can use the `cv::split()` function to split the multi-channel image into separate single-channel images and then access each channel individually. Here's an example:

```cpp
// Splitting channels
std::vector<cv::Mat> channels;
cv::split(frame, channels);

// Accessing second channel
putText(channels[1], "Commutation success", cv::Point(200, 200), cv::FONT_HERSHEY_SIMPLEX, 1.0, cv::Scalar(0, 255, 0), 2);
```

Make sure to include `<opencv2/core.hpp>` and `<opencv2/imgproc.hpp>` headers at the top of your file for these functions and types.

Alternatively, if you only need to display text on a single-channel image (e.g., grayscale image), you can convert your multi-channel image (`frame`) into a single-channel image before accessing it:

```cpp
// Converting frame to grayscale
cv::Mat grayFrame;
cvtColor(frame, grayFrame , cv:COLOR_BGR2GRAY);

// Accessing converted grayscale frame
putText(grayFrame , "Commutation success", cv:Point(200 ,200) , FONT_HERSHEY_SIMPLEX ,1 .0,cv:Scalar(0 ,255 ,0) ,2);
```

Again make sure to include `<opencv2/core.hpp>` and `<opencv2/imgproc.hpp>` headers at the top of your file for these functions and types.
一星  二星  三星  四星  五星 

互联网非法外之地,请不要输入不良内容
 查下百度 查下必应 06-20 14:50:06



chatGPT中国版--星外智问--8v6.CN
当前运行网址:haoadm.com
客服微信:xwgdd_com APP下载 怎么问 识别真假GPT4 使用GPT赚钱 退出登陆