Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93540 > unrolled thread
| Started by | Agustin Cruz <agustin.cruz@gmail.com> |
|---|---|
| First post | 2015-07-06 14:31 -0700 |
| Last post | 2015-07-07 07:49 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.python
Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi Agustin Cruz <agustin.cruz@gmail.com> - 2015-07-06 14:31 -0700
Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-06 22:59 +0100
Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi Agustin Cruz <agustin.cruz@gmail.com> - 2015-07-06 16:16 -0700
Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-07 07:49 +0100
| From | Agustin Cruz <agustin.cruz@gmail.com> |
|---|---|
| Date | 2015-07-06 14:31 -0700 |
| Subject | Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi |
| Message-ID | <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> |
I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow).
I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images.
import io
import time
import picamera
#from PIL import Image
def outputs():
stream = io.BytesIO()
for i in range(40):
# This returns the stream for the camera to capture to
yield stream
# Once the capture is complete, the loop continues here
# (read up on generator functions in Python to understand
# the yield statement). Here you could do some processing
# on the image...
#stream.seek(0)
#img = Image.open(stream)
# Finally, reset the stream for the next capture
stream.seek(0)
stream.truncate()
with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
camera.framerate = 80
time.sleep(2)
start = time.time()
camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
finish = time.time()
print('Captured 40 images at %.2ffps' % (40 / (finish - start)))
Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file
Best regards, Agustín
[toc] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-07-06 22:59 +0100 |
| Message-ID | <mailman.332.1436220007.3674.python-list@python.org> |
| In reply to | #93540 |
On 06/07/2015 22:31, Agustin Cruz wrote:
> I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow).
>
> I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images.
>
> import io
> import time
> import picamera
> #from PIL import Image
>
> def outputs():
> stream = io.BytesIO()
> for i in range(40):
> # This returns the stream for the camera to capture to
> yield stream
> # Once the capture is complete, the loop continues here
> # (read up on generator functions in Python to understand
> # the yield statement). Here you could do some processing
> # on the image...
> #stream.seek(0)
> #img = Image.open(stream)
> # Finally, reset the stream for the next capture
> stream.seek(0)
> stream.truncate()
>
> with picamera.PiCamera() as camera:
> camera.resolution = (640, 480)
> camera.framerate = 80
> time.sleep(2)
> start = time.time()
> camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
> finish = time.time()
> print('Captured 40 images at %.2ffps' % (40 / (finish - start)))
>
> Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file
>
> Best regards, Agustín
>
http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is
the first hit on google for "numpy 3d array stack".
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Agustin Cruz <agustin.cruz@gmail.com> |
|---|---|
| Date | 2015-07-06 16:16 -0700 |
| Message-ID | <9647ca9f-3b8c-48e2-b422-338654c3b4fb@googlegroups.com> |
| In reply to | #93541 |
On Monday, July 6, 2015 at 6:00:42 PM UTC-4, Mark Lawrence wrote:
> On 06/07/2015 22:31, Agustin Cruz wrote:
> > I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow).
> >
> > I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images.
> >
> > import io
> > import time
> > import picamera
> > #from PIL import Image
> >
> > def outputs():
> > stream = io.BytesIO()
> > for i in range(40):
> > # This returns the stream for the camera to capture to
> > yield stream
> > # Once the capture is complete, the loop continues here
> > # (read up on generator functions in Python to understand
> > # the yield statement). Here you could do some processing
> > # on the image...
> > #stream.seek(0)
> > #img = Image.open(stream)
> > # Finally, reset the stream for the next capture
> > stream.seek(0)
> > stream.truncate()
> >
> > with picamera.PiCamera() as camera:
> > camera.resolution = (640, 480)
> > camera.framerate = 80
> > time.sleep(2)
> > start = time.time()
> > camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
> > finish = time.time()
> > print('Captured 40 images at %.2ffps' % (40 / (finish - start)))
> >
> > Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file
> >
> > Best regards, Agustín
> >
>
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is
> the first hit on google for "numpy 3d array stack".
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
>
> Mark Lawrence
Hi Mark,
I know the dstack function can do the job, but i don't know how to implement it in this case.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-07-07 07:49 +0100 |
| Message-ID | <mailman.338.1436251777.3674.python-list@python.org> |
| In reply to | #93542 |
On 07/07/2015 00:16, Agustin Cruz wrote:
> On Monday, July 6, 2015 at 6:00:42 PM UTC-4, Mark Lawrence wrote:
>> On 06/07/2015 22:31, Agustin Cruz wrote:
>>> I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow).
>>>
>>> I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images.
>>>
>>> import io
>>> import time
>>> import picamera
>>> #from PIL import Image
>>>
>>> def outputs():
>>> stream = io.BytesIO()
>>> for i in range(40):
>>> # This returns the stream for the camera to capture to
>>> yield stream
>>> # Once the capture is complete, the loop continues here
>>> # (read up on generator functions in Python to understand
>>> # the yield statement). Here you could do some processing
>>> # on the image...
>>> #stream.seek(0)
>>> #img = Image.open(stream)
>>> # Finally, reset the stream for the next capture
>>> stream.seek(0)
>>> stream.truncate()
>>>
>>> with picamera.PiCamera() as camera:
>>> camera.resolution = (640, 480)
>>> camera.framerate = 80
>>> time.sleep(2)
>>> start = time.time()
>>> camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
>>> finish = time.time()
>>> print('Captured 40 images at %.2ffps' % (40 / (finish - start)))
>>>
>>> Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file
>>>
>>> Best regards, Agustín
>>>
>>
>> http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is
>> the first hit on google for "numpy 3d array stack".
>>
>> --
>> My fellow Pythonistas, ask not what our language can do for you, ask
>> what you can do for our language.
>>
>> Mark Lawrence
>
> Hi Mark,
> I know the dstack function can do the job, but i don't know how to implement it in this case.
>
Sadly I don't know how either, but if I can find the above link in
seconds, I'm fairly certain that with a little searching you could find
something. Specific sites like nullege or koders might offer solutions.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web