OpenCV error on cvShowImage not declared

Problem

I tried to compile some code that uses OpenCV and got this error:

foo.cpp:275:25: error: ‘cvShowImage’ was not declared in this scope
foo.cpp:532:29: error: ‘cvSaveImage’ was not declared in this scope
foo.cpp:556:45: error: ‘cvLoadImage’ was not declared in this scope

That is, the compiler is not able to find the declarations of cvShowImage, cvSaveImage and cvLoadImage. This code used to compile without errors in older versions of OpenCV.

Solution

In newer versions of OpenCV, these declarations are in the highgui.h header file and it needs to be explicitly included:

#include <opencv/highgui.h>

Tried with: OpenCV 2.4.9 and Ubuntu 12.04 LTS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.