I am working on a system that will analyze video frames from multiple cameras. Each camera will initialize a WCF session and be assigned a GUID for identification before sending video frames. The processing load is more than the server can accomplish in real time as the number of cameras grow. As such, I am writing a class to manage the data as it arrives in bursts from the motion activated cameras.
Each frame from the cameras must be analyzed in parallel with frames from the other cameras. Each of the cameras will be filling a queue with frames to manage the FIFO nature of the data.
Management of the Queues has left me searching for ideas. Initially I had intended to create a dictionary and insert each GUID-Queue pair. After working on the code for a while I am starting to think that this is not the best approach. Does anyone have any suggestions?
Some simplified sample code:
namespace DataCollection
{
[ServiceBehavior(Name = "ClientDataView", InstanceContextMode = InstanceContextMode.Single)]
public class DataCollectionService : IDataCollectionService
{
//Dictionary of Guid-Queue pairs
CameraCollection CameraArray = new CameraCollection();
public Guid RegisterCamera()
{
Guid ID = new Guid();
WorkQueue FrameQueue = new WorkQueue();
CameraArray.AddCamera(ID, FrameQueue)
return ID;
}
public bool SendData(Guid ID, FrameReady newFrame)
{
Frame dataFrame = newFrame.OpenFrame;
WorkQueue que = CameraArray.GetQueueReference(ID);
que.QueueFrame(dataFrame);
return true;
}
}
}
Currently if I hard-code everything for a set number of cameras the system works. Getting it to work with a variant number of cameras is more challenging. Any suggestions or advise would be appreciated.
.Net framewok 4 has a class called Parallel. This class has an extension method Foreach. With your collection, you can do something like Parallel.Foreach(collection,action),