AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Find coordinates Blob

The forum is to discuss topics related to different areas of image processing and computer vision.

Find coordinates Blob

Postby Shpak » Thu Jun 16, 2016 1:41 pm

Hello. I need to find the coordinates of moving objects in the video. Here is the code but rect.x option provides the coordinates of image. Help my please.

Code: Select all
        private void button1_Click(object sender, EventArgs e)
        {
            if (videoSourcePlayer1.IsRunning == true) videoSourcePlayer1.SignalToStop();
            FinalVideo = new VideoCaptureDevice( VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
     
            videoSourcePlayer1.VideoSource = FinalVideo;
            videoSourcePlayer1.Start();
       
         motionDetector = new TwoFramesDifferenceDetector();
         motionProcessing = new BlobCountingObjectsProcessing()
                     {
                        MinObjectsHeight = 100,
                        MinObjectsWidth = 100
                     };

         Detector = new MotionDetector(motionDetector, motionProcessing);
         NivelDeDetector = 0;
        }

        private void Form_video_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (videoSourcePlayer1.IsRunning == true) videoSourcePlayer1.SignalToStop();
        }       

        private void Stop_Click(object sender, EventArgs e)
        {
            videoSourcePlayer1.SignalToStop();
        }

        private void videoSourcePlayer1_NewFrame(object sender, ref Bitmap image)
        {
            Mirror filter = new Mirror(false, true);
            filter.ApplyInPlace(image);// отражаем

                if (Detector.ProcessFrame( image ) > 0.05) // проверяем скорость
                {
                  NivelDeDetector = Detector.ProcessFrame( image );

                    BlobCounter blobCounter = new BlobCounter();
                    blobCounter.FilterBlobs = true;
                    blobCounter.ProcessImage( image );
                   
                    Blob[] blobs = blobCounter.GetObjectsInformation( );
                    if (blobs.Length > 0)
                    {
                        foreach (Blob blob in blobs) {
                                Rectangle rect = blob.Rectangle;
                                Console.WriteLine(rect.X); // <= ?

                           }
                    }

                 }     
          } 
Shpak
 
Posts: 2
Joined: Thu Jun 16, 2016 1:23 pm

Re: Find coordinates Blob

Postby andrew.kirillov » Thu Jun 16, 2016 3:01 pm

Hello,

The code makes little sense without a sample image. No clue what sort of objects/blobs you deal with.

Make sure your images have black background.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Find coordinates Blob

Postby Shpak » Thu Jun 16, 2016 8:02 pm

andrew.kirillov wrote:Hello,

The code makes little sense without a sample image. No clue what sort of objects/blobs you deal with.

Make sure your images have black background.


Thanks for the help, I understand. :D
Shpak
 
Posts: 2
Joined: Thu Jun 16, 2016 1:23 pm




Return to Image Processing and Computer Vision

cron