Пример #1
0
        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;
            }
        }
Пример #2
0
        public void PushLoop()
        {
            while (!m_Stop)
            {
                try
                {
                    CONSUMER_PUSH consumerPush = null;

                    while (m_AllFramesConsumerPushQ.Count > 0)
                    {
                        consumerPush = m_AllFramesConsumerPushQ.Dequeue();

                        if (consumerPush != null)
                        {
                            foreach (ConsumerNotificationInfo consumer in consumerPush.ConsumersToPush)
                            {
                                consumer.callback(consumerPush.FrameToPush);
                            }
                        }
                    }



                    consumerPush = null;

                    while (m_MotionDetectedConsumerPushQ.Count > 0)
                    {
                        consumerPush = m_MotionDetectedConsumerPushQ.Dequeue();

                        if (consumerPush != null)
                        {
                            foreach (ConsumerNotificationInfo consumer in consumerPush.ConsumersToPush)
                            {
                                consumer.callback(consumerPush.FrameToPush);
                            }
                        }
                    }
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }

                Thread.Sleep(1);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        //   /////////////////////////////////////////////////////////
        //   /////////////////////////////////////////////////////////
        //   /////////////////////////////////////////////////////////


        //     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); }
        }
Пример #5
0
        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;

            }
        }
Пример #6
0
        //   /////////////////////////////////////////////////////////
        //   /////////////////////////////////////////////////////////
        //   /////////////////////////////////////////////////////////
        //     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); }
        }
Пример #7
0
        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);

            }
        }