Пример #1
0
Файл: DVR.cs Проект: mutita/anpr
        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;
        }
Пример #2
0
Файл: DVR.cs Проект: mutita/anpr
        void DVRLoop()
        {
            FRAME frame = null;
            int   count = 10;

            while (!m_Stop)
            {
                // if motion detected, send to the copy-out thread which copies the pre-motion buffer to storage


                frame = m_MotionDetectedQ.Dequeue();
                while (frame != null && count-- > 0)
                {
                    WriteMotionEventAndPushPreMotionBuffer(frame); // store it on disk

                    frame = m_MotionDetectedQ.Dequeue();           // get the next one from the queue
                }



                // if we are in the post-motion copy-out time, copy this frame to storage
                count = 10;
                frame = m_DirectyToStorageQ.Dequeue();
                while (frame != null && count-- > 0)
                {
                    WriteToStorage(frame);

                    frame = m_DirectyToStorageQ.Dequeue();
                }

                try
                {
                    // write out LPR events to the event log
                    count = 10;
                    frame = m_NewLPRRecordQ.Dequeue();
                    while (frame != null && count-- > 0)
                    {
                        frame.JpegFileRelativePath = Paths.GetJpegRelateivePath(frame);

                        // if ( ! m_AppData.DVR_StoreToUserSpecifiedFolder) ===>> if user is in Workstation and pushing output images to a special folder, do not
                        //  write the LPR string results to the event log

                        if (!m_AppData.DVR_StoreToUserSpecifiedFolder)
                        {
                            //
                            // write LPR results to the Event Log
                            //

                            if (!PauseFlag.Pause)
                            {
                                EventLogFiles.EventLogFiles.EVENT_TO_WRITE data = m_EventLogFile.WriteLPREvent(frame);
                                CreateLogDirectory(data.directory);
                                FileAccessControl.AppendAllText(data.file, data.line);
                            }
                        }

                        if (m_AppData.DVRMode == APPLICATION_DATA.DVR_MODE.STORE_ON_PLATE_FOUND)
                        {
                            WriteToStorage(frame);
                        }

                        frame = m_NewLPRRecordQ.Dequeue();
                    }
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }


                try
                {
                    // all new frames go into the pre-motion buffer
                    count = 10;
                    frame = m_NewFrameQ.Dequeue();
                    while (frame != null && count-- > 0)
                    {
                        PendingMotionDetection(frame);
                        frame = m_NewFrameQ.Dequeue();
                    }
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }



                Thread.Sleep(1);
            }
        }