Home | Community | Message Board

Out-Grow.com - Mushroom Growing Kits & Supplies
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: North Spore North Spore Mushroom Grow Kits & Cultivation Supplies   Original Sensible Seeds Bulk Cannabis Seeds   Myyco.com Golden Teacher Liquid Culture For Sale   PhytoExtractum Buy Bali Kratom Powder   MagicBag.co Certified Organic All-In-One Grow Bags by Magic Bag

Jump to first unread post Pages: 1
OfflineeLeSDenes
Mycelium Expander
Male User Gallery


Folding@home Statistics
Registered: 05/25/11
Posts: 955
Last seen: 6 days, 2 hours
Timelapse tek - with a Raspberry Pi and a webcam * 9
    #26351786 - 11/29/19 10:51 AM (4 years, 3 months ago)

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
InvisiblebodhisattaMDiscordReddit
Smurf real estate agent
 User Gallery
Folding@home Statistics
Registered: 04/30/13
Posts: 61,891
Loc: Milky way
Trusted Cultivator
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26351801 - 11/29/19 11:05 AM (4 years, 3 months ago)

:neat:
I use magic lantern firmware on my camera

Extras: Filter Print Post Top
Invisiblefilthyknees
no coincidence
 User Gallery

Registered: 03/08/13
Posts: 6,283
Trusted Cultivator
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26351838 - 11/29/19 11:27 AM (4 years, 3 months ago)

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
InvisibleStygianKnight
A Mushroom

Registered: 03/12/12
Posts: 2,717
Trusted Cultivator
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: filthyknees]
    #26351852 - 11/29/19 11:39 AM (4 years, 3 months ago)

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
InvisiblebodhisattaMDiscordReddit
Smurf real estate agent
 User Gallery
Folding@home Statistics
Registered: 04/30/13
Posts: 61,891
Loc: Milky way
Trusted Cultivator
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: StygianKnight]
    #26351860 - 11/29/19 11:44 AM (4 years, 3 months ago)

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

Edit,
Looks like Canon only

Extras: Filter Print Post Top
OfflineeLeSDenes
Mycelium Expander
Male User Gallery


Folding@home Statistics
Registered: 05/25/11
Posts: 955
Last seen: 6 days, 2 hours
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: StygianKnight]
    #26351869 - 11/29/19 11:49 AM (4 years, 3 months ago)

Quote:

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
OfflineKrip
Garbage Decomposer
I'm a teapot User Gallery


Registered: 05/27/18
Posts: 50
Loc: Underground
Last seen: 4 months, 11 days
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes] * 2
    #26402235 - 12/26/19 10:08 PM (4 years, 3 months ago)

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
OfflineeLeSDenes
Mycelium Expander
Male User Gallery


Folding@home Statistics
Registered: 05/25/11
Posts: 955
Last seen: 6 days, 2 hours
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: Krip] * 1
    #26402483 - 12/27/19 04:54 AM (4 years, 3 months ago)

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
OfflineKrip
Garbage Decomposer
I'm a teapot User Gallery


Registered: 05/27/18
Posts: 50
Loc: Underground
Last seen: 4 months, 11 days
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26407117 - 12/30/19 01:14 AM (4 years, 2 months ago)

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
InvisibleYogiBear
Male User Gallery


Registered: 08/24/19
Posts: 845
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #26407174 - 12/30/19 02:38 AM (4 years, 2 months ago)

Great work! 👍🍿😎

Extras: Filter Print Post Top
OfflineMarmot
Stranger
Registered: 10/06/21
Posts: 1
Last seen: 2 years, 2 months
Re: Timelapse tek - with a Raspberry Pi and a webcam [Re: eLeSDenes]
    #27571245 - 12/06/21 11:02 AM (2 years, 3 months ago)

I really appreciate this

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

Shop: North Spore North Spore Mushroom Grow Kits & Cultivation Supplies   Original Sensible Seeds Bulk Cannabis Seeds   Myyco.com Golden Teacher Liquid Culture For Sale   PhytoExtractum Buy Bali Kratom Powder   MagicBag.co Certified Organic All-In-One Grow Bags by Magic Bag


Similar ThreadsPosterViewsRepliesLast post
* Combo TEK Bulk Using Turkey Bags GratefulDread 2,185 9 03/20/03 06:28 PM
by Ali
* Webcam in an PMP morian 627 4 10/03/04 05:55 PM
by Baby_Hitler
* Growth Log Pictures, Pk-tek ---- First Timer ---- DatDaNK420 1,254 10 07/07/03 08:30 AM
by makisupa09
* Too Much Water in BRF PF TEK? Anonymous 9,516 8 05/15/03 08:31 AM
by MykeOfile
* Gerber Tek
( 1 2 all )
Ekuenchuocha 3,238 22 08/15/02 03:20 PM
by _VisioN_
* Some Rye Questions About Magash Tek Sinistar 773 4 02/02/05 07:49 PM
by Sinistar
* Finally! first pins pics! and a good time-lapse webcam prog plz? Boffsun 1,298 8 03/02/05 09:00 PM
by Anything4Poppies
* Ultra neglect tek?? MeSaUsA 1,021 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, LogicaL Chaos, 13shrooms, Stipe-n Cap, Pastywhyte, bodhisatta, Tormato, Land Trout, A.k.a
1,978 topic views. 17 members, 119 guests and 91 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2024 Mind Media. Some rights reserved.

Generated in 0.028 seconds spending 0.01 seconds on 14 queries.