Thread: AviCap tutorial?

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    30

    Question AviCap tutorial?

    Hello, I am going to make a application that can show live preview from a webcam, and after reading alot on the internet I think that Avicap is easier to learn than directshow.
    After googling on avicap I found some Visual Basic tutorials, But no c++ ones.
    First question: Can you use avicap in c++?
    Second: Are there any good tutorials on using avicap on the internet?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Like this you mean?
    avicap in c++ - Google Search
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    Did you find any tutorials that explain the basics of avicap from that search? I only got some tutorial in creating a wrapper for avicap live stream or a tutorial in vb...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well the concepts will be the same regardless of whether you use VB or C++.

    And the concept of a DLL wrapper will be relevant to all DLLs, and not something specific to avicap.

    Sooner or later, you have to start mixing and matching disparate sources of information yourself. There simply isn't a tutorial for everything on the web.

    If you've already googled sufficiently well already, then the chances are we're not going to fare much better at finding something "just right for you".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    So let's say there ain't any tutorial on this, how would I learn the very basics of usig avicap? Should I read the VB tutorials? Or maybe someone of you here maybe could explain some of the basics? Or are there some kind of documentation or something?

    /Daniel

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Sure, read the VB tutorials.

    But don't worry too much about the syntactic details of any code, but pay more attention to which API calls are being made.

    Reading code in other languages is a useful skill, even if you've got no intention of actually writing anything. VB is verbose enough that you should be able to figure out what is going on without having to read a great deal.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    So I found this piece of code that I actually understand (the most of it anyway) so I will be able to learn something from it.
    The problem is just 2 errors that I think are very strange.

    (158): error C2065: 'true' : undeclared identifier
    (160): error C2065: 'true' : undeclared identifier

    Here is a piece of the code that I found:

    Code:
     case 1:
    {
    
     ShowWindow(camhwnd,SW_SHOW);
    
     SendMessage(camhwnd,WM_CAP_DRIVER_CONNECT,0,0);
     SendMessage(camhwnd, WM_CAP_SET_SCALE, true, 0);// Here is error 1
     SendMessage(camhwnd, WM_CAP_SET_PREVIEWRATE, 30, 0);
     SendMessage(camhwnd, WM_CAP_SET_PREVIEW, true, 0);// Here is error 2
    
    break;
    }
    I am really confused about this error.
    If someone could explain it to me, I would appreciate it.

    /Daniel

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    true and false are valid C++ code.
    Are you sure you're compiling C++?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    I am compiling in c++ yes, Visual c++ 2010 express edition .

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Make sure the filename ends in .cpp rather than .c, then. Or, alternatively, if you're supposed to pass an int as the third argument, then pass an int (like 1).

  11. #11
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    Oh, It was ending in .c , my bad. trying it as cpp now

  12. #12
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    Got some less strange errors this time:

    program.exe not found or not built by the last incremental link; performing full link
    1>ctl_one.obj : error LNK2019: unresolved external symbol _capCreateCaptureWindowA@32 referenced in function "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
    program .exe : fatal error LNK1120: 1 unresolved externals


    This part is creating a capture window:
    Code:
     camhwnd = capCreateCaptureWindow ("camera window", WS_CHILD , 0, 100, 300, 300, hwnd, 0);

  13. #13
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you believe that capCreateCaptureWindow exists, then you need to link with the library that contains it.

  14. #14
    Registered User
    Join Date
    Jan 2011
    Posts
    30
    vfw.h.
    already linked in the code

    Edit: Found this in msdn.microsoft:
    HWND VFWAPI capCreateCaptureWindow(
    LPCTSTR lpszWindowName,
    DWORD dwStyle,
    int x,
    int y,
    int nWidth,
    int nHeight,
    HWND hWnd,
    int nID
    );

    so there doesnt seem to be any wrong the the parameters.
    Last edited by Danne; 01-12-2011 at 03:06 PM.

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    vfw.h is not the library. According to capCreateCaptureWindow Function (Windows), the library is vfw32.dll.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My new website
    By joeprogrammer in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 03-17-2006, 07:38 PM
  2. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 01:41 AM
  3. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  4. Problem with tutorial (Vector class)
    By OdyTHeBear in forum C++ Programming
    Replies: 4
    Last Post: 12-18-2002, 02:49 PM
  5. My DirectInput tutorial....
    By jdinger in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-18-2002, 11:32 PM