A .NET 6 ASP.NET Core application that provides a WebSocket server for capturing photos from Canon EOS cameras using the Canon EOS Digital SDK.
This application creates a WebSocket server that:
- Automatically connects to a connected Canon EOS camera
- Takes photos on demand via WebSocket connection
- Returns the file path of captured images to connected clients
- Saves photos to the user's Pictures folder under
RemotePhotosubdirectory
┌─────────────────┐ WebSocket ┌──────────────────┐ EDSDK ┌────────────────┐
│ Client (Web) │◄──────────────────►│ CameraWebSocket │◄──────────────►│ Canon Camera │
└─────────────────┘ wss://localhost └──────────────────┘ └────────────────┘
:42069/ws
| File | Description |
|---|---|
Program.cs |
Entry point, WebSocket server setup, handles client connections |
CameraHelper.cs |
Canon EOS SDK integration, photo capture logic |
- .NET 6.0 SDK or later
- Canon EOS Digital SDK (EDSDKLib)
- A compatible Canon EOS camera connected via USB
- Windows OS (Canon EDSDK is Windows-only)
- EDSDKLib - Canon EOS Digital SDK wrapper library (referenced from
../EDSDKLib-1.1.2/EDSDKLib)
Make sure you have the Canon EOS Digital SDK installed and the EDSDKLib project is available at ../EDSDKLib-1.1.2/EDSDKLib/.
dotnet build CameraWebSocket.slncd CameraWebSocket
dotnet runThe server will start at https://localhost:42069.
wss://localhost:42069/ws
- Connect to the WebSocket endpoint
- The server automatically:
- Opens a session with the first detected Canon camera
- Takes a photo using current camera settings
- Downloads the image to
%USERPROFILE%\Pictures\RemotePhoto\ - Returns the full file path of the saved image
- Photo capture repeats every 5 seconds while the connection is open
Each message is a UTF-8 encoded string containing the absolute file path of the captured photo:
C:\Users\YourName\Pictures\RemotePhoto\IMG_1234.CR2
- Auto-detection: Waits for camera connection if not already connected
- Session management: Opens and manages camera sessions automatically
- Photo capture: Supports both normal and bulb mode photography
- Image download: Automatically downloads captured images to host PC
The application uses the camera's current settings. To use bulb mode, set the camera's Tv (shutter speed) value to Bulb.
| Setting | Value | Location |
|---|---|---|
| Server URL | https://localhost:42069 |
Program.cs |
| Image Save Path | %USERPROFILE%\Pictures\RemotePhoto |
CameraHelper.cs |
| Photo Interval | 5000ms | Program.cs |
camera-web-socket/
├── CameraWebSocket.sln # Solution file
├── CameraWebSocket/
│ ├── Program.cs # WebSocket server & entry point
│ ├── CameraHelper.cs # Canon SDK camera operations
│ ├── CameraWebSocket.csproj # Project configuration
│ ├── appsettings.json # App configuration
│ └── Properties/
│ └── launchSettings.json
└── README.md
- Ensure your Canon camera is connected via USB
- Make sure the camera is turned on and in "PC Connection" mode
- Check that no other application (like Canon EOS Utility) is using the camera
- Verify the server is running on port 42069
- Check that no firewall is blocking the connection
- For HTTPS, you may need to trust the development certificate
This project uses the Canon EOS Digital SDK. Please ensure you comply with Canon's SDK license terms.