public void DeleteCamera(CameraData camData) { CameraDictionary.Remove(CameraData.PathAndPrefix(camData)); }
void RemoveUnmovedVehicles(CameraData camera, List <ImageObject> objectList) { Dbg.Trace("Object count before removing parked: " + objectList.Count.ToString()); List <ImageObject> vehicles = new List <ImageObject>(); int nonVehicleObjects = 0; if (objectList != null && objectList.Count > 0) { foreach (ImageObject obj in objectList) { if (IsVehicle(obj)) { if (obj.Confidence > minVehicleConfidence) { vehicles.Add(new ImageObject(obj)); } } else { ++nonVehicleObjects; } } Dbg.Trace("non-vehicle objects before parking check: " + nonVehicleObjects.ToString()); List <ImageObject> allFoundVehicles = new List <ImageObject>(vehicles); int i = 0; /*List<Frame> recentFrames = null; * if (vehicles.Count > 0) * { * recentFrames = camera.FrameHistory.GetFramesInTimespan(TimeSpan.FromSeconds(5), DateTime.Now, TimeDirection.Before); * }*/ while (i < vehicles.Count) { bool removedOne = false; lock (_previousVehicles) { for (int j = 0; j < _previousVehicles.Count; j++) { if (vehicles[i].Label == _previousVehicles[j].Label) // In this case we only remove objects that are the same - A = car, B = car (not 100%, but what can we do?) { int targetOverlap = ParkedOverlap; bool foundParked = false; int overlap = AIAnalyzer.GetOverlap(vehicles[i], _previousVehicles[j]); if (overlap >= targetOverlap) // Shadows, etc. do cause event parked vehicles to shift in outline { Dbg.Trace("Vehicle found parked using area overlap"); foundParked = true; } else { // Now we consider 2 points on both the parked and the subject vehicle. If they are close we consider it parked. // This is because people walking in front of a car may change the outlines. // This is far from perfect, but it is worth trying. // Note that this assumes only one edge of the vehicle is covered at a time, but for now is better than nothing. // If the vehicle is still moving the next frame should tell via the overlap test so that is not a concern // TODO: keep the parked vehicle locations in a db table? // TODO: Parked vehicles that are covered by people/animals at both corners (we know where people are) will not be // removed from the parked list? We probably don't care about vehicles covered by vehicles because the moving vehicles are // movement in themselves, unless we care specifically what kind of vehicles we are concerned with. Point pPreviousUL = new Point(_previousVehicles[j].ObjectRectangle.Left, _previousVehicles[j].ObjectRectangle.Top); Point pPreviousLR = new Point(_previousVehicles[j].ObjectRectangle.Right, _previousVehicles[j].ObjectRectangle.Bottom); Point pVehicleUL = new Point(vehicles[i].ObjectRectangle.Left, vehicles[i].ObjectRectangle.Top); Point pVehicleLR = new Point(vehicles[i].ObjectRectangle.Right, vehicles[i].ObjectRectangle.Bottom); double ulDistance = GetPointDistance(pPreviousUL, pVehicleUL); double lrDistance = GetPointDistance(pPreviousLR, pVehicleLR); double parkedSize = pVehicleLR.X - pVehicleUL.X; // the width in pixels of the parked vehicle, to get a rough idea of its size double targetSize = parkedTargetDistance * parkedSize; /*if (targetSize > parkedTargetMax) * { * targetSize = parkedTargetMax; // just a WAG pending test data * }*/ if (ulDistance < targetSize || lrDistance < targetSize) { Dbg.Trace("Parked Target Size: " + targetSize.ToString()); Dbg.Trace("Parked ULDistance: " + ulDistance.ToString()); Dbg.Trace("Parked LRDistance: " + lrDistance.ToString()); Dbg.Trace("Vehicle found parked using corners"); foundParked = true; } if (!foundParked) { Dbg.Trace("Vehicle found not parked using corners"); } } if (foundParked) { // OK, here we assume that they are the same object. // TODO: In high frame rate situations this could be a problem. // We add which ever has the highest confidence level to the result; objectList.RemoveAll(obj => obj.ID == vehicles[i].ID); // and remove it from the passed list Dbg.Trace("Removing parked vehicle: " + vehicles[i].Label); vehicles.RemoveAt(i); // we are done with this vehicle removedOne = true; break; } } } if (removedOne) { i = 0; // Since we removed on we need to start over } else { i++; // and on to the next } } // if we have any remaining vehicles add them to the list of previously seen ones _previousVehicles.Clear(); _previousVehicles = new List <ImageObject>(allFoundVehicles); // because ALL vehicles we found are now "previous" } } Dbg.Trace(" Vehicles remaining after parking check: " + vehicles.Count.ToString()); }
public void AddCamera(CameraData camData) { CameraDictionary.Add(CameraData.PathAndPrefix(camData), camData); }
// The actual path for monitoring motion images public static string WildcardPath(CameraData camera) { return(CameraData.PathAndPrefix(camera) + "\\*.jpg"); }
// PathAndPrefix allows us to monitor the directory for motion images. It also identifies the camera public static string PathAndPrefix(CameraData camera) { return(string.Format("{0}\\{1}", camera.Path, camera.CameraPrefix).ToLower()); }
public String Path() { return(CameraData.PathAndPrefix(cameraData)); }
private void OnMonitorCheck(object sender, ItemCheckEventArgs e) { CameraData data = (CameraData)monitorListView.Items[e.Index].Tag; data.Monitoring = (e.NewValue == CheckState.Checked); }