A: 

I suggest you run through OpenCV-2.1.0 Visual C++ 2010 on Windows 7 to make sure it works. It does not seem like you should have to build the OpenCV binaries yourself?

Steve Townsend
I have tried this already. It does not work when I try to use opencv_ffmpeg210d.dll , which is why I had to build the libraries myself.
Jyoti
@Jyoyi - do you have the same problem with the release binary (minus the 'd')?
Steve Townsend
When I use the Release binary, it just throws an error (again at the same LoadLibrary line of code, with an Access Violation). I have paralleled doing all the above steps and tests with the Release as well.
Jyoti
@Jyoti - have you tried the OpenCV wiki for this? Sounds like a problem with their shipped binaries, maybe others have hit it? VS2010 is not exactly an edge case.
Steve Townsend
I've hit the wiki for the install guides, and numerous searches (Google, in-wiki) didn't reveal much information. I only came to StackOverflow after I had exhausted all my option; for most people, it seemed building the binaries with Cmake fixed all their issues. For me, it did initially with the second block of code I put in my question above that only created an image. The problem came when I wanted to process a .AVI video using OpenCV.
Jyoti
Does that DLL load any others that might be the real problem? Try running `depends.exe` on it.
Steve Townsend
This post suggests copying the DLLs to \winnt\system32. Might be worth a try? http://electronic-salad.blogspot.com/2010/03/install-opencv20-for-windows.html
Steve Townsend
I tried copying all my DLLs into Windows\system32. Even when opencv_ffmpeg210d.dll gets processed from system32, the manifest error is still present and an access violation is still called on Debug and Release versions (respectively). I'm still not sure what to do.
Jyoti
I edited the question to make it easier to read and to show all the steps I've taken thus far. Still no luck working with the code yet.
Jyoti
A: 

[Sorry, not an answer, but not enough space in a comment]

I have the same problem. Windows 7 X64, VS2008 SP1, OpenCV2.1.

Code:

#include "stdafx.h"
#include "highgui.h"
int main(int argc, char** argv)
{
    cvNamedWindow("Example2",CV_WINDOW_AUTOSIZE);
    CvCapture* capture = cvCreateFileCapture(argv[1]);
    IplImage* frame;
    while(1) {
        frame=cvQueryFrame(capture);
        if (! frame) break;
        cvShowImage("Example2",frame);
        char c=cvWaitKey(1000);
        if (c==27) break;
    }
    cvReleaseCapture(&capture);
    cvDestroyWindow("Example2");
    return 0;
}

Notice the 1000mS pause. The first frame displays and then I get:

alt text

Two observations:

  1. If I logoff and logon again, the program works correctly ONCE. Re-executing crashes.
  2. Sometimes, I get this message in the console alt text

From the symptoms and the messages, I'm thinking it's a combination of alignment and a static variable that's not being re-initialised, or something on those lines.

If anyone can throw some light on this, I'd be most grateful, it's very frustrating to buy the book and not get past lesson 2.

smirkingman