Record continuous line profile data with highest frame rate (and Python)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Record continuous line profile data with highest frame rate (and Python)

Inqsey

Dear MM-Community,

 

For an experiment I need a frame rate > 50 fps which is no problem with the ABS CMOS-Camera UK1275-C I’m using (83 fps by 640 x 480 Pixel) .

If I use the live acquisition in MM the frame rate for 640 x 480 Pixel is shown to be the 80 fps.

 

Now I want to save (and work with) a continuous line plot of the pictures which works best with Pythons Numpy. Like a live line plot, but with data storage.
Due to this I use the MMCorePy and snap the image and its line plot in a loop (Code below).

 

My problem is now, that I can’t get the frame rate in Python which is possible in MM. The rate is always much lower than the half of the possible rate (~10-20 fps).

I also tried a continuous frame acquisition with “mmc.startContinuousSequenceAcquisition(1)”, but there I have the same problem.

 

After a lost week I still don’t know how to fix it. Does anyone have an idea what I’m doing wrong?

Or can someone help me out with another way to record a continuous line profile with the highest possible frame rate, maybe over the Beanshell (unfortunately I’m not into Java…)?

 

Thanking you in advance

Moritz

 

 

import numpy

import time

import MMCorePy

 

exposure = 10  #microseconds

 

mmc = MMCorePy.CMMCore()

mmc.loadDevice("ABSCam", "ABSCamera", "ABSCam")

mmc.initializeAllDevices()

mmc.setCameraDevice('ABSCam')

mmc.setProperty("ABSCam", "Standard Resolutions", "12) VGA ( 640 x  480)")

mmc.setProperty("ABSCam", "PixelType", " 16bit")

mmc.setExposure(exposure)

 

 

#measure fps

start_time = time.time()

t = 1           #Zeit in denen fps ermittelt wird

counter = 0

 

 

profilePlotList = []

 

#Snap Images and save ProfilePlots       

for i in range(0,10000):

    mmc.snapImage()

    img = numpy.uint16(mmc.getImage())

    

    #Profile Plot

    profilePlot = img[240,100:400]

    profilePlotList.append(profilePlot)

 

    #measure fps every second

    counter+=1

    if (time.time() - start_time) > t :

        print("FPS: ", counter / (time.time() - start_time))

        counter = 0

        start_time = time.time()



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Record continuous line profile data with highest frame rate (and Python)

oftakofta
Hi Moritz,

In my experience initiating new Numpy arrays can be time consuming. You could try and pre-initiate an array which you re-populate with image data for each acquired image. Additionally, you could maybe initiate a second array to store the line plots, I don't know how this would compare to the list you are using in your current implementation.

Peace!

/Jens Eriksson
Sellin Imaging platform
Uppsala University




On Fri, Jan 11, 2019 at 2:30 PM Klotz, Moritz <[hidden email]> wrote:

Dear MM-Community,

 

For an experiment I need a frame rate > 50 fps which is no problem with the ABS CMOS-Camera UK1275-C I’m using (83 fps by 640 x 480 Pixel) .

If I use the live acquisition in MM the frame rate for 640 x 480 Pixel is shown to be the 80 fps.

 

Now I want to save (and work with) a continuous line plot of the pictures which works best with Pythons Numpy. Like a live line plot, but with data storage.
Due to this I use the MMCorePy and snap the image and its line plot in a loop (Code below).

 

My problem is now, that I can’t get the frame rate in Python which is possible in MM. The rate is always much lower than the half of the possible rate (~10-20 fps).

I also tried a continuous frame acquisition with “mmc.startContinuousSequenceAcquisition(1)”, but there I have the same problem.

 

After a lost week I still don’t know how to fix it. Does anyone have an idea what I’m doing wrong?

Or can someone help me out with another way to record a continuous line profile with the highest possible frame rate, maybe over the Beanshell (unfortunately I’m not into Java…)?

 

Thanking you in advance

Moritz

 

 

import numpy

import time

import MMCorePy

 

exposure = 10  #microseconds

 

mmc = MMCorePy.CMMCore()

mmc.loadDevice("ABSCam", "ABSCamera", "ABSCam")

mmc.initializeAllDevices()

mmc.setCameraDevice('ABSCam')

mmc.setProperty("ABSCam", "Standard Resolutions", "12) VGA ( 640 x  480)")

mmc.setProperty("ABSCam", "PixelType", " 16bit")

mmc.setExposure(exposure)

 

 

#measure fps

start_time = time.time()

t = 1           #Zeit in denen fps ermittelt wird

counter = 0

 

 

profilePlotList = []

 

#Snap Images and save ProfilePlots       

for i in range(0,10000):

    mmc.snapImage()

    img = numpy.uint16(mmc.getImage())

    

    #Profile Plot

    profilePlot = img[240,100:400]

    profilePlotList.append(profilePlot)

 

    #measure fps every second

    counter+=1

    if (time.time() - start_time) > t :

        print("FPS: ", counter / (time.time() - start_time))

        counter = 0

        start_time = time.time()

_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general


--
Science is built up of facts, as a house is built of stones; but an accumulation of facts is no more a science than a heap of stones is a house.  /Henri Poincaré


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Record continuous line profile data with highest frame rate (and Python)

Inqsey
In reply to this post by Inqsey

Hi Jens,

 

Thank you very much for your help!

Meanwhile I have reinstalled a newer version of the DirectShow filter provided by the camera producer ABS. And like a miracle, it works now!

 

I followed your tip and changed the list, which was filled with numpy arrays, into a single large numpy array. This makes it faster, easier to handle and way more elegant. Thank you!

 

Best regards

Moritz



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general