Ask Your Question

Problem with IPL image and imshow

asked 2015-05-11 04:34:23 -0500

spinter696 gravatar image

updated 2015-05-11 04:36:18 -0500

Hi I want to show an IPL image created but with imshow I am having problems, I was searching how to solve that error but I didn't find anything.... so if someone could help me I would be very please. I am in a raspberry pi, using opencv 3.0.0 I know is better use Mat know but I didnt know hot to convert an Image captured by other API to a Mat object and not and IPL

#include <uEye.h>
#include <ueye_deprecated.h>
#include <wchar.h>
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main(int argc, char *argv[])
rest of code

if(is_FreezeVideo(hCam, IS_WAIT) == IS_SUCCESS){
        void *pMemVoid; //pointer to where the image is stored
        is_GetImageMem (hCam, &pMemVoid);
        IplImage * img;
        img=cvCreateImage(cvSize(img_width, img_height), IPL_DEPTH_8U, 3); 
        img->imageData=(char*)pMemVoid;  //the pointer to imagaData
        img->imageDataOrigin=(char*)pMemVoid; //and again
        //now you can use your img just like a normal OpenCV image
        namedWindow( "A", 1 );
  rest of code

Error is the next:

$ g++ -Wall -I/usr/lib -o main main.cpp -lueye_api
main.cpp: In function 'int main(int, char**)':
main.cpp:100:31: error: no matching function for call to 'imshow(const char [2], IplImage*&)'
main.cpp:100:31: note: candidates are:
/usr/local/include/opencv2/highgui.hpp:305:19: note: void cv::imshow(const cv::String&, cv::InputArray)
/usr/local/include/opencv2/highgui.hpp:305:19: note:   no known conversion for argument 2 from        'IplImage* {aka _IplImage*}' to 'cv::InputArray {aka const cv::_InputArray&}'
/usr/local/include/opencv2/highgui.hpp:488:17: note: void cv::imshow(const cv::String&, const     cv::ogl::Texture2D&)
/usr/local/include/opencv2/highgui.hpp:488:17: note:   no known conversion for argument 2 from 'IplImage* {aka _IplImage*}' to 'const cv::ogl::Texture2D&'
edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2015-05-11 04:59:24 -0500

berak gravatar image

updated 2015-05-11 05:40:20 -0500

please avoid using IplImage* , or , anything from opencv's arcane c-api.

instead, stick to using cv::Mat consistently.

(wherever you found that code, it's horribly outdated)

i think, you want this instead:

    void *pMemVoid; //pointer to where the image is stored
    is_GetImageMem (hCam, &pMemVoid);

    cv::Mat image(height, width, CV_8UC3, (uchar*)pMemVoid);
    cv::imshow("lalala", image);

also, since you mention opencv3.0, please:

#include <opencv2/opencv.hpp>
edit flag offensive delete link more

answered 2015-05-11 05:32:54 -0500

spinter696 gravatar image

updated 2015-05-11 05:36:57 -0500

I tryed that befores posting butI obtain the next error: /tmp/ccxslput.o: In the function main': main.cpp:(.text+0x354): reference tocv::namedWindow(cv::String const&, int)' without definition main.cpp:(.text+0x398): reference to cv::imshow(cv::String const&, cv::_InputArray const&)' without definition main.cpp:(.text+0x3b8): reference tocv::waitKey(int)' without definition /tmp/ccxslput.o: In the function cv::String::String(char const*)': main.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4c): reference tocv::String::allocate(unsigned int)' without definition /tmp/ccxslput.o: In the functioncv::String::~String()': main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): reference tocv::String::deallocate()' without definition /tmp/ccxslput.o: En la función `cv::Mat::Mat(int, int, int, void*, unsigned int)

edit flag offensive delete link more


you're not linking any of the required opencv libs

$ g++ -Wall -I/usr/lib -o main main.cpp -lueye_api -lopencv_core -lopencv_imgproc -lopencv_highgui

berak gravatar imageberak ( 2015-05-11 05:38:47 -0500 )edit

Linking in that way libraries give me the same error

spinter696 gravatar imagespinter696 ( 2015-05-11 05:46:30 -0500 )edit

try to find out, where the libs are , and add a -L/path/to/opencv/libs

(g++ unfortunately does not complain about non-found libs)

berak gravatar imageberak ( 2015-05-11 05:49:58 -0500 )edit

I have libs under /usr/lib g++ -Wall -I/usr/lib -o main main.cpp -L/usr/lib -lueye_api -lopencv_core -lopencv_imgproc -lopencv_highgui

that will be the correct one???

spinter696 gravatar imagespinter696 ( 2015-05-11 05:56:14 -0500 )edit

idk, where your opencv libs are.

berak gravatar imageberak ( 2015-05-11 06:18:57 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-05-11 04:34:23 -0500

Seen: 1,206 times

Last updated: May 11 '15