AForge.NET

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

enhance mouse mouvement and camera fps

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

enhance mouse mouvement and camera fps

Postby mohsinmushtaq » Tue Jan 08, 2013 12:33 pm

im using Aforge to track color objects and make a blob around it this worked good, as i applied euclidean filter to get my desired color, the problem im facing is that the video delay increases and the blob im making is not fixed it changes its size, can i get a fixed size blob is there any way im using this code for making blob
Code: Select all
ExtractBiggestBlob filter1 = new ExtractBiggestBlob();
                // apply the filter
                Bitmap biggestBlobsImage = filter.Apply(video);
                BlobCounter blobCounter = new BlobCounter();
                blobCounter.MinWidth = 5;
                blobCounter.MinHeight = 5;

                blobCounter.FilterBlobs = true;
                blobCounter.ObjectsOrder = ObjectsOrder.Size;
                blobCounter.ProcessImage(video);
                Rectangle[] rects = blobCounter.GetObjectsRectangles();
                foreach (Rectangle recs in rects)
                {
                    if (rects.Length > 0)
                    {
                        Rectangle objectRect = rects[0];
                        Graphics g = Graphics.FromImage(video);
                        using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 5))
                        {
                            g.DrawRectangle(pen, objectRect);
                        }
                        g.Dispose();
                        cursor_position cu = new cursor_position();
                        int xX = cu.posX(video.Width, objectRect.X, objectRect.Width);
                        int yY = cu.posY(video.Height, objectRect.Y, objectRect.Height);
                        //Cursor.Position = new System.Drawing.Point(xX, yY);
                  }


i need to know is there any way to enhance my mouse movement and reduce the delay, cause this is making problem in controlling the mouse and performing clicks ! Thanks
mohsinmushtaq
 
Posts: 6
Joined: Sun Jan 06, 2013 11:22 am

Re: enhance mouse mouvement and camera fps

Postby andrew.kirillov » Tue Jan 08, 2013 12:47 pm

mohsinmushtaq wrote: the problem im facing is that the video delay increase

What does this mean? Does it mean that you have one frame rate in the beginning, but then another one later? So frame rate drops after a while?

mohsinmushtaq wrote:blob im making is not fixed it changes its size

Not quite sure what do you mean. If the object you track increases its size, then yes, blob size will grow. Kind of obviously.

mohsinmushtaq wrote:can i get a fixed size blob

Don't get what you want. Blob's size depends on the size of the found object. It is not something you set.

The code you have is quite wrong. First, it is not clear what is the point of using ExtractBiggestBlob ... But, actually I see that is not used at all, but another filter is used, which result is ignored. The foreach loop is plain wrong. You loop through every blob, but then use only the first one (index 0). And of course using Graphics.FromImage() on every loop's iteration is a bad idea. Looks messy.
With best regards,
Andrew


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

Re: enhance mouse mouvement and camera fps

Postby mohsinmushtaq » Tue Jan 08, 2013 4:38 pm

hmm ... the camera fps drops drastically when im tracking colored object, i dont know why is this because of my webcam ? or pc does these things have to do anything with the webcam performance ... and i by having a fixed size of blob i mean this
video https://www.youtube.com/watch?v=AaQQQKKIZKs
he is having a fixed blob how can i get something like this thats really beautiful :)
mohsinmushtaq
 
Posts: 6
Joined: Sun Jan 06, 2013 11:22 am

Re: enhance mouse mouvement and camera fps

Postby andrew.kirillov » Tue Jan 08, 2013 4:51 pm

From that video I can see that the guy was using HSLFiltering class from AForge.NET framework. Not sure what is used by you for color tracking.

mohsinmushtaq wrote:the camera fps drops drastically when im tracking colored object, i dont know why is this because of my webcam ?

Although HSLFiltering is not as fast as filtering in RGB color space, it should not be so bad. I would look for issues in your code. The one you sent before is not good, so I would not be surprised if that is the cause of the issues.
With best regards,
Andrew


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

Re: enhance mouse mouvement and camera fps

Postby mohsinmushtaq » Thu Jan 10, 2013 11:02 am

i looked at the answer you gave, and tweaked the code little bit and the webcam is responding well
Code: Select all
EuclideanColorFiltering filter = new EuclideanColorFiltering();
           
            filter.CenterColor = new RGB(53, 90, 216);
           // filter.CenterColor = new RGB(216, 35, 0);
            filter.Radius = 100;
           
            // apply the filter
            filter.ApplyInPlace(video);

BlobCounter blobCounter = new BlobCounter();
         
            blobCounter.FilterBlobs = true;
            blobCounter.ObjectsOrder = ObjectsOrder.Size;
            blobCounter.ProcessImage(video);
            Rectangle[] rects = blobCounter.GetObjectsRectangles();
           
                if (rects.Length > 0)
                {
                    Rectangle objectRect = rects[0];
                    Graphics g = Graphics.FromImage(video);
                    using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 2))
                    {
                        g.DrawRectangle(pen, objectRect);
                    }
                    g.Dispose();
                    cursor_position cu = new cursor_position();
                    int xX = cu.posX(video.Width, objectRect.X, objectRect.Width);
                    int yY = cu.posY(video.Height, objectRect.Y, objectRect.Height);


removed the biggestblob and foreach , now the fps is better ...

we are using EuclideanColorFiltering class to detect the Blue color ...


EDIT:
theres a problem when i bring my finger with color cap, my program makes a blob around my color object and also detects the color at the back, is there anyway to stop it from detecting the colors that are behind and only track the biggest color !
mohsinmushtaq
 
Posts: 6
Joined: Sun Jan 06, 2013 11:22 am

Re: enhance mouse mouvement and camera fps

Postby mohsinmushtaq » Fri Jan 18, 2013 7:58 am

I am detecting color from HSL filter, this detection is perform by Webcam, I would like to perform a single click with the color detected. I have tried to apply boolean flag, but as the frame event is continously running so it will click many times (for eg; camera has 10fps so it will click 10 times in a second).

Is there any way that mouse perform single click under the frame event of VideoCaptureDevice.
mohsinmushtaq
 
Posts: 6
Joined: Sun Jan 06, 2013 11:22 am

Re: enhance mouse mouvement and camera fps

Postby mrvturan96 » Wed Jan 24, 2018 7:58 pm

Hi sir,
Did you find the solution to the problem?
mrvturan96
 
Posts: 2
Joined: Wed Jan 24, 2018 7:55 pm




Return to Image Processing and Computer Vision