예제 #1
0
        // 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);
            //}
        }
예제 #2
0
        void LPRProcessImage(FRAME frame)
        {
            try
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.LPR.LPR_FramesProcessed].HitMe++;

                int error = 0;
                int plateCount = 0;

                int diagEnabled = 0;
                if (m_AppData.LPRDiagEnabled) diagEnabled = 1;

                try
                {
                    plateCount = m_LPRFuntions.ReadThisImage(frame.Luminance, diagEnabled, ref  m_processOptions, ref error);
                    if (error != 0)
                    {
                        m_Log.Log("LPR Error = " + error.ToString(), ErrorLog.LOG_TYPE.FATAL);
                    }
                }
                catch (Exception ex)
                {
                    m_Log.Log("ReadThisImage ex: " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
                }

                // did we find any plates int the image ?

                if (plateCount < 1)
                {
                    m_LPRFuntions.PlateGroups_ProcessNewImage(frame.SourceChannel, " ", 0, frame.SerialNumber);// notify next frame had no plates
                    frame = null;
                    return;
                }

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.LPR.LPR_PlatesFound].HitMe = plateCount;

                // extract the plate images and strings, and send to the LPRStorage class

                string[] detectedStrings = new string[plateCount];

                for (int p = 0; p < plateCount; p++)
                {
                    float score = 0;

                    // get the string from the plate

                    detectedStrings[p] = m_LPRFuntions.GetPlateString(p, ref score);

                    m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.LPR.LPR_LastReading].StatString.SetValue = (string) detectedStrings[p];

                    if (m_AppData.DVRMode == APPLICATION_DATA.DVR_MODE.STORE_ON_MOTION)
                    {
                        // in store-on-motion mode, consolidate multiple frames of detected plates into a single grouping of plate readings...
                        m_LPRFuntions.PlateGroups_ProcessNewImage(frame.SourceChannel, detectedStrings[p], detectedStrings[p].Length, frame.SerialNumber);
                    } // else, we are in the mode of store on LPR detecting a plate number. In this case,  we are going to store all results below...

                }// end for each plate found

                // send unfiltered plate result to consumers
                FRAME justToXferPlateNumber = frame.Clone(false, false, false);
                justToXferPlateNumber.PlateNumberNativeLanguage = detectedStrings;
                justToXferPlateNumber.PlateNumberLatin = detectedStrings;

                m_LPRPerFrameReadingQ.Enqueue(justToXferPlateNumber);

                if (plateCount > 0 && m_AppData.DVRMode == APPLICATION_DATA.DVR_MODE.STORE_ON_PLATE_FOUND)
                {

                    // in store on plate found, store all plate readings/images on a per frame basis, no groupings.. will be redundant from image to image

                    frame.PlateNumberNativeLanguage = detectedStrings; // this contains a multiple reading from multiple plates in one image
                    frame.PlateNumberLatin = detectedStrings;

                    m_LPRFinalPlateGroupOutputQ.Enqueue(frame);
                }

            }
            catch (Exception ex)
            {
                m_Log.Log("LPRProcessImage ex : " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
            }
        }