Ask Your Question

identifier 'imshow' and 'waitkey' is undefined

asked 2016-08-22 02:03:19 -0500

pariwesh07 gravatar image

updated 2016-08-22 02:41:22 -0500

LBerger gravatar image


I am trying to open the camera through opencv using 'uwp c++ blank template' in vs 2015. but i am getting error identifier 'imshow' is undefined and identifier 'waitkey' is undefined . i also install nuget package .which package did i exactly missing. code below

#include "pch.h"
#include "MainPage.xaml.h"

using namespace OpenCam_22aug;

using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

// The Blank Page item template is documented at
using namespace cv;
int main(int argc, char** argv)
    VideoCapture cap;
    // open the default camera, use something different from 0 otherwise;
    // Check VideoCapture documentation.
    if (!
        return 0;
    for (;;)
        Mat frame;
        cap >> frame;
        if (frame.empty()) break; // end of video stream
        imshow("this is you, smile! :)", frame);
        if (waitKey(1) == 27) break; // stop capturing by pressing ESC 
    // the camera will be closed automatically upon exit
    // cap.close();
    return 0;
edit retag flag offensive close merge delete


Please use icon with 101010 to for format your code

LBerger gravatar imageLBerger ( 2016-08-22 02:42:27 -0500 )edit

May be imshow in not defined in your system. What is your operating system and compiler opencv version?

LBerger gravatar imageLBerger ( 2016-08-22 02:52:27 -0500 )edit

my os is windows 10 and i am using nuget package manager to install opencv package it is v0.0.2-alpha and what is '101010' i am not getting can you elaborate.

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 03:41:06 -0500 )edit

About 101010 it is about your code in your post Before post you have to select your code and click in this code. You can see difference here

Now I have never use nuget and opencv 0.0.-2 alpha it is unknow version. Can you try this program with same include and give results?

int main()
return 0;
LBerger gravatar imageLBerger ( 2016-08-22 04:16:23 -0500 )edit

Thx for above information . Itried with the above code but following error is coming Severity Code Description Project File Line Suppression State Error LNK1181 cannot open input file 'opencv_calib3d310.lib'

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 04:32:45 -0500 )edit

I don't know nuget. If you install opencv from github and use CMake i can help you..

LBerger gravatar imageLBerger ( 2016-08-22 04:40:22 -0500 )edit

check this you will understand nuget link text

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 04:43:38 -0500 )edit

I understand now UWP : you want to make an universal windows application . I don't think that you can use imshow.

Check this sample.

About LNK1181 give manually path opencv_calib3d310.lib. (it is weird because it should be 2.4.10 version ?)

LBerger gravatar imageLBerger ( 2016-08-22 05:10:03 -0500 )edit

Thx a lot for your initiative to help me. i am checking out with sample if any issue i will contact you LBerger.

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 05:19:12 -0500 )edit

please, if you're a noob, try a non-managed (empty) project first.

managed c++ (what you're trying to use above) and opencv is not a marriage made in heaven, there's tons of (unnessecary) complications, please avoid those.

berak gravatar imageberak ( 2016-08-22 06:49:55 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-22 02:51:38 -0500

imshow is in the highgui-module: highgui so you have to include that.

edit flag offensive delete link more


i have included #include<opencv\highgui.h> but still error exist.

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 04:02:32 -0500 )edit

please try the following:

#include "opencv2\highgui\highgui.hpp"
Ice_T02 gravatar imageIce_T02 ( 2016-08-22 04:48:59 -0500 )edit

i tried but it is giving me following error: Severity Code Description Project File Line Suppression State Error LNK1181 cannot open input file 'opencv_calib3d310.lib'

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 05:03:18 -0500 )edit

which version do you run? are you sure your project property linking is correct? LNK1181 typically points toward an invalid linking to a library path. Maybe this one helps Link

Ice_T02 gravatar imageIce_T02 ( 2016-08-22 05:20:49 -0500 )edit

actually i am using vs 2015,windows 10 and using nuget package manager for installing opencv referlink text

pariwesh07 gravatar imagepariwesh07 ( 2016-08-22 05:39:09 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-08-22 02:03:19 -0500

Seen: 2,911 times

Last updated: Aug 22 '16