| |

VerySource

 Forgot password?
 Register
Search
View: 624|Reply: 2

Failure encountered while establishing a video capture window

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Lithuania

Post time: 2020-1-2 19:30:01
| Show all posts |Read mode
When trying to establish a video capture through a USB camera, I encountered a failure, and the result was weird, because the program is very simple, using VFW, only 4 lines of program, and pressing F7 to compile also passed. The expected result is in the main dialog A video capture window appears in the box, but the actual result is that there is no such window in the main dialog box after pressing F5, the procedure is as follows:
#include <vfw.h>
// ==============================================
BOOL CVideoDlgDlg :: OnInitDialog ()
{
// ===============================================
// TODO: Add extra initialization here
hWndC = capCreateCaptureWindow ("Video", WS_CHILD | WS_VISIBLE, 0,0,320,240, m_hWnd, 0);
capDriverConnect (hWndC, 0);
capPreviewRate (hWndC, 30);
capPreview (hWndC, TRUE);
return TRUE; // return TRUE unless you set the focus to a control
}
In addition, the information returned by the execution of the program is as follows: Please give pointers to the experts for your guidance, be grateful!
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\avicap32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\winmm.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\msvfw32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\shell32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded symbols for 'D:\WINDOWS\system32\MFC42D.DLL'
Loaded symbols for 'D:\WINDOWS\system32\MSVCRTD.DLL'
Loaded symbols for 'D:\WINDOWS\system32\MFCO42D.DLL'
Loaded 'D:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\serwvdrv.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\umdmxfrm.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\mfc42loc.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\MSCTF.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\SynTPFcs.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\MSCTFIME.IME', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Latvia

 Author| Post time: 2020-7-1 09:00:01
| Show all posts
Does anyone care?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 United States

Post time: 2020-7-17 10:00:01
| Show all posts
Your question is a bit character, I don't understand what it is!
Go to the VC camera control SDK source code!


#include <windows.h>
#include <stdio.h>
#include <vfw.h>
#pragma comment(lib,"vfw32.lib")

HWND ghWndCap; //handle of capture window
CAPDRIVERCAPS gCapDriverCaps; //Capability of video driver
CAPSTATUS gCapStatus; //Capture the status of the window
char szCaptureFile[] = "MYCAP.AVI";
char gachBuffer[20];

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

LRESULT CALLBACK StatusCallbackProc(HWND hWnd, int nID, LPSTR lpStatusText)
{
if(!ghWndCap)return FALSE;//Get the status of the capture window
capGetStatus(ghWndCap,&gCapStatus,sizeof(CAPSTATUS));//Update the size of the capture window
SetWindowPos(ghWndCap,NULL,0,0,gCapStatus.uiImageWidth,gCapStatus.uiImageHeight,SWP_NOZORDER|SWP_NOMOVE);
if(nID==0){//Clear old status information
SetWindowText(ghWndCap,(LPSTR)"hello");
return (LRESULT)TRUE;
}//Display status ID and status text
wsprintf(gachBuffer,"Status# %d: %s",nID,lpStatusText);
SetWindowText(ghWndCap, (LPSTR) gachBuffer);
return (LRESULT)TRUE;
}
LRESULT CALLBACK ErrorCallbackProc(HWND hWnd, int nErrID, LPSTR lpErrorText)
{
if(!ghWndCap)return FALSE;
  if(nErrID==0) return TRUE;//Remove the old error
wsprintf(gachBuffer,"Error# %d",nErrID);//Display error ID and text
MessageBox(hWnd, lpErrorText, gachBuffer,MB_OK | MB_ICONEXCLAMATION);
return (LRESULT) TRUE;
}

LRESULT CALLBACK FrameCallbackProc(HWND hWnd,LPVIDEOHDR lpVHdr)
{
FILE *fp;
fp=fopen("caram.dat","w");
if(!ghWndCap) return FALSE;//Assume that fp is an open .dat file pointer
fwrite(lpVHdr->lpData,1,lpVHdr->dwBufferLength,fp);
return (LRESULT)TRUE;
}


int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
static TCHAR szAppName[]=TEXT("HelloWin");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This program requires WindowsNT!"),szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName, TEXT("The Hello Program"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
{
ghWndCap=capCreateCaptureWindow((LPSTR)"Capture Window",WS_CHILD|WS_VISIBLE,0,0,300,240,(HWND)hwnd,(int)0);
capSetCallbackOnError(ghWndCap,(FARPROC)ErrorCallbackProc);
capSetCallbackOnStatus(ghWndCap,(FARPROC)StatusCallbackProc);
capSetCallbackOnFrame(ghWndCap,(FARPROC)FrameCallbackProc);
capDriverConnect(ghWndCap,0); // Connect the capture window to the driver
//Get the ability of the driver, the relevant information is placed in the structure variable gCapDriverCaps
capDriverGetCaps(ghWndCap,&gCapDriverCaps,sizeof(CAPDRIVERCAPS));
capPreviewRate(ghWndCap, 66); // Set the display rate of Preview mode
capPreview(ghWndCap, TRUE); //Start Preview mode
if(gCapDriverCaps.fHasOverlay) //Check if the drive has overlay capability
capOverlay(ghWndCap,TRUE); //Start Overlay mode
if(gCapDriverCaps.fHasDlgVideoSource)capDlgVideoSource(ghWndCap); //Video source dialog
if(gCapDriverCaps.fHasDlgVideoFormat)capDlgVideoFormat(ghWndCap); // Video format dialog
if(gCapDriverCaps.fHasDlgVideoDisplay)capDlgVideoDisplay(ghWndCap); // Video display dialog
capFileSetCaptureFile( ghWndCap, szCaptureFile); //Specify the capture file name
capFileAlloc(ghWndCap, (1024L * 1024L * 5)); //allocate storage space for the capture file
capCaptureSequence(ghWndCap); //Start capturing video sequence
capGrabFrame(ghWndCap); //Capture single frame image

}

return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("Hello,Windows98!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
{
capSetCallbackOnStatus(ghWndCap, NULL);
capSetCallbackOnError(ghWndCap,NULL);
capSetCallbackOnFrame(ghWndCap, NULL);
capCaptureAbort(ghWndCap);//Stop capturing
capDriverDisconnect(ghWndCap); //Disconnect the capture window from the driver
PostQuitMessage(0);
}
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list