Home > Back-end >  Now use directshow calls this method can't cameras photographed?
Now use directshow calls this method can't cameras photographed?

Time:09-20

I downloaded a use directshow call the Internet camera program, I run the executable file inside can realize the function of the photo, but after I compile program source code through, to run the program file has not taken the image, this what's going on, urgent urgent!!!!!!!!!!!!!!! The great god help me

CodePudding user response:

No photos procedure call camera can achieve preview is

CodePudding user response:

Why nobody

CodePudding user response:

This part of my original debugging, if you open the file is not a image file, not the correct display pictures, check the part of the code you write the file header, may have a problem, really not coming together to see the code,

CodePudding user response:

 

# include & lt; VFW. H>
HWND hWndC ghWndCap;
Void __fastcall TfmGoodsPhotoGet: : sbCheckVideoClick (TObject * Sender)
{
Bool bVFWFlag;
Int iVFWCount;

if(! BCheckVideoEnable)
{//sheath maerial open
HWndC=Panel8 - & gt; Handle;
//create a capture window, which gives priority to handle to the window hWnd
GhWndCap=capCreateCaptureWindow (" the Capture Window, "WS_CHILD | WS_VISIBLE,
0,0,352,298, hWndC, 0);

BVFWFlag=false;
IVFWCount=0;
While ((iVFWCount<1000) & amp; & (bVFWFlag==false))
{
BVFWFlag=capDriverConnect (ghWndCap, 0);
IVFWCount++;
}
If (bVFWFlag==true)
{
CAPDRIVERCAPS caps.
CapDriverGetCaps (ghWndCap, sizeof (caps), & amp; Caps);
If (caps. FHasOverlay) capOverlay (ghWndCap, TRUE);

CapPreviewScale (ghWndCap, 1);
CapPreviewRate (ghWndCap, 1000/24);//set the Preview mode of display rate
CapPreview (ghWndCap, TRUE);//start the Preview mode
BCheckVideoEnable=true;
SbCheckVideo - & gt; Caption="sheath maerial off";
SbCapture - & gt; Enabled=true;
}
}
The else
{//sheath maerial closed
If (ghWndCap)
{
CapPreview (ghWndCap, false);
CapCaptureStop (ghWndCap);
CapCaptureAbort (ghWndCap);
CapDriverDisconnect (ghWndCap);
: : DestroyWindow (ghWndCap);
GhWndCap=NULL;
BCheckVideoEnable=false;
SbCheckVideo - & gt; Caption="open sheath maerial";
SbCapture - & gt; Enabled=false;
}
}
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

The front is preview
Capture the following
[code=c

# include & lt; VFW. H>
HWND hWndC ghWndCap;
Void __fastcall TfmGoodsPhotoGet: : sbCheckVideoClick (TObject * Sender)
{
Bool bVFWFlag;
Int iVFWCount;

if(! BCheckVideoEnable)
{//sheath maerial open
HWndC=Panel8 - & gt; Handle;
//create a capture window, which gives priority to handle to the window hWnd
GhWndCap=capCreateCaptureWindow (" the Capture Window, "WS_CHILD | WS_VISIBLE,
0,0,352,298, hWndC, 0);

BVFWFlag=false;
IVFWCount=0;
While ((iVFWCount<1000) & amp; & (bVFWFlag==false))
{
BVFWFlag=capDriverConnect (ghWndCap, 0);
IVFWCount++;
}
If (bVFWFlag==true)
{
CAPDRIVERCAPS caps.
CapDriverGetCaps (ghWndCap, sizeof (caps), & amp; Caps);
If (caps. FHasOverlay) capOverlay (ghWndCap, TRUE);

CapPreviewScale (ghWndCap, 1);
CapPreviewRate (ghWndCap, 1000/24);//set the Preview mode of display rate
CapPreview (ghWndCap, TRUE);//start the Preview mode
BCheckVideoEnable=true;
SbCheckVideo - & gt; Caption="sheath maerial off";
SbCapture - & gt; Enabled=true;
}
}
The else
{//sheath maerial closed
If (ghWndCap)
{
CapPreview (ghWndCap, false);
CapCaptureStop (ghWndCap);
CapCaptureAbort (ghWndCap);
CapDriverDisconnect (ghWndCap);
: : DestroyWindow (ghWndCap);
GhWndCap=NULL;
BCheckVideoEnable=false;
SbCheckVideo - & gt; Caption="open sheath maerial";
SbCapture - & gt; Enabled=false;
}
}
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
] [/code]

CodePudding user response:

reference zzbinfo reply: 3/f
this part I was debugged, and if you open the file is not a image file, not the correct display pictures, check the code you write the file header, may have a problem, really not coming together to see the code,
main save photo code is this paragraph
BOOL SampleGrabberCB: : SaveBitmap (BYTE * pBuffer, long lBufferSize)
{
HANDLE hf=CreateFile (
M_szFileName GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, NULL, NULL);
If (hf==INVALID_HANDLE_VALUE) return 0;
//write file header
BITMAPFILEHEADER BFH;
Memset (& amp; BFH, 0, sizeof (BFH));
BFH. BfType='MB';
BFH. BfSize=sizeof (BFH) + lBufferSize + sizeof (BITMAPINFOHEADER);
BFH. BfOffBits=sizeof (BITMAPINFOHEADER) + sizeof (BITMAPFILEHEADER);
DWORD dwWritten=0;
WriteFile (hf, & amp; BFH, sizeof (BFH), & amp; DwWritten, NULL);
//write the bitmap format
BITMAPINFOHEADER bih.
Memset (& amp; Bih, 0, sizeof (bih));
Bih. BiSize=sizeof (bih);
Bih. BiWidth=lWidth;
Bih. BiHeight=lHeight;
Bih. BiPlanes=1;
Bih. BiBitCount=24;
WriteFile (hf, & amp; Bih, sizeof (bih), & amp; DwWritten, NULL);
//write the bitmap data
WriteFile (hf, pBuffer, lBufferSize, & amp; DwWritten, NULL);
The CloseHandle (hf);
return 0;
}

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related