Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does the webcam image appear darker than when it's started from another application?
    primarykey
    data
    text
    <p>I am using the Windows API to take a picture with the attached webcam.</p> <p>All works fine except the picture captured is very dark. If I start the webcam in another application and then I capture with my application, all works fine. What am I doing wrong?</p> <p>Here is the code I use:</p> <pre><code>procedure TWebCam.Execute; //different thread var hand: THandle; fname: AnsiString; const WM_CAP_START = $0400; WM_CAP_DRIVER_CONNECT = $0400 + 10; WM_CAP_DRIVER_DISCONNECT = $0400 + 11; WM_CAP_SAVEDIB = $0400 + 25; WM_CAP_GRAB_FRAME = $0400 + 60; WM_CAP_STOP = $0400 + 68; WM_CAP_SET_PREVIEW = WM_CAP_START + 50; WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52; WM_CAP_SET_SCALE = WM_CAP_START + 53; begin FreeOnTerminate := True; fname := AnsiString(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'capture.bmp'); if FileExists(String(fname)) then DeleteFile(string(fname)); hand := capCreateCaptureWindowA('CapWindow32', WS_CHILD and WS_VISIBLE, 0, 0, 0, 0, frmMain.Handle, 0); if hand &lt;&gt; 0 then begin if SendMessage(hand, WM_CAP_DRIVER_CONNECT, 0, 0) &lt;&gt; 0 then begin SendMessage(hand,WM_CAP_SET_PREVIEWRATE,66,0); //tried some stuff that are not required but without any success SendMessage(hand, WM_CAP_SET_PREVIEW, 1, 0); Sleep(5000); SendMessage(hand, WM_CAP_GRAB_FRAME, 0, 0); SendMessage(hand, WM_CAP_SAVEDIB, 0, NativeInt(PAnsichar(fname))); SendMessage(hand, WM_CAP_DRIVER_DISCONNECT, 0, 0); SendMessage(hand, $0010, 0, 0); SendMessage(frmMain.Handle,WM_USER + 24,0,0); //notify main thread end else begin SendMessage(hand, $0010, 0, 0); Synchronize(NoWebcam); end; end else Synchronize(NoWebcam); end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload