Exemple #1
0
        private void MediaTimerCallBack(Object obj)
        {
            //Console.WriteLine("MediaTimerCallBack");


            if (this.panel1.InvokeRequired)
            {
                this.panel1.BeginInvoke(new Action(() =>
                {
                    if (anpr != null)
                    {
                        Bitmap bmp = new Bitmap(this.panel1.Width, this.panel1.Height);

                        bmp = (Bitmap)ImageCapture.DrawToImage(this.panel1, cropX, cropY, cropWidth, cropHeight);     // 108, 110, 800, 450);
                        //bmp = ResizeBitmap(bmp, 480, 270); // size of anpr input image
                        anpr.pushMedia(bmp, bmp.Width, bmp.Height);
                        bmp.Dispose();
                    }
                }
                                                   ));
            }
            else
            {
                // do nothing
            }
        }
Exemple #2
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Bitmap bmp = new Bitmap(this.panel1.Width, this.panel1.Height);

            // In order to use DrawToBitmap, the image must have an INITIAL image.
            // Not sure why. Perhaps it uses this initial image as a mask??? Dunno.

            /*using (Graphics G = Graphics.FromImage(bmp))
             * {
             *  G.Clear(Color.Yellow);
             * }*/

            bmp = (Bitmap)ImageCapture.DrawToImage(this.panel1);
            anpr.getValidPlate2(bmp, bmp.Width, bmp.Height);

            //bmp.Save("c:\\save.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            bmp.Dispose();
        }
Exemple #3
0
        private void MediaTimerCallBack(Object obj)
        {
            //Console.WriteLine("MediaTimerCallBack");


            if (this.panel1.InvokeRequired)
            {
                this.panel1.BeginInvoke(new Action(() =>
                {
                    if (anpr != null)
                    {
                        bool isReconnect = false;
                        Bitmap bmp       = new Bitmap(this.panel1.Width, this.panel1.Height);

                        bmp = (Bitmap)ImageCapture.DrawToImage(this.panel1, camera.cropX, camera.cropY, camera.cropWidth, camera.cropHeight);     // 108, 110, 800, 450);
                        if (camera.isResize)
                        {
                            if (camera.cropHeight > camera.cropWidth)
                            {
                                Console.WriteLine("resize for corridor mode!");
                                bmp = ResizeBitmap(bmp, 360, 640);     // size of anpr input image
                            }
                            else
                            {
                                Console.WriteLine("resize!");
                                bmp = ResizeBitmap(bmp, 640, 360);     // size of anpr input image
                            }
                        }
                        int pushMediaResult = anpr.pushMedia(bmp, bmp.Width, bmp.Height);
                        bmp.Dispose();

#if RECONNECT
                        /*if (pushMediaResult < 1)
                         * {
                         *  Console.WriteLine("Overflow count " + (overflowCount++));
                         * }
                         *
                         * if (overflowCount > 50)
                         * {
                         *  Console.WriteLine("Overflow count exceeded. Try to reconnect!");
                         *  isReconnect = true;
                         * }*/
#endif

                        if (notifyColor == Color.Red || notifyColor == Color.LightGreen)
                        {
                            DrawBorder();
                        }

                        if (notifyColor == Color.LightGreen)
                        {
                            notifyCount++;

                            if (notifyCount > 30)
                            {
                                notifyCount = 0;
                                notifyColor = Color.Red;
                            }
                        }

#if RECONNECT
                        // get libvlc media state and reconnect
                        if (player != null)
                        {
                            double playtime = player.GetPlayTime();
                            //Console.WriteLine("libVlc playtime " + playtime + " lastplaytime " + lastPlayTime + " mediaMonitorCount " + mediaMonitorCount);
                            if (lastPlayTime == playtime)
                            {
                                mediaMonitorCount++;
                            }
                            else
                            {
                                mediaMonitorCount = 0;
                            }

                            if (mediaMonitorCount > 50)
                            {
                                // reconnect
                                isReconnect = true;
                            }
                            else
                            {
                                lastPlayTime = playtime;
                            }
                        }

                        if (isReconnect)
                        {
                            Stop();
                            Play();
                        }
#endif
                    }
                }
                                                   ));
            }
            else
            {
                // do nothing
            }
        }