Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'from:addr:yahoo.co.uk': 0.05; 'pil': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'stack': 0.13; 'def': 0.13; 'subject: \n ': 0.15; '(read': 0.16; 'cruz': 0.16; 'mark,': 0.16; 'module?': 0.16; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sadly': 0.16; 'seconds,': 0.16; 'something.': 0.16; 'subject:array': 0.16; 'subject:image': 0.16; 'time.time()': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'language': 0.19; '>>>': 0.20; '2015': 0.20; 'fairly': 0.22; 'complete,': 0.22; 'lawrence': 0.22; 'second': 0.24; 'import': 0.24; 'header :In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'skip:# 10': 0.27; 'finally,': 0.27; 'yield': 0.27; 'function': 0.28; 'skip:u 20': 0.28; 'array': 0.29; 'reset': 0.29; "i'm": 0.30; 'code': 0.30; 'solutions.': 0.30; 'certain': 0.31; 'anyone': 0.32; 'implement': 0.32; 'language.': 0.32; 'stream': 0.33; 'file': 0.34; 'skip:c 30': 0.35; 'next': 0.35; 'could': 0.35; 'possible,': 0.35; 'but': 0.36; 'project': 0.36; 'url:org': 0.36; 'monday,': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'google': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'subject:with': 0.40; 'some': 0.40; 'per': 0.62; 'charset:windows-1252': 0.62; 'our': 0.64; 'capture': 0.66; 'here': 0.66; 'offer': 0.66; 'saving': 0.70; 'received:89': 0.80; 'agustin': 0.84; 'pythonistas,': 0.84; 'subject:Fast': 0.84; 'url:scipy': 0.84; 'utc-4,': 0.84; 'url:reference': 0.91; 'camera': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi Date: Tue, 07 Jul 2015 07:49:25 +0100 References: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> <9647ca9f-3b8c-48e2-b422-338654c3b4fb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-89-240-167-175.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <9647ca9f-3b8c-48e2-b422-338654c3b4fb@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436251777 news.xs4all.nl 2957 [2001:888:2000:d::a6]:37051 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93550 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