Home | Community | Message Board

The Spore Depot
This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Shop: Original Sensible Seeds Bulk Cannabis Seeds   North Spore North Spore Mushroom Grow Kits & Cultivation Supplies   MagicBag.co Certified Organic All-In-One Grow Bags by Magic Bag   Sporeworks.EU Spores for European Microscopy   Myyco.com Golden Teacher Liquid Culture For Sale

Jump to first unread post Pages: 1
Some of these posts are very old and might contain outdated information. You may wish to search for newer posts instead.
Timelapse tek - with a Raspberry Pi and a webcam * 9
    #26351786 -

Hello everyone,

Not sure if there are methods for this posted here or not, but I thought many of you want to take timelapse type videos to create gifs. It not just lets you to view the shroom how it grows but it also looks more interesting than static images. There exists many professional setups for this, but here I present you a very cheap and simple solution. You only need a Raspberry Pi (any model will do, I used a really old one) and a webcam.
The setup for petri dish timelapse:


The setup for mono timelapse:



If your raspberry pi is setup, connect it to your network and you can use ssh to login.
You can do that from a terminal (if you have Mac or Linux) or use PuTTY on windows.
To open an ssh connection, open the terminal and type: ssh pi@IP_ADDRESS_OF_PI.
Then, you need to install opencv and screen.
In terminal type:     

  • sudo apt-get install libopencv-dev
  • sudo apt-get install screen


These 2 commands will install the necessary packages to run the program. Then, create a folder for the program, name it something like timelapse_video. To do this enter in terminal : mkdir timelapse_video. Then to change to that folder : cd timelapse_video.
Now we have to create the program. You can use your favourite text editor if you have any or just use vim. In terminal type: vi timelapse.py
This will create a file and open the editor. Copy paste the following:

import cv2
import time
import sys


#reading command line arguments
a = float(sys.argv[1])
b = float(sys.argv[2])
c = int(sys.argv[3])

# initialize the camera
cam = cv2.VideoCapture(c)

number_of_days = a # number of days to run
snapshot_frequency = b # number of seconds to wait before taking the next image
total_seconds_run = 86400 * number_of_days
number_of_iterations = int(total_seconds_run/snapshot_frequency)

for i in range(0,number_of_iterations) :
    #read camera
    ret, image = cam.read()

    #if camera was successfully read
    if ret:

        #get epoch time in seconds
        seconds = time.time()

        #the file name will be S_ + the epoch time to have different filenames
        filestring = 'S_' + str(seconds) + '.jpg'
        cv2.imwrite(filestring,image)

        #sleep until the next timestep
        time.sleep(snapshot_frequency)

cam.release()


To save the program press ESC and type    :wq      (with the colon)
To start the program you will use this general form : python timelapse.py <number_of_days_to_run> <time_interval_in_seconds> <camera_number>. So let's say you want to run it for 5 days and want to snap an image in every half an hour you type: python timelapse.py 5 1800 0 which will run it with camera '0'. If you have multiple cameras attached via usb, you can start the program specifying the camera number.

we are also going to use 'setsid' to run the process in the background. To do this, in terminal type:  setsid python timelapse.py 5 1800 0 to run the timelapse program in the background
You can check your running process with (terminal) : ps -ef | grep timelapse which will give a process ID just in case you need to terminate the program just type: kill <process_id>

This program will create images in given time intervals you so you will have lots of images. You can use any gif-maker to stitch these to video and gifs.

Some examples of the recording:

Isolation of PE


Mycelium under microscope




B+


LPEU


Rusty Whyte


I hope I did not make it complicated and if you have any problem setting this up, just let me know.

Edited by eLeSDenes (03/28/21 04:45 AM)

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26351801 -

:neat:
I use magic lantern firmware on my camera

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26351838 -

Nice thread


--------------------
But if you're in a hurry, and really got to go
If you're in a hurry, might have to find out slow
That it's one thing to try and another to fly
You get there quicker just a step at a time
It's one thing to bark, another to bite
The show ain't over till you pack up at night

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: filthyknees]
    #26351852 -

Awesome!
This will come in handy.

For those with old school DSLR cameras, you can get a Timer Shutter release remote for $10-$20 that can be set to take a picture every time interval.
The downside though is unless you have a wireless card, the only way to see your progress on camera is to touch it and possibly mess up its position.  The webcam option above means you can watch the progress in ‘real time’ without needing to touch anything.

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: StygianKnight]
    #26351860 -

Look into magic lantern for any DSLR it will do it automatically.

Edit,
Looks like Canon only

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: StygianKnight]
    #26351869 -

StygianKnight said:
Awesome!
This will come in handy.

For those with old school DSLR cameras, you can get a Timer Shutter release remote for $10-$20 that can be set to take a picture every time interval.
The downside though is unless you have a wireless card, the only way to see your progress on camera is to touch it and possibly mess up its position.  The webcam option above means you can watch the progress in ‘real time’ without needing to touch anything.



Exactly, I just use Filezilla to pull the images it made. In the future, I will also check how many cameras it is possible to control simultaneously so more things can be recorded.

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes] * 2
    #26402235 -

The code is wrong! You skipped an identation in
Quote:
time.sleep(snapshot_frequency)


So it would shoot all the photos at the same time, wait, and end the script.
Code should be:

import cv2
import time
import sys

# initialize the camera
cam = cv2.VideoCapture(0)

# reading command line arguments
number_of_days = float(sys.argv[1]) # number of days to run
snapshot_frequency = float(sys.argv[2]) # number of seconds to wait before taking the next image

# calculating iterations
total_seconds_run = 86400 * number_of_days
number_of_iterations = int(total_seconds_run/snapshot_frequency)

for i in range(0,number_of_iterations):
    #read camera
    ret, image = cam.read()

    #if camera was successfully read
    if ret:
        #get epoch time in seconds
        seconds = time.time()

        # file name = S_ + the epoch time --> have different filenames
        filestring = 'S_' + str(seconds) + '.jpg'
        cv2.imwrite(filestring,image)

        # sleep until the next timestep
        time.sleep(snapshot_frequency)

cam.release()


I modified a little bit the code so it could be shorter, no change in functionality.
Nice post!


--------------------
Alea iacta est.

Edited by Krip (12/26/19 10:09 PM)

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: Krip] * 1
    #26402483 -

Hey man,

Thanks good catch, edited it! It was indented but for some reason it was not visible here, but I am happy that you spotted it, as it would break the program for anyone trying to use it. :laugh:

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26407117 -

Clearly it was a post typo/error, i just posted it so you could check it and fix it in the original post :smile:. It would be great to have a functionality to post code, i know it's a lot to ask though, it's a mycology forum after all!

Nice idea by the way, loved it, will probably make some timelapse using this tek. Love 2 u <3


--------------------
Alea iacta est.

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26407174 -

Great work! 👍🍿😎

Extras: Filter Print Post Top
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #27571245 -

I really appreciate this

Extras: Filter Print Post Top
Jump to top Pages: 1

Shop: Original Sensible Seeds Bulk Cannabis Seeds   North Spore North Spore Mushroom Grow Kits & Cultivation Supplies   MagicBag.co Certified Organic All-In-One Grow Bags by Magic Bag   Sporeworks.EU Spores for European Microscopy   Myyco.com Golden Teacher Liquid Culture For Sale


Similar ThreadsPosterViewsRepliesLast post
* Combo TEK Bulk Using Turkey Bags GratefulDread 2,299 9 03/20/03 06:28 PM
by Ali
* Webcam in an PMP morian 654 4 10/03/04 05:55 PM
by Baby_Hitler
* Growth Log Pictures, Pk-tek ---- First Timer ---- DatDaNK420 1,318 10 07/07/03 08:30 AM
by makisupa09
* Too Much Water in BRF PF TEK? Anonymous 9,856 8 05/15/03 08:31 AM
by MykeOfile
* Gerber Tek
( 1 2 all )
Ekuenchuocha 3,534 22 08/15/02 03:20 PM
by _VisioN_
* Some Rye Questions About Magash Tek Sinistar 786 4 02/02/05 07:49 PM
by Sinistar
* Finally! first pins pics! and a good time-lapse webcam prog plz? Boffsun 1,321 8 03/02/05 09:00 PM
by Anything4Poppies
* Ultra neglect tek?? MeSaUsA 1,055 8 10/15/02 08:10 PM
by z@z.com

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: Shroomism, george castanza, RogerRabbit, veggie, mushboy, fahtster, the_chosen_one, LogicaL Chaos, 13shrooms, hamloaf, cronicr, Stipe-n Cap, Pastywhyte, bodhisatta, Tormato, Land Trout, A.k.a
2,398 topic views. 18 members, 1,467 guests and 144 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2026 Mind Media. Some rights reserved.

Generated in 0.029 seconds spending 0.012 seconds on 16 queries.