2

hi I am using opencv in webots and I want to plot an image . This is the controller:

#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;
}  

and this is the makefile:

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

I make it successfully but when I want to run it I face a runtime error about 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.

I really need help.

S.kh
  • 45
  • 5
  • It seems you are on macOS and the problem is more related with your qt/opencv configuration. Did you manage to get a standalone opencv program plotting an image? – Olivier Michel Feb 07 '19 at 07:53
  • @OlivierMichel hello Olivier . no i am using ubuntu 16.04 and i can plot an image in a standalone opencv program . i think some thing is wrong with the webots library path but i have no idea how to solve it. – S.kh Feb 08 '19 at 23:26
  • In that case, can you try to `setenv QT_QPA_PLATFORM_PLUGIN_PATH=` where `` points to the contents of the `plugins` folder of the Qt installation used by opencv? That should fix the problem, – Olivier Michel Feb 10 '19 at 11:30

0 Answers0