void NewImageCallBack(FRAME frame) { try { int c = frame.SourceChannel; if (m_CurrentImageQ[c].Count > 2) m_CurrentImageQ[c].Dequeue();// this queue is just to act as a single unit buffer m_CurrentImageQ[c].Enqueue(frame); } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); } }
void OnReceiveNewFrameToExtractTimeStamp(FRAME frame) { m_ToDisplayProcessedTimeStampsQ.Enqueue(frame); }
void GenAlertMessages(FRAME frame) { m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.WatchList.WatchList_NumAlerts].Accumulator.Increment(1); m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.WatchList.WatchList_LastAlert].StatString.SetValue =(string) frame.WatchListMatchingNumber; if ( ((WatchListControl)frame.ParentWatchList).WatchEmailAddresses == null ) return; foreach (string to in ((WatchListControl)frame.ParentWatchList).WatchEmailAddresses) { EmailServices.SEND_MESSAGE message = new EmailServices.SEND_MESSAGE(); message.to = to; string attachement = m_DVR.Paths.GetCompleteFilePath(frame.JpegFileRelativePath); /// the email server has a problem that if you attach a file to a new mail, and then /// send multiple emails with the same attachment, you get an exception of file open by another process. /// so create a new file copy for each mail that is sent. Don't keep this file around forever. /// message.attachment = m_DVR.GetUniqueCopy(attachement); message.from = m_EmailService.FromAddress; message.subject = "ALERT: " + frame.WatchListMatchingNumber + " Sent at " + DateTime.UtcNow.ToString(); message.body = message.subject + Environment.NewLine + Environment.NewLine + "From PSS: " + frame.PSSName + Environment.NewLine + Environment.NewLine + "Camera Source: " + frame.SourceName + Environment.NewLine + Environment.NewLine + "Hot list entry: " + frame.WatchListMatchingNumber +", " +frame.WatchListMatchingNumberUserComment + Environment.NewLine + Environment.NewLine + "Detected Nunmber: " + frame.BestMatchingString + Environment.NewLine + Environment.NewLine + "Match Probability: " + frame.MatchScore.ToString() + "%" + Environment.NewLine + Environment.NewLine + "Jpeg Image: " + frame.JpegFileRelativePath + Environment.NewLine + Environment.NewLine + "GPS Location: " + frame.GPSPosition + Environment.NewLine + Environment.NewLine + "Plot location URL: " + mapURL + frame.GPSPosition + Environment.NewLine + Environment.NewLine + "Observation time: " + frame.TimeStamp.ToString(); message.sendResultCallBack = OnSendMessageSendStatus; m_EmailService.SendMessage(message); m_Log.Log("WL sent message : " + message.subject, ErrorLog.LOG_TYPE.INFORMATIONAL); } }
public void AddFrame(FRAME frame, string matchingPlateString,int newScore, string alertString) { if (newScore > score) { score = newScore; bestMatchPlateString = matchingPlateString; matchingFrame = frame; matchingFrame.BestMatchingString = matchingPlateString; matchingFrame.MatchScore = newScore; matchingFrame.ParentWatchList = (object)parentWatchList; matchingFrame.WatchListMatchingNumber = alertString; } }
//void CreateLogDirectory(string dir) //{ // if (!Directory.Exists((string)dir)) // { // char[] seperator = { '\\', '\\' }; // string[] branches = dir.Split(seperator); // string path = null; // for (int i = 0; i < branches.Count(); i++) // { // if (branches[i].Length < 1) continue; // path += (branches[i] + "\\"); // if (!Directory.Exists(path)) // Directory.CreateDirectory(path); // } // } //} string BuildPlateField(FRAME frame) { // PLATE^LATIN^C3C456D2AB:G3C456D2AB:G3G456D2A8 string plateField = "PLATE," + frame.PlateNativeLanguage + "^" + BuildAltReadings(frame.PlateNumberNativeLanguage) + "^" + BuildAltReadings(frame.PlateNumberLatin); return (plateField); }
void BuidlAlertFrame(FRAME frame, string matchingPlateString, string watchNumber, string watchNumberComment, WatchListControl list, int score) { frame.BestMatchingString = matchingPlateString; frame.MatchScore = score; frame.ParentWatchList = (object)list; frame.WatchListMatchingNumber = watchNumber; frame.WatchListMatchingNumberUserComment = watchNumberComment; }
void fileDecoder_OnNewFrame(FRAME frame) { // lock (singleton) { FramesToPushQ.Enqueue(frame); } }
void SendImageToConsumer(object image, S2255Controller.COMPRESSION_MODE frmType, int cindex) { FRAME frame = new FRAME(m_AppData); if (frmType == S2255Controller.COMPRESSION_MODE.BITMAP) { frame.Bmp = (Bitmap)image; frame.Jpeg = null; } else { frame.Bmp = null; frame.Jpeg = (byte[])image; } frame.SourceName = chanSourceNames[cindex]; frame.SourceChannel = cindex; if (OnNewFrame[frame.SourceChannel] != null) OnNewFrame[frame.SourceChannel](frame); }
// get the individual frames and send them to the DVR/LPR processing chains /// <summary> buffer callback, COULD BE FROM FOREIGN THREAD. </summary> int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen) { lock (lockSampleGrabberState) { if (m_Stop) return 0; m_SampleGrabberCallBackIsDone = false; IntPtr ipSource = pBuffer; int[,] ipDest = new int[m_videoWidth, m_videoHeight]; bool invert = true; if (m_videoWidth != ipDest.GetLength(0) || m_videoHeight != ipDest.GetLength(1)) { return 0; } LPROCR_Wrapper.LPROCR_Lib.extractFromBmpDataToLumArray(ipSource, ipDest, m_stride, m_videoWidth, m_videoHeight, invert); // compose a new bitmap Bitmap bmp = new Bitmap(m_videoWidth, m_videoHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb); // Lock the bitmap's bits. Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); // Get the address of the first line. IntPtr ptr = bmpData.Scan0; // copy out to the new bitamp bool dontcare = false; unsafe { LPROCR_Lib.MemCopyByte((int*)ipSource, ptr, BufferLen, ref dontcare); } bmp.UnlockBits(bmpData); bmp.RotateFlip(RotateFlipType.Rotate180FlipX);// what it takes to make it look right, if I had time I would do this in one step in LPROCR_Lib.MemCopyByte FRAME frame = new FRAME(m_AppData); frame.Luminance = ipDest; frame.TimeStamp = m_FileTimeOfCurrentFile.AddSeconds(SampleTime); frame.Bmp = bmp; frame.SourceChannel = m_Channel; frame.SourceName = m_AppData.UserSpecifiedCameraName == null ? "storedjpeg" : m_AppData.UserSpecifiedCameraName; frame.SetFileName(); OnNewFrame(frame); m_SampleGrabberCallBackIsDone = true; return 0; } }
void PlayFilesLoop() { int frameRate = 100; int frameDelay = ( 1000 / frameRate); int currentFrame=0; Bitmap bmp= null; m_BitmapsForDisplayQ = new ThreadSafeQueue<Bitmap>(30); while (!m_Stop) { while (playing) { if (m_Stop) break; Thread.Sleep(frameDelay); // when processing plate image jpegs (i.e. just the clipped out plate in a very small image) the player can go too fast for the image processing // resulting in Que overruns, so slow down to prevent loss if (m_AppData.LPRGettingBehind || m_AppData.MotionDetectionGettingBehind || m_AppData.DVRStoringLPRRecordsGettingBehind) Thread.Sleep(250); // slow down a bit if (m_FilesToPlay == null) continue; if (m_FilesToPlay.Count() < 1) continue; try { bmp =(Bitmap) Bitmap.FromFile(m_FilesToPlay[currentFrame]); } catch { } if (bmp == null) continue; Bitmap forDisplayToOwn = new Bitmap(bmp); m_BitmapsForDisplayQ.Enqueue(forDisplayToOwn); m_ParentPanel.Parent.BeginInvoke((MethodInvoker)delegate { PushBitmapToDisplay(); }); FRAME frame = new FRAME(m_AppData); frame.NotVideoEachFrameIsUniqueSize = true; int[,] lum = new int[bmp.Width, bmp.Height]; getPixelsFromImageInY(bmp, ref lum); frame.Luminance = lum; frame.TimeStamp = new FileInfo(m_FilesToPlay[currentFrame]).LastWriteTimeUtc; frame.Bmp = bmp; frame.SourceChannel = m_Channel; // frame.SourceName = ((m_FilesToPlay[currentFrame].Replace("\\", "_")).Replace(":", "_")).Replace(".", "_"); frame.SourceName = m_AppData.UserSpecifiedCameraName == null ? ("stilljpg") : m_AppData.UserSpecifiedCameraName; frame.SetFileName(); OnNewFrame(frame); currentFrame++; if (currentFrame == m_FilesToPlay.Length) { OnEndOfFileEvent(); // we are done. playing = false; m_Stop = true;// this is a one-time use thread break; } } Thread.Sleep(1); } }
void OnReceiveNewImageFromS2255Device(FRAME partialFrame) { if (partialFrame.Jpeg != null) { // this is a jpeg m_LastJPEGReceived[partialFrame.SourceChannel].SetJpeg(partialFrame.Jpeg); } else { // this is a bitmap - send it and the last jpeg received up the chain m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].HitMe++; int chan = partialFrame.SourceChannel; FRAME frame = new FRAME(m_AppData); frame.SetNew(partialFrame.Bmp, m_LastJPEGReceived[partialFrame.SourceChannel].GetJpeg(), partialFrame.SourceName, DateTime.UtcNow, m_FrameCount, m_CurrentGPSPosition, m_ConsumerIDs.GetConsumerCount, partialFrame.SourceChannel); frame.PSSName = m_AppData.ThisComputerName; m_FrameCount++; // convert the bitmap format to a luminace 2-D array for image processing int[,] luminance = new int[frame.Bmp.Width, frame.Bmp.Height]; getPixelsFromImageInY(frame.Bmp, ref luminance); frame.Luminance = luminance; // send to motion detection m_MotionDetectionQ.Enqueue(frame); m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].HitMe = m_MotionDetectionQ.Count; // send to non-motion-detection consumers CONSUMER_PUSH push = new CONSUMER_PUSH(); push.FrameToPush = frame; push.ConsumersToPush = m_Channels[chan].m_NewImageCallBackList; m_AllFramesConsumerPushQ.Enqueue(push); m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].HitMe = m_AllFramesConsumerPushQ.Count; } }
// ///////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////// // Receiving new frames from the lower layers // receive a new from from a movie file being played void MovieFiles_OnNewImage(FRAME frame) { // this is a bitmap - send it and the last jpeg received up the chain try { m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].HitMe++; // manufacture a jpeg from the bitmap Image image = frame.Bmp; MemoryStream stream = new MemoryStream(); image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] jpeg = stream.ToArray(); frame.Jpeg = jpeg; frame.SerialNumber = m_FrameCount; frame.GPSPosition = m_CurrentGPSPosition; frame.PSSName = m_AppData.ThisComputerName; frame.SetFileName(); m_FrameCount++; // send to motion detection if (!frame.NotVideoEachFrameIsUniqueSize) { m_MotionDetectionQ.Enqueue(frame); if (m_MotionDetectionQ.Count > m_MotionDetectionQueLevel / 2) m_AppData.MotionDetectionGettingBehind = true; else m_AppData.MotionDetectionGettingBehind = false; } else { // skip motion detection because the source is a directory of independent jpegs, each potentially of a different size // pretend we detected motion CONSUMER_PUSH p = new CONSUMER_PUSH(); p.FrameToPush = frame; p.ConsumersToPush = m_Channels[frame.SourceChannel].m_MotionDetectedCallBackList; m_MotionDetectedConsumerPushQ.Enqueue(p); } m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].HitMe = m_MotionDetectionQ.Count; // send to non-motion-detection consumers CONSUMER_PUSH push = new CONSUMER_PUSH(); push.FrameToPush = frame; push.ConsumersToPush = m_Channels[frame.SourceChannel].m_NewImageCallBackList; m_AllFramesConsumerPushQ.Enqueue(push); m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].HitMe = m_AllFramesConsumerPushQ.Count; } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); } }
void DetectMotion(FRAME frame) { m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_FrameCnt].HitMe++; int[,] luminance = frame.Luminance; bool motionDetected = false; int error = 0; try { motionDetected = LPROCR_Lib.DetectMotion(frame.SourceChannel, luminance, luminance.GetLength(0), luminance.GetLength(1), ref error); } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.INFORMATIONAL); } if (error != 0) { m_Log.Log("DetectMotion error = " + error.ToString(), ErrorLog.LOG_TYPE.FATAL); } if (motionDetected) { m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_FramesDetected].HitMe++; CONSUMER_PUSH push = new CONSUMER_PUSH(); push.FrameToPush = frame; push.ConsumersToPush = m_Channels[frame.SourceChannel].m_MotionDetectedCallBackList; m_MotionDetectedConsumerPushQ.Enqueue(push); } }
public FRAME CompleteFrameDataToByPassLPR(FRAME frame) { // used by the image hand-editor in the Analysts Workstation application, to by-pass the LPREngine and send results to storage frame.TimeStamp = DateTime.UtcNow; frame.SerialNumber = m_FrameCount; frame.GPSPosition = m_CurrentGPSPosition; frame.PSSName = "AnalystsWorkstation_" + m_AppData.ThisComputerName; frame.SetFileName(); return (frame); }
public string GetJpegRelateivePath(FRAME frame) { lock (singleton) { DateTime timeStamp = frame.TimeStamp; int year = timeStamp.ToUniversalTime().Year; int month = timeStamp.ToUniversalTime().Month; int day = timeStamp.ToUniversalTime().Day; int hour = timeStamp.ToUniversalTime().Hour; string path = year.ToString("####") + "\\" + month.ToString("####") + "\\" + day.ToString("####") + "\\" + hour.ToString("####") + "\\" + SystemName + "\\" + frame.SourceName + "\\" + frame.JpegFileNameOnly; return (path); } }
void WriteToStorage(FRAME frame) { if (!m_AppData.DVR_StoreToUserSpecifiedFolder) { if (PauseFlag.Pause) return; } string destDir = null; string destPath=null; try { if (!m_AppData.DVR_StoreToUserSpecifiedFolder) { destPath = Paths.GetFrameStoragePath(frame.JpegFileNameOnly, frame.SourceName, out destDir); if (!FileAccessControl.DirectoryExists(destDir)) { char[] seperator = { '\\', '\\' }; string[] branches = destDir.Split(seperator); string path = null; for (int i = 0; i < branches.Count(); i++) { if (branches[i].Length < 1) continue; path += (branches[i] + "\\"); if (!FileAccessControl.DirectoryExists(path)) FileAccessControl.CreateDirectory(path); } } } else { // else this is the Analysts workstation app and the user has selected an alternative storage path PauseFlag.Pause = false; PauseFlag.DriveExists = true; destDir = m_AppData.DVR_UserSpecifiedStoragePath + "\\" + frame.SourceName; // destDir = m_AppData.DVR_UserSpecifiedStoragePath; if ( ! FileAccessControl.DirectoryExists(destDir)) FileAccessControl.CreateDirectory(destDir); destPath = destDir +"\\" + frame.JpegFileNameOnly; } FileAccessControl.WriteStream(destPath, frame.Jpeg); Paths.AccumulatedSize += frame.Jpeg.Length; } catch (Exception ex) { m_Log.Log("WriteToStorage ex :" + ex.Message, ErrorLog.LOG_TYPE.FATAL); } }
/// <summary> /// Used by the hand-editor in Analysts workstation to by-pass the automatic processing chain of motion-detection based storage /// </summary> /// <param name="frame"></param> public void SendFrameDirectlyToStorage(FRAME frame) { WriteToStorage(frame); }
public EVENT_TO_WRITE WriteLPREvent(FRAME frame) { EVENT_TO_WRITE eventData = new EVENT_TO_WRITE(); lineFields[(int)FIELDS_ON_BUILDING_STRING.EVENT] = BuildPlateField(frame); lineFields[(int)FIELDS_ON_BUILDING_STRING.PSS_NAME] = frame.PSSName; lineFields[(int)FIELDS_ON_BUILDING_STRING.TIME_STAMP] = frame.TimeStamp.ToString(m_AppData.TimeFormatStringForFileNames); lineFields[(int)FIELDS_ON_BUILDING_STRING.SOURCE_CAMERA_NAME] = frame.SourceName; if ( frame.GPSPosition.Contains("No Position")) { frame.GPSPosition = "No Position Available, No position Available"; // once for lat and once for lon } lineFields[(int)FIELDS_ON_BUILDING_STRING.GPS_LOCATION] = frame.GPSPosition; lineFields[(int)FIELDS_ON_BUILDING_STRING.JPEGFILE_RELATIVE_PATH] = frame.JpegFileRelativePath; string line = BuildLine(lineFields) + "\r\n"; string file = m_PathManager.GetEventLogFilePath(frame.TimeStamp, frame.SourceName); eventData.file = file; eventData.line = line; eventData.directory = m_PathManager.GetEventLogDirectoryPath(frame.TimeStamp, frame.SourceName); return (eventData); //lock (m_FileLock) //{ // CreateLogDirectory(m_PathManager.GetEventLogDirectoryPath(frame.TimeStamp, frame.SourceName)); // File.AppendAllText(file, line); //} }
string GetPreMotionFileNameCompletePath(FRAME frame) { return (Paths.PreMotionPath + "\\" + frame.SourceName + "\\" + frame.JpegFileNameOnly); }
public FRAME Clone(bool copyBitmap, bool copyJpeg, bool copyLuminance) { FRAME newFrame = new FRAME(m_AppData); lock (singleton) { if (copyBitmap) { newFrame.bmp = (Bitmap)bmp.Clone(); } if (copyJpeg) { newFrame.jpeg = (byte[])jpeg.Clone(); } newFrame.sourceName = (string)sourceName.Clone(); newFrame.timeStamp = timeStamp; newFrame.serialNumber = serialNumber; if (gPSPosition != null) { newFrame.gPSPosition = (string)gPSPosition.Clone(); } newFrame.consumerCount = consumerCount; newFrame.available = available; if (pSSName != null) { newFrame.pSSName = (string)pSSName.Clone(); } if (jpegFileNameOnly != null) { newFrame.jpegFileNameOnly = (string)jpegFileNameOnly.Clone(); } if (jpegFileRelativePath != null) { newFrame.jpegFileRelativePath = (string)jpegFileRelativePath.Clone(); } newFrame.sourceChannel = sourceChannel; if (copyLuminance) { newFrame.luminance = (int[, ])luminance.Clone(); } if (plateNativeLanguage != null) { newFrame.plateNativeLanguage = (string)plateNativeLanguage.Clone(); } if (plateNumberLatin != null) { newFrame.plateNumberLatin = (string[])plateNumberLatin.Clone(); } if (plateNumberNativeLanguage != null) { newFrame.PlateNumberNativeLanguage = (string[])plateNumberNativeLanguage.Clone(); } if (bestMatchingString != null) { newFrame.bestMatchingString = (string)bestMatchingString.Clone(); } newFrame.matchScore = matchScore; newFrame.parentWatchList = parentWatchList; if (watchListMatchingNumber != null) { newFrame.watchListMatchingNumber = (string)watchListMatchingNumber.Clone(); } if (watchListMatchingNumberUserComment != null) { newFrame.watchListMatchingNumberUserComment = (string)watchListMatchingNumberUserComment.Clone(); } newFrame.NotVideoEachFrameIsUniqueSize = NotVideoEachFrameIsUniqueSize; return(newFrame); } }
void OnLPRNewRecord(FRAME frame) { m_NewLPRRecordQ.Enqueue(frame); if (m_NewLPRRecordQ.Count > m_LPRRecordQueLen / 2) m_AppData.DVRStoringLPRRecordsGettingBehind = true; else m_AppData.DVRStoringLPRRecordsGettingBehind = false; }
// // add new match events in this method // void ComparePlateNumbersToAllWatchLists( FRAME frame) { foreach (WatchListControl list in m_WatchLists) { for (int i = 0; i < list.WatchEntrys.Length; i++ ) { string watchNumber = list.WatchEntrys[i].Number; foreach (string plate in frame.PlateNumberLatin) { int score = LPROCR_Lib.scoreMatch(plate, watchNumber); if (score >= list.AlertThreshold) { Console.WriteLine("WL found intermediate match"); BuidlAlertFrame(frame, plate, watchNumber, list.WatchEntrys[i].UserComment, list, score); // // Add new match events here // m_AlertsToBeGeneratedQ.Enqueue(frame); } } } } }
// this event is calld from the FrameGenerator, which does the motion detection void OnMotionDetection(FRAME frame) { if (m_AppData.DVRMode != APPLICATION_DATA.DVR_MODE.STORE_ON_MOTION) return;// if not store on motion, we only get frames from LPR to store // dont process stuff on this thread frame.JpegFileRelativePath = Paths.GetJpegRelateivePath(frame); // if we are still in within the post-motion copy-out time from the previous motion event, do not trigger a new copy-out of the pre-motion buffer if (m_MotionFrameCount < 0) { m_MotionDetectedQ.Enqueue(frame); // send this frame to the DVR thread so it can use this frame's time/channel reference to trigger a copy out of the pre-motion buffer } // reset the post-motion recording frame counter m_MotionFrameCount = m_NumberOfFramesToPrePostBuffer; }
void NewLPRResultsEvent_OnNewPlateEvent(FRAME frame) { Console.WriteLine("WL recevied new plate"); // put this on the que to be handeled by the watch list thread m_NewLPRResultQ.Enqueue(frame); }
void OnNewFrame(FRAME frame) { if (m_AppData.DVRMode != APPLICATION_DATA.DVR_MODE.STORE_ON_MOTION) return; // if not store on motion, we only get frames from LPR to store // dont process stuff on this thread if (m_MotionFrameCount-- > 0) { // record it, we had motion m_DirectyToStorageQ.Enqueue(frame); } else { m_NewFrameQ.Enqueue(frame);// goes to the pre-motion buffer } }
void m_LPREngine_OnNewPlateEvent(FRAME frame) { try { int c = frame.SourceChannel; m_CurrentPlateNumberQ[c].Dequeue();// this queue is just to act as a single unit buffer m_CurrentPlateNumberQ[c].Enqueue(frame); } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); } }
/// <summary> /// put images into the pre-motion temp buffer area on disk /// </summary> /// <param name="frame"></param> void PendingMotionDetection(FRAME frame) { if (PauseFlag.Pause) return; if (m_PreMotionRecords[frame.SourceChannel].MotionDetectedMovingFilesInProcess) return; // generate a sub-directory prequalified file name for this image to go into string PreMotionFileNameCompletePath = GetPreMotionFileNameCompletePath(frame); FileAccessControl.WriteStream(PreMotionFileNameCompletePath, frame.Jpeg); // use this queue to keep track of the last X frames to have come in before a motion event m_PreMotionRecords[frame.SourceChannel].PendingMotionDetectionQ.Enqueue(PreMotionFileNameCompletePath); // keep the number of pre-motion frames at m_MotionFrameCount if (m_PreMotionRecords[frame.SourceChannel].PendingMotionDetectionQ.Count >= m_NumberOfFramesToPrePostBuffer) { PreMotionFileNameCompletePath = m_PreMotionRecords[frame.SourceChannel].PendingMotionDetectionQ.Dequeue(); FileAccessControl.FileDelete(PreMotionFileNameCompletePath); } }
// //////////////////////////// // // // Receive New LPR results and display void m_LPREngine_OnNewPlateEvent(FRAME frame) { int chan = frame.SourceChannel; StringBuilder sb = new StringBuilder(); foreach (string s in frame.PlateNumberLatin) { sb.Append(s); sb.Append(", "); } //string result = sb.ToString(); // this.BeginInvoke((MethodInvoker)delegate { this.PostLPRString(chan,result); }); LPR_RESULT_TO_POST result = new LPR_RESULT_TO_POST(); result.result = sb.ToString(); result.chan = chan; m_LPRResultsToPostQ.Enqueue(result); }
void WriteMotionEventAndPushPreMotionBuffer(FRAME frame) { // // write the motion event to the Event Log // EventLogFiles.EventLogFiles.EVENT_TO_WRITE data = m_EventLogFile.WriteMotoinEvent(frame.PSSName, frame.TimeStamp, frame.SourceName, frame.GPSPosition, frame.JpegFileRelativePath); CreateLogDirectory(data.directory); FileAccessControl.AppendAllText(data.file, data.line); string sourceDir = Paths.PreMotionPath + "\\" + frame.SourceName; if (sourceDir == null) return; // // are the frames in the PRE-MOTION dir to copy out to storage ? // // based on time stamp and channel, copy out the pre-motion files to the storage location string[] sourceFiles = FileAccessControl.GetFiles(sourceDir); if (sourceFiles == null)return; m_PreMotionRecords[frame.SourceChannel].MotionDetectedMovingFilesInProcess = true; foreach (string file in sourceFiles) { MoveFileToDVRStorage(file, frame.SourceName); } m_PreMotionRecords[frame.SourceChannel].PendingMotionDetectionQ.Clear(); m_PreMotionRecords[frame.SourceChannel].MotionDetectedMovingFilesInProcess = false ; }
void OnNewFrameFromDevice(FRAME frame) { // send new frame to registered consumers if (OnNewFrame != null) OnNewFrame(frame); }
// registered to receive frames where motion was detected from the previous frame void OnRxNewMotionWasDetectedFrame(FRAME frame) { bool sucess = m_LPRProcessQ.Enqueue(frame); // enqueue for the LPR thread to process if (!sucess) m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.LPR.LPR_DroppedFrames].HitMe++; if (m_LPRProcessQ.Count > m_LPRProcessQueSize / 2) m_AppData.LPRGettingBehind = true; else m_AppData.LPRGettingBehind = false; // store the frame meta data for later retrival if the LPR finds plates // no need to use memory storing bitmaps and jpegs as the jpeg has been stored on disk by the DVR and the // frame meta data includes a reference to this file. FRAME newFrame = null; newFrame = frame.Clone(false, false, false); newFrame.PlateNativeLanguage = "LATIN"; // keep knowledge of this frame around for a while, so that if LPR plate number group processig finds some numbers, // we can look up which frame was associated with those numbers by serial number. // the jpeg already went to disk by the time the LPR found numbers, so only the file url gets recorded // into the eventlog.txt file m_StoredFrameData.Add(newFrame.SerialNumber, newFrame); // for plate groupings, keep the serialnumber/frame data around for a while, only use //if (m_AppData.DVRMode == APPLICATION_DATA.DVR_MODE.STORE_ON_MOTION) //{ // newFrame = frame.Clone(false, false, false); // newFrame.PlateNativeLanguage = "LATIN"; // // keep knowledge of this frame around for a while, so that if LPR plate number group processig finds some numbers, // // we can look up which frame was associated with those numbers by serial number. // // the jpeg already went to disk by the time the LPR found numbers, so only the file url gets recorded // // into the eventlog.txt file // m_StoredFrameData.Add(newFrame.SerialNumber, newFrame); //} //else //{ // //else m_AppData.DVRMode == APPLICATION_DATA.DVR_MODE.STORE_ON_PLATE_FOUND // // keep a copy of the jpeg in this frame since this frame is what the DVR will write to disk // newFrame = frame.Clone(false,true,false); //} }