Hello ,

I need an approach for my new assignment.Thought a lot but could'nt find an approach so posting it in this site hoping that someone might have come accross this situation and can suggest me something :-)

I have a console application that downloads images from IP cameras (say cctv cameras in shoping Malls) as per the time specified in Database.
I am using windows service with a timer for initial POC.
I will try to explain the scenario for which I am not finding an approach:

Say I have four cemaras
1. Camera1
2. Camera2
3. Camera3
4. Camera4

Now as per the database records, I have to capture the image at exactly 7 AM in the morning for all the cameras.
Now my windows service can have one call at a time. If I loop through and call the request for camera1 first then I will get the 7 AM picture frame(image) for camera1. But till the request comes for camera4 the time will be different and I will not be able to capture image for camera4 at 7 Am, may be I will get the image of 7.05 AM.

I cannot create 4 windows service as how many cameras will be there is decided by the records in the database which I have to read dynamically, So there may be more then 4 cameras or even less then 4.

So my question is how can I have a 4 or even more calls simalteniously and get the picture frame of the specified time ?? There may be 100 cameras as well :-(

Hope I am able to explain the situation. Please let me know if you have come accross this kind of problem and have some idea about the solution.

Thanks & Regards,
Suraj

Dani AI

Generated

Capturing simultaneous frames from many IP cameras is a timing-and-distribution problem more than a pure threading problem: clocks, network latency and where the capture command runs determine whether a frame is genuinely from “07:00:00”. Both and made useful points — camera-side scheduling is ideal when available, and concurrency is required — so a production approach combines those ideas with reliability and timing controls.

A practical pattern:

  • A single scheduler (the Windows service) reads the DB and enqueues timestamped capture jobs in a persistent queue (SQL/MSMQ/RabbitMQ). Persisted jobs survive restarts and can be dispatched to many workers.
  • A pool of lightweight capture workers executes jobs using asynchronous I/O (non-blocking HTTP/RTSP calls) with a controlled concurrency limit (tuned to network and camera capacity). This avoids one-thread-per-camera and scales to hundreds.
  • For timing accuracy, sync clocks (NTP/PTP) on cameras and servers, measure per-camera RTT and either (a) ask cameras to snap at their own 07:00 if the camera supports it, or (b) schedule the worker to initiate the request just ahead of the target using the measured latency so the camera’s frame matches the wall time.

Operational details and cautions:

  • For large or WAN deployments, deploy small “edge” agents on the camera LAN so captures originate locally and are effectively simultaneous.
  • Persist both the camera-provided timestamp (from image metadata or camera API) and the server-receive timestamp so any skew/missed capture is detectable.
  • Log latency statistics, retry with backoff for transient failures, and expose metrics/alerts for missed scheduled captures.
  • If sub-second accuracy is required, use a scheduler with higher resolution than a coarse timer (or a library like Quartz.NET) and avoid naive looping timers.

This approach balances accuracy, scalability and reliability while building on ’s and ’s suggestions.

Recommended Answers

All 3 Replies

hmm most IP cameras have settings that let them take picture or recording at certain times. Just use the software provided to get the images in a certain folder. Then let your software take it from there, even if it take an hour, your 7 A.M. pics will be 7 A.M. as per the camera settings.

Maybe multithreading would help. Loop through database records and start a new thread for each request you have to do.

Ionut

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.