Skip to content

BackEnd socket for streaming Canon camera image to Desktop App or client

Notifications You must be signed in to change notification settings

joshuasir/camera-web-socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CameraWebSocket

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.

Overview

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 RemotePhoto subdirectory

Architecture

┌─────────────────┐     WebSocket      ┌──────────────────┐     EDSDK      ┌────────────────┐
│  Client (Web)   │◄──────────────────►│  CameraWebSocket │◄──────────────►│  Canon Camera  │
└─────────────────┘  wss://localhost   └──────────────────┘                └────────────────┘
                       :42069/ws

Key Components

File Description
Program.cs Entry point, WebSocket server setup, handles client connections
CameraHelper.cs Canon EOS SDK integration, photo capture logic

Prerequisites

  • .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)

Dependencies

  • EDSDKLib - Canon EOS Digital SDK wrapper library (referenced from ../EDSDKLib-1.1.2/EDSDKLib)

Getting Started

1. Install Canon EDSDK

Make sure you have the Canon EOS Digital SDK installed and the EDSDKLib project is available at ../EDSDKLib-1.1.2/EDSDKLib/.

2. Build the Solution

dotnet build CameraWebSocket.sln

3. Run the Application

cd CameraWebSocket
dotnet run

The server will start at https://localhost:42069.

WebSocket API

Endpoint

wss://localhost:42069/ws

Behavior

  1. Connect to the WebSocket endpoint
  2. 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
  3. Photo capture repeats every 5 seconds while the connection is open

Response Format

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

Camera Features

Supported Operations

  • 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

Camera Settings

The application uses the camera's current settings. To use bulb mode, set the camera's Tv (shutter speed) value to Bulb.

Configuration

Setting Value Location
Server URL https://localhost:42069 Program.cs
Image Save Path %USERPROFILE%\Pictures\RemotePhoto CameraHelper.cs
Photo Interval 5000ms Program.cs

Project Structure

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

Troubleshooting

"No camera found. Please plug in camera"

  • 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

WebSocket connection fails

  • 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

License

This project uses the Canon EOS Digital SDK. Please ensure you comply with Canon's SDK license terms.

About

BackEnd socket for streaming Canon camera image to Desktop App or client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages