【问题标题】:OpenCV waitKey() should return -1 but didn'tOpenCV waitKey() 应该返回 -1 但没有
【发布时间】:2017-12-15 23:54:05
【问题描述】:

doc 中是这样说的

如果在指定的时间过去之前没有按下任何键,则返回按下的键的代码或 -1。

但是当我的 Ubuntu 14.04 设备上没有按键时,它返回 255 而不是 -1。这是为什么呢?

代码示例:

#include <opencv/cv.hpp>
#include <iostream>

using namespace cv;

int main(void) {
    Mat image = Mat::zeros(100, 100, CV_8UC3);
    char window_name[] = "waitKey() example";
    imshow(window_name, image);

    const int DELAY = 50;
    int c = waitKey(DELAY);
    std::cout << c << std::endl;
}

【问题讨论】:

  • 请发布您的代码!
  • 返回类型为int。如果您将其阅读为uchar,它将是 255 而不是 -1
  • 代码就是 imshow() 和 waitKey()
  • @Miki 不,我把它读作 int。
  • 这对我来说按预期工作

标签: c++ opencv


【解决方案1】:

最近对cv::waitKey()进行了一些代码修改,还有一个fix关于此问题尚未合并。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 2013-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多