PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
OpenCV 3.0 with VS2013 for x64-VBForums
Results 1 to 4 of 4

Thread: OpenCV 3.0 with VS2013 for x64

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    62

    OpenCV 3.0 with VS2013 for x64

    Hi guys,

    My first time using OpenCV 3.0 using C++ in Visual Studio 2013 in an x64 platform, I managed to do the initialization part and it was all good.

    However, moving forward, I was trying out a simple webcam feed code using OpenCV 3.0 (which has pretty scarce tutorials). I was using a code obtained from Youtube (Supershok) as follows:

    c++ Code:
    1. #include <opencv2\highgui\highgui.hpp>
    2.  
    3. //displays video from a webcam
    4. //0 is built-in, 1 is external
    5. //press esc key to close
    6.  
    7. int main()
    8. {
    9.     cvNamedWindow("Streaming", CV_WINDOW_AUTOSIZE);
    10.     CvCapture* capture = cvCreateCameraCapture(1); //0 = built-in, 1 = external
    11.     IplImage* frame;
    12.     while (1) {
    13.         frame = cvQueryFrame(capture);
    14.         if (!frame) break;
    15.         cvShowImage("Streaming", frame);
    16.         char c = cvWaitKey(33);
    17.         if (c == 27) break;
    18.     }
    19.     cvReleaseCapture(&capture);
    20.     cvDestroyWindow("Streaming");
    21.     return 0;
    22. }
    The error I got is this:
    error LNK1112: module machine type 'X86' conflicts with target machine type
    I suppose we can change the project settings but the options to change it to x64 is not there. Also, I have looked in the stackoverflow answers but it didn't work out for me, which I suspect might be a different issue altogether although he had the same error.

    I suppose there are syntax/code migration issues here, but can anyone point me in the right direction?

    Thanks!
    Vizier87
    Last edited by Vizier87; Jul 5th, 2015 at 10:34 PM.

  2. #2
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    652

    Re: OpenCV 3.0 with VS2013 for x64

    You have a conflict of machine types in your project configuration. For x64 build, in Build/Configuration Manager, the Active Solution Platform should be X64. In Project/Properties/Configuration Properties/Linker/Advanced, should be Machine64.

    I suspect you're set Linker to Machine64 but haven't set Active Solution Platform. Note that in Active Solution Platform if X64 isn't shown then you need to choose <new> and select x64 from the new platform drop down list.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.5.3)

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    62

    Re: OpenCV 3.0 with VS2013 for x64

    Hi 2kaud, thanks for the reply. Actually I didn't miss that part per se, however you're right. I didn't consider that option since the x64 option kinda didn't show up in the Config Manager. Something mysterious happened and somehow the x64 option appeared. Didn't know what I missed. I tweaked the code a bit where I commented on the line and hey presto (The trick is, if you don't have a default webcam and having an external webcam instead, select 0 anyway on the cvCreateCameraCapture(x) function):

    c++ Code:
    1. #include <opencv2\highgui\highgui.hpp>
    2.  
    3. //displays video from a webcam
    4. //0 is built-in, 1 is external
    5. //press esc key to close
    6.  
    7. int main()
    8. {
    9.     cvNamedWindow("Streaming", CV_WINDOW_AUTOSIZE);
    10.     CvCapture* capture = cvCreateCameraCapture(0);  //0 = built-in, 1 = external, however in this case it seems having no default webcam, select 0.
    11.     IplImage* frame;
    12.     while (1) {
    13.         frame = cvQueryFrame(capture);
    14.         if (!frame) break;
    15.         cvShowImage("Streaming", frame);
    16.         char c = cvWaitKey(33);
    17.         if (c == 27) break;
    18.     }
    19.     cvReleaseCapture(&capture);
    20.     cvDestroyWindow("Streaming");
    21.     return 0;
    22. }

    Now the code works and I managed to start a simple Webcam feed via the code, but the console mentioned:
    "Failed to load OpenCL at runtime <Expected version 1.1+>".
    Wonder what that was all about. I'll do more digging and hopefully get to the cool parts soon.
    Last edited by Vizier87; Jul 8th, 2015 at 03:26 AM.

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: OpenCV 3.0 with VS2013 for x64

    Hi there,
    you may be interested in the C++ bindings for OpenCV, your example is using the C interface. One is not better than the other so it is a matter of personal preference.
    Code:
    #include <opencv2/core/core.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <opencv2/highgui/highgui.hpp>
    
    int main(int argc, char* argv[])
    {
    	using namespace cv;
    
    	VideoCapture cap(0); // open the default camera
    	if (!cap.isOpened())  // check if we succeeded
    		return -1;
    
    	Mat frame;
    	namedWindow("capture", 1);
    	for (;;)
    	{
    		cap >> frame; // get a new frame from camera
    		imshow("capture", frame);
    		if (waitKey(1) >= 0) // check for keyboard input
    			break;
    	}	
    	return 0;
    }
    I would not worry too much about the OpenCL warning, most of OpenCV will function without it. You might make it go away by installing the latest drivers for graphics card or checking to see if the vendor provides separate drivers for OpenCL.

    W o t . S i g

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width