Delphi_WebCam_Component
An easy to use Drag and drop VCL WebCam component!
- Active · last change 3-10-2026
- ★ 8 on GitHub
README
🎥 Delphi Webcam Capture Component
Professional DirectShow Webcam Capture Component for Delphi VCL
High-performance • Asynchronous • Thread-safe • Easy drop-in integration
A lightweight TWebcamCapture component that captures webcam frames as TBytes and delivers them safely on the main thread via events.
Designed for smooth UI behavior and straightforward integration in Delphi VCL apps.
🚀 Overview
- Device enumeration
- Camera selection by index
- Configurable resolution and frame rate
- JPEG or BMP frame output
- Threaded capture pipeline (UI stays responsive)
- Main-thread frame delivery via event callbacks
- Snapshot access via
GetSingleFrame
⭐ Key Features
🎥 Capture
- Capture webcam frames continuously
- Output frames as raw
TBytes(JPEG or BMP) - Track actual negotiated resolution and frame count
⚙️ Configuration
DeviceIndex,Width,Height,FrameRateImageFormat(wifJPEGorwifBMP)JPEGQuality(1..100)
🧵 Threading & Stability
- Dedicated capture thread for DirectShow/COM work
- UI callback delivery through queued main-thread events
- Startup handshake to avoid false “active” state
- Frame dispatch backpressure (prevents runaway UI queue)
🧩 Delphi Integration
- Registered as
TWebcamCaptureon the Webcam palette - Standard VCL component usage pattern
- Works cleanly with dropped VCL controls (
TImage,TTimer, etc.)
📦 Repository Contents
WebcamCapture.pas— Core component implementation.WebcamCaptureReg.pas— IDE component registration.WebcamComponents.dpk/.dproj— Package project.Demos/Basic Demo— Local preview, device selection, snapshot save.Demos/Network Webcam Streaming Demo— Webcam streaming over network (uses NetCom7 sources).
✅ Requirements
Core Component
- Delphi VCL (tested with Delphi 12.2 Athens toolchain)
- Windows desktop target
- DirectShow-capable system with camera drivers
Optional (Network Demo Only)
- NetCom7 source path configured for demo build
🔧 Installation
- Open
WebcamComponents.dprojin Delphi. - Build the package for your target (
Win32and/orWin64). - Install package in IDE.
- Drop
TWebcamCapturefrom the Webcam component palette.
⚡ Quick Start (Basic Usage)
1) Drop components on a VCL form
TWebcamCapture(WebcamCapture1)TImage(Image1)
2) Configure and start
procedure TForm1.FormCreate(Sender: TObject);
begin
WebcamCapture1.DeviceIndex := 0;
WebcamCapture1.Width := 640;
WebcamCapture1.Height := 480;
WebcamCapture1.FrameRate := 30;
WebcamCapture1.ImageFormat := wifJPEG;
WebcamCapture1.JPEGQuality := 85;
WebcamCapture1.Active := True;
end;
procedure TForm1.WebcamCapture1FrameReceived(Sender: TObject;
const FrameData: TBytes; Width, Height: Integer);
var
S: TMemoryStream;
begin
if Length(FrameData) = 0 then Exit;
S := TMemoryStream.Create;
try
S.WriteBuffer(FrameData[0], Length(FrameData));
S.Position := 0;
Image1.Picture.LoadFromStream(S);
finally
S.Free;
end;
end;📚 API Reference
Properties
| Property | Type | Description |
|---|---|---|
Active | Boolean | Start/stop capture |
DeviceIndex | Integer | Selected camera index |
Width / Height | Integer | Requested capture size |
FrameRate | Integer | Requested FPS |
ImageFormat | TWebcamImageFormat | wifJPEG or wifBMP |
JPEGQuality | Integer | JPEG quality (1..100) |
ActualWidth / ActualHeight | Integer | Negotiated capture size |
FrameCount | Int64 | Number of captured frames |
LastFrameData | TBytes | Last captured encoded frame |
| Method | Description |
|---|---|
GetDevices | Returns available camera list |
RefreshDevices | Re-enumerates cameras |
GetSupportedResolutions | Queries camera-supported resolutions |
StartCapture / StopCapture | Manual control |
GetSingleFrame | Returns last captured frame bytes |
| Event | Description |
|---|---|
OnFrameReceived | New frame (TBytes, width, height) |
OnCaptureStarted | Capture session started |
OnCaptureStopped | Capture session stopped |
OnCaptureError | Capture error text |
OnDeviceListChanged | Device count changed |
Basic Demo
- Device enumeration and selection
- Live preview
- JPEG/BMP switch
- Snapshot saving
- FPS display
- Uses NetCom7
TncServerSource/TncClientSource - Broadcasts captured frames to remote clients
- Shows practical frame transport over TCP
Core Component
- No third-party runtime DLL required by this repo itself.
- Uses Windows COM/DirectShow APIs and system codecs.
- Windows desktop only (VCL + WinAPI/COM)
- Win32 and Win64 build targets supported
- Not intended for FMX/mobile platforms
- Camera privacy settings can block access if not allowed
“No webcam devices detected”
- Verify camera is connected and not disabled
- Check Device Manager
- Check Windows camera permissions
- Another app may already own the camera
- Driver may not expose expected DirectShow path
- Try a different
DeviceIndexor lower requested resolution/FPS
- Ensure
OnFrameReceivedhandler is correctly assigned - Use
Image1.Picture.LoadFromStream(...)forTBytespayloads

