1

Is it possible to simultaneously display an image and the pixel,coordinate values based on the mouse pointer positions?

I am asking an OpenCV equivalent of imview function in MATLAB.

Karthik Murugan
  • 1,595
  • 4
  • 19
  • 26

4 Answers4

1

You don't need Qt to do that. Just use default OpenCV function imshow to show image and SetMouseCallback to set callback on mouse click.

ArtemStorozhuk
  • 8,715
  • 4
  • 35
  • 53
1

It can be done using mouse call back events. You can find a good example in \opencv\samples\cpp\grabcut.cpp

nisssal
  • 111
  • 4
1

I had a few problems trying to do this with OpenCV alone using an old code I wrote a while back. At this point I'm not sure if I missed something or if it's a bug in OpenCV. I'll investigate this further.

But I shared a short, self contained, correct (compilable), example at my repository, check cvImage. It's written in C++ with Qt and OpenCV. It's a Qt application that loads an image with OpenCV and displays the RGB values as the title of the Qt window.

Move the mouse around and place the cursor on top of the pixel that you are interested at to see it's RGB value.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Thank you @karlphillip. I have installed Qt creator. **Should I download and add/build any library for Qt?** If it is not required for simple display purposes, when will it be needed? How to check if I have Qt library is already present or not?(I dont remember what libraries i installed, since i did it from ubuntu software center as part of ROS). Also, **can i use the same libraries of ROS-opencv for any project or should I install opencv separately as a standalone **(**Will problems be created if I install opencv separately due to ROS-opencv?**) – Karthik Murugan Feb 17 '13 at 07:22
  • Qt Creator is just the IDE. [Qt is a cross-platform application framework](http://qt-project.org/downloads), which means you must download it's headers and libraries to be able to compile my code, but to run it, you'll only need Qt libraries installed on the system. If Qt is already installed you should have a command-line tool named `qmake`. If you can execute it then Qt is installed on your system. I believe you can use ROS-opencv, but I've never tried it myself. – karlphillip Feb 17 '13 at 13:45
  • After installing Qt you need to adjust a few settings on my code: edit `cvImage.pro` and make sure *OpenCV settings for Unix/Linux* are OK for your system. After that, execute `qmake` on the same directory as the .pro file and then you can execute `make` to compile the application. I just updated a few things on the source code, I suggest you download my code again. – karlphillip Feb 17 '13 at 14:22
  • Thank you @karlphillip.. Qt is installed in my computer. Checked using qmake -v... I have not yet tried using the IDE and your code since I am not familiar with the configuring of IDE. Can you suggest any link to start using Qt?? – Karthik Murugan Feb 17 '13 at 14:28
  • Just open a terminal (console) and `cd` into the directory where `cvImage.pro` is. Then execute `qmake` followed by `make` to build the application. If you want to use Qt Creator to compile the application [check these tutorials](http://qt-project.org/doc/qt-4.8/tutorials.html#qt-creator-tutorial). But there are many more out there, you can Google them. – karlphillip Feb 17 '13 at 14:34
-1

Opencv with Qt support will do that.

isrish
  • 692
  • 6
  • 12