Quantcast

Very slow acquisition of live images

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Very slow acquisition of live images

aniri
In the past month or so I have been tinkering with a Photometrix camera so that I could get live Images using Matlab. Now that I have done so, I have noticed that the "live feed" (that only collects 1000 frames)becomes more and more delayed overtime.
The code used looks like follow:

import mmcorej.*;
mmc = CMMCore;
mmc.loadDevice('Camera', 'PVCAM', 'Camera-1')
mmc.initializeDevice(mmc.getCameraDevice());
mmc.initializeCircularBuffer();
mmc.detectDevice(mmc.getCameraDevice());
mmc.setCircularBufferMemoryFootprint(1000);
mmc.startContinuousSequenceAcquisition(500);
cap = mmc.getBufferTotalCapacity();
img = zeros(128,128, 7000);
sig = zeros(1, 7000);
i=2;
n=0;
format shortg;

while (mmc.isSequenceRunning())
    i=i+1;
    if (mmc.getRemainingImageCount()> 0)
        img1 = mmc.popNextImage;
        [pixelType] = pixel(mmc);
        [img1] = camprop(mmc, img1,pixelType);
        img(:,:,i) = transpose(img1);
        imagesc(img(:,:,i));
        sig(i) = img(50,50,i);
        sig(2)=1500;
        Y =[sig(i),sig(i-1)];
        X = [i , i-1];
        subplot(2,1,1);
        plot(X, Y);
        hold on;
        drawnow;  
        subplot(2,1,2);
        imagesc(img(:,:,i));
        drawnow;
    end
    if i== 1000
        mmc.stopSequenceAcquisition();
    end
end
 
exposuretime = mmc.getExposure();
i
mmc.clearCircularBuffer();
mmc.unloadAllDevices();


Could someone please shed some light on:

1. Why is the image being delayed overtime? Is there a special function that I need to use?
2. How could I always have a live image that doesn't store anything in matlab, but once I need it to store it will do so. Is there a BLIT function or equivalent that I can use?

Thank you in advance

Ahmed
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Very slow acquisition of live images

Nico Stuurman-2
Hi Aniri,


On 12/14/2016 12:59 PM, aniri wrote:
> In the past month or so I have been tinkering with a Photometrix camera so
> that I could get live Images using Matlab. Now that I have done so, I have
> noticed that the "live feed" (that only collects 1000 frames)becomes more
> and more delayed overtime.
> Could someone please shed some light on:
>
> 1. Why is the image being delayed overtime? Is there a special function that
> I need to use?
Doing processing and displaying a live stream can be at odds with each
other.  If you can process images as fast as they are delivered by the
system, then you should be good to go.  In practice, that is often not
the case.  Therefore, the Micro-Manager code uses the function
mmc.getLastImage() rather than mmc.popNextImage().  This helps to ensure
that the user always sees the freshest image.  However, you very well
may "skip" images using this approach.

> 2. How could I always have a live image that doesn't store anything in
> matlab, but once I need it to store it will do so. Is there a BLIT function
> or equivalent that I can use?

When you need to store data, use mmc.popNextImage(), when you need to
display, use mmc.getLastImage().  As long as the circular buffer is
large enough, it will hold all images for later use (but be aware that
it is not a real circular buffer, in fact, it will be emptied when full
and start re-filling).

Best,

Nico

> The code used looks like follow:
>
> import mmcorej.*;
> mmc = CMMCore;
> mmc.loadDevice('Camera', 'PVCAM', 'Camera-1')
> mmc.initializeDevice(mmc.getCameraDevice());
> mmc.initializeCircularBuffer();
> mmc.detectDevice(mmc.getCameraDevice());
> mmc.setCircularBufferMemoryFootprint(1000);
> mmc.startContinuousSequenceAcquisition(500);
> cap = mmc.getBufferTotalCapacity();
> img = zeros(128,128, 7000);
> sig = zeros(1, 7000);
> i=2;
> n=0;
> format shortg;
>
> while (mmc.isSequenceRunning())
>      i=i+1;
>      if (mmc.getRemainingImageCount()> 0)
>          img1 = mmc.popNextImage;
>          [pixelType] = pixel(mmc);
>          [img1] = camprop(mmc, img1,pixelType);
>          img(:,:,i) = transpose(img1);
>          imagesc(img(:,:,i));
>          sig(i) = img(50,50,i);
>          sig(2)=1500;
>          Y =[sig(i),sig(i-1)];
>          X = [i , i-1];
>          subplot(2,1,1);
>          plot(X, Y);
>          hold on;
>          drawnow;
>          subplot(2,1,2);
>          imagesc(img(:,:,i));
>          drawnow;
>      end
>      if i== 1000
>          mmc.stopSequenceAcquisition();
>      end
> end
>  
> exposuretime = mmc.getExposure();
> i
> mmc.clearCircularBuffer();
> mmc.unloadAllDevices();
>
>
>
> Thank you in advance
>
> Ahmed
>
>
>
> --
> View this message in context: http://micro-manager.3463995.n2.nabble.com/Very-slow-acquisition-of-live-images-tp7587918.html
> Sent from the Micro-Manager mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Very slow acquisition of live images

PhilippeP
In reply to this post by aniri
Hi Ahmed,

We had a similar experience. This was due to a preference setting, asking for individual metadata files for each image. Simply unselecting this option solved the problem.

Hope that helps.
Philippe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Very slow acquisition of live images

aniri
In reply to this post by Nico Stuurman-2
Thank you for that explanation.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Very slow acquisition of live images

aniri
In reply to this post by PhilippeP
Hi Philippe,

I have tried out suggestion, but as the images accumulate it still is slower.
Do you have any other suggestion?

Thanks

Ahmed
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Very slow acquisition of live images

PhilippeP
Afraid not...
Sorry.
Loading...