在Webots中使用OpenCV的'imshow'绘制图像

时间:2019-02-06 14:58:41

标签: qt opencv webots

嗨,我在webots中使用opencv,我想绘制图像。这是控制器:

#include <webots/Robot.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>

using namespace webots;
using namespace cv;

int main(int argc, char **argv){

  Robot *robot = new Robot();
  int timeStep = (int) robot->getBasicTimeStep();

  while (robot->step(timeStep) != -1) {
      Mat a1 = imread("/home/alireza/Desktop/1.jpg");
      cv::imshow("test",a1);
  };

  delete robot;
  return 0;
}  

这是生成文件:

OPENCV = `pkg-config opencv --cflags --libs` 
LIBRARIES = $(OPENCV) 
space :=
space +=
WEBOTS_HOME_PATH=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME))))
RESOURCES_PATH = $(WEBOTS_HOME)/projects/robots/robotis

CXX_SOURCES = $(wildcard *.cpp)
include $(WEBOTS_HOME_PATH)/resources/Makefile.include

我成功完成了它,但是当我想运行它时,我遇到了一个关于Qt的运行时错误:

[co] qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
[co] This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

我真的需要帮助。

0 个答案:

没有答案