kevpatts2
Posts: 8
Joined: Thu Jul 19, 2012 1:58 pm

Re: Lightweight python motion detection

Tue Jul 30, 2013 8:09 am

Krisduck wrote:Is anyone else getting (mostly) green horizontal lines across their images? It's triggering the motion capture, so I've got a bunch of pics with green lines across them, but with no other movement. It seems like it might mostly be in lower-light situations, but I think there's been a few in brighter shots too. I'll try to keep an eye on it.

Cheers,

Kris
Hey Kris, I'm having no such problems, but it may be due to a subtlety in your code. Can you post the troublesome script and I'll see if I can reproduce the green lines problem?

How low light?

kevpatts2
Posts: 8
Joined: Thu Jul 19, 2012 1:58 pm

Re: Lightweight python motion detection

Tue Jul 30, 2013 8:17 am

Nige C wrote:This thread has been an insight to me. I received my Pi Camera Boards last week. I'm am a member of the Cloud Appreciation Society, this thread has really helped me. I want to monitor the great clouds around my locale right now with timelapse :)
Thank you everyone.
Nige, using my method you can upload your cloud pictures directly to the cloud!

Nige C
Posts: 46
Joined: Thu Jul 19, 2012 12:22 am
Location: Hadleigh, Suffolk

Re: Lightweight python motion detection

Wed Jul 31, 2013 12:00 am

kevpatts2 wrote:
Nige C wrote:This thread has been an insight to me. I received my Pi Camera Boards last week. I'm am a member of the Cloud Appreciation Society, this thread has really helped me. I want to monitor the great clouds around my locale right now with timelapse :)
Thank you everyone.
Nige, using my method you can upload your cloud pictures directly to the cloud!
Hehe love it :)
Retired power engineer with a lot of real life experience. Life is an adventure again :)

Rushview
Posts: 1
Joined: Fri Aug 02, 2013 7:10 am

Re: Lightweight python motion detection

Fri Aug 02, 2013 7:14 am

I've been tinkering with this script and it's working brilliantly, just need to tweak the sensitivity a touch more.

I'm trying to incorporate time triggering so that the motion detection is only activated at certain times during the day, say 13:00 whilst 14:00, then later again from 17:00 whilst 19:00, but I'm having problems incorporating it into the script. Whilst I'm still pretty fresh getting into Python, does anyone have an idea how to do this simply, without having to fall back on cron?

kevpatts2
Posts: 8
Joined: Thu Jul 19, 2012 1:58 pm

Re: Lightweight python motion detection

Fri Aug 02, 2013 9:45 am

I'm doing something similar, but taking a different approach.

I recently bought two of these http://www.belkin.com/us/c/WSPWRCSR and they have a lot of my home cinema and tech on the switched ports of them. We turn them off at night and when the house is empty. One of them has a WRT-54G set up as a wifi bridge on it's switched port.

I'm looking to set the security camera to ping this bridge, and only take photos when it can't reach it. This means it will only function when we switch the other things off.

This is intended to prevent the camera taking unnecessary pics when our lives don't confirm to the defined schedule.

Haven't really started doing this yet, hopefully this weekend I will.

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Fri Aug 02, 2013 10:52 am

zeronickname wrote:I've modified the original script to auto upload the pictures to Picasa/Google Photos (taking advantage of the unlimited space by resizing the pictures to be < 2048px)

https://github.com/zeronickname/RasPiMotionDetect
I tried your script. Upload to picasa works very well. However force capture does not seem to work as intended. Noticed also that -t 0 option is too harsh for RasPi camera, picture quality is degraded. Choose to remove -t 0 and picture quality is much better (5 s default value). Added also auto AWB and exposure.

Thanks for your work !

zeronickname
Posts: 13
Joined: Sat Jul 20, 2013 4:35 pm

Re: Lightweight python motion detection

Fri Aug 02, 2013 1:42 pm

pinjan wrote: I tried your script. Upload to picasa works very well. However force capture does not seem to work as intended. Noticed also that -t 0 option is too harsh for RasPi camera, picture quality is degraded. Choose to remove -t 0 and picture quality is much better (5 s default value). Added also auto AWB and exposure.

Thanks for your work !
You're right about the forcecapture. It was originally taken verbatim from pageauc's script and as noted by Kesthal (http://www.raspberrypi.org/phpBB3/viewt ... 83#p391583), there is a bug with this.

I'll make some updates and include Kesthal's selective search.
Thanks for the t=0 tip. I took it down to 0 because I noticed I missed fast moving events with a five second delay. I might make this configurable so you can switch between quality and speed of capture.

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Fri Aug 02, 2013 3:38 pm

zeronickname:

one more suggestion as picasa albums are limited to 1000 photos per album to automatically create new album after 1000 captures. https://support.google.com/picasa/answer/43879?hl=fi So put some kind of counter to 1000 and then create album_name1, 2, 3 etc. respectively based on counter. I tried to do this myself, but it seems I need to hone my coding skills more :oops:

zeronickname
Posts: 13
Joined: Sat Jul 20, 2013 4:35 pm

Re: Lightweight python motion detection

Sat Aug 03, 2013 5:30 am

pinjan wrote:zeronickname:

one more suggestion as picasa albums are limited to 1000 photos per album to automatically create new album after 1000 captures. https://support.google.com/picasa/answer/43879?hl=fi So put some kind of counter to 1000 and then create album_name1, 2, 3 etc. respectively based on counter. I tried to do this myself, but it seems I need to hone my coding skills more :oops:
I pushed some updates to https://github.com/zeronickname/RasPiMotionDetect.
It now creates a new album for every day it runs. Not really a "proper" fix for the 1000 pic limit, but it does mitigate the issue somewhat (as long as you're not continuously running the script, of course) -- I'll implement your incrementing-album-suffix suggestion, but it's not there yet.
It also has the forceCapture now hopefully working (I've used Kesthal's implementation instead of rolling my own to keep it as close to the forum versions as possible -- I'd also like to incorporate his "selective scanning at some point :)
The ini file also allows you to easily add any options you want to raspistill so you can choose (awb, timeout, etc) settings without needing to hack the .py file directly (it does mean you'll need to merge the new config.ini-EXAMPLE with your personal config.ini when you update)

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Sat Aug 03, 2013 3:06 pm

THANKS ! I will test it today and tomorrow. It is interesting to see how did you fix it

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Sun Aug 04, 2013 2:57 pm

Some testing results so far:

- Force capture works now.

- new ini file works well :)

- New album name for everyday works only if rebooted daily. If not rebooted, then pictures captured e.g. today will be stored to album created yesterday (I am starting this program automatically during boot)

- I set hrs_to_loop = 8760, but program worked only for ~15 hours. Not sure yet about error, I am trying to reproduce it.

Other remarks:

I have tried different image settings now to reduce the file size and 1280×960 pixels with -q 15 gives acceptable result for me. File size is around 200 KB's and uploading goes much smoother.

zeronickname
Posts: 13
Joined: Sat Jul 20, 2013 4:35 pm

Re: Lightweight python motion detection

Sun Aug 04, 2013 3:39 pm

pinjan wrote:New album name for everyday works only if rebooted daily.
Yes... sorry, it uses the date when it was started. Newest version now has configurable options for the date (again, only the date when it starts) -- maybe I should look into having it configurable for people who leave it continuously running, such as yourself.
As requested by yourself, this version also automatically checks for number of photos in an album and creates a new picasa album when it hits a 1000 photos.
pinjan wrote:I set hrs_to_loop = 8760, but program worked only for ~15 hours. Not sure yet about error, I am trying to reproduce it.
Was there any output on the terminal when it finished? Or anything in dmesg (wondering if the kernel killed it due to running out of resources -- filehandles/memory/etc)

Can you run it with
./RasPiCamera.py --logging-level=debug --logging-file=/home/pi/raspi.log
That should dump (a lot of) logs to file.

I usually just leave it running for 8-10hrs a day (started the next day via a cron job) -- so I can't say I've run any long term stability tests on it.

Feel free to log an issue on github.

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Mon Aug 05, 2013 2:08 pm

zeronickname wrote: As requested by yourself, this version also automatically checks for number of photos in an album and creates a new picasa album when it hits a 1000 photos.
Ok, I need to clone this newest version
zeronickname wrote: Was there any output on the terminal when it finished? Or anything in dmesg (wondering if the kernel killed it due to running out of resources -- filehandles/memory/etc)
No, unfortunately nothing in terminal or dmesg. It could be that I am running out of juice (1A power supply) using RasPi via USB WLAN stick. I am going to change supply to 2A version.
zeronickname wrote: Can you run it with
./RasPiCamera.py --logging-level=debug --logging-file=/home/pi/raspi.log
That should dump (a lot of) logs to file.
Yes, I am running now with logging level. Let's see if I can get anything into log. If nothing there then it must be my power supply.

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Mon Aug 05, 2013 6:24 pm

It is saying that token expired in logs:

2013-08-05 21:18:02 CRITICAL: InsertPhotoSimple barfed! Exception: (403, 'Forbidden', 'Token expired')
2013-08-05 21:18:03 DEBUG: Current queue size FullSize:100 ThumbSize:0

zeronickname
Posts: 13
Joined: Sat Jul 20, 2013 4:35 pm

Re: Lightweight python motion detection

Mon Aug 05, 2013 6:40 pm

pinjan wrote:It is saying that token expired in logs:

2013-08-05 21:18:02 CRITICAL: InsertPhotoSimple barfed! Exception: (403, 'Forbidden', 'Token expired')
2013-08-05 21:18:03 DEBUG: Current queue size FullSize:100 ThumbSize:0
Odd, the token should last for around two weeks. Does it stop there? It "should" have tried to re-login to picasa after that.
Any chance you can share the full logs (there should be no personally identifiable information -- except the album name you used on Picasa)

So as not to hijack this thread too much, can you post them directly to github?
https://github.com/zeronickname/RasPiMo ... t/issues/3

I'll try to reproduce it on my side too.

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Mon Aug 05, 2013 7:40 pm

Yes it is odd. Unfortunately I mistakenly deleted Raspi.log, but will run new session and will post full logs to github. Will also raise issues from now on there.

zeronickname
Posts: 13
Joined: Sat Jul 20, 2013 4:35 pm

Re: Lightweight python motion detection

Wed Aug 07, 2013 5:38 am

pinjan wrote:Yes it is odd. Unfortunately I mistakenly deleted Raspi.log, but will run new session and will post full logs to github. Will also raise issues from now on there.
Made some mods to the script. It allows you to run it for infinite time now (set run time as zero). I also changed some picasa login timeouts (not sure if that makes any difference, to be honest)

I also ran the script for 36hrs without any issues. I did see the "token expired" error, but the script re-logged in to Picasa and continued on (as expected). So, if you get the logs from a failed run, please stick them on github for me to take a look at.

pinjan
Posts: 8
Joined: Fri Aug 02, 2013 10:43 am

Re: Lightweight python motion detection

Wed Aug 07, 2013 4:42 pm

zeronickname wrote: I also ran the script for 36hrs without any issues. I did see the "token expired" error, but the script re-logged in to Picasa and continued on (as expected). So, if you get the logs from a failed run, please stick them on github for me to take a look at.
I haven't been able to reproduce it . It has been running now for 24 hours without issues.

EDIT: it has been crashed again. Looked wrong folder. I should have all logs now
EDIT2: nothing special on log, it must be power supply issue
EDIT3: issue anyway added to github

james1700
Posts: 3
Joined: Fri Aug 09, 2013 7:51 am

Re: Lightweight python motion detection

Fri Aug 09, 2013 7:58 am

Hi,

Not sure if anyone else has seen this or if im doing something wrong. Ive done a git pull to the latest code. I have a cron which starts the script at 6am and stops the script and 8pm. On the first day in google i get an album called RasPiMotionDetect_06-08-13_0 however the next day when the script starts again i get just RasPiMotionDetect with no date.

thanks
james

zeronickname
Posts: 13
Joined: Sat Jul 20, 2013 4:35 pm

Re: Lightweight python motion detection

Sat Aug 10, 2013 5:43 am

james1700 wrote:Hi,

Not sure if anyone else has seen this or if im doing something wrong. Ive done a git pull to the latest code. I have a cron which starts the script at 6am and stops the script and 8pm. On the first day in google i get an album called RasPiMotionDetect_06-08-13_0 however the next day when the script starts again i get just RasPiMotionDetect with no date.

thanks
james
Hi,
<updated>
Just realised there was a bug when i created a new album. Can you do a git pull and retry the latest code, please?
If you still have an issue, can you run it with
./RasPiCamera.py --logging-level=debug --logging-file=/home/pi/raspi.log
and post the logs please? Just add the log options directly to cron. Again, if possible, to github so as not to hijack this thread.

Secondly, how are you stopping the script with cron? Saving the PID & issuing a kill? While this is fine, note that killing the script may leave some pictures un-uploaded. You may find it better to start the script from cron and set hrs_to_loop (in config.ini) to be 14. This ensures the script stops taking pictures at 2000, but will continue to run until all previously taken photos are uploaded to Picasa.
Last edited by zeronickname on Wed Aug 14, 2013 4:13 am, edited 2 times in total.

jim8
Posts: 3
Joined: Tue Sep 25, 2012 2:57 am

Re: Lightweight python motion detection

Sat Aug 10, 2013 6:23 am

Thanks brainflakes for your script and everybody else that contributed to it or shared ideas!

I got the camera module since I wanted to do a security/monitoring setup and this thread has helped a lot to getting me started.

The next steps are to setup a webserver to upload captures to, then have raspberrypi poll the webserver for monitoring instructions. That way the I can remotely (from work or outside) and tell the camera to monitor or stop before I get through my door. This also has the benefit of being able to see what's going on remotely and not have to worry (too much) if someone takes my hardware.

james1700
Posts: 3
Joined: Fri Aug 09, 2013 7:51 am

Re: Lightweight python motion detection

Wed Aug 14, 2013 7:41 am

Hi,

Tested the latest code and dated folder names in google are working. Thanks very much.

Il post anything else i find directly on github.

thanks.
james.

kevindomadia
Posts: 8
Joined: Tue Jul 02, 2013 6:28 pm

Re: Lightweight python motion detection

Thu Aug 15, 2013 2:47 pm

Hi!... just wanted to know if this script will work for any other USB camera?.... I am using Logitech C310.... Thanks in advance!

Jorik
Posts: 4
Joined: Mon Aug 19, 2013 10:09 am

Re: Lightweight python motion detection

Mon Aug 19, 2013 10:19 am

Hi,

When I run the script on my Rpi, I always get the same error.
I have really no idea how to fix it.
I also tried the script from pageauc but I get the same error.
This is the error:

Traceback (most recent call last):
File "motiondetect.py", line 69, in <module>
image1, buffer1 = captureTestImage()
File "motiondetect.py", line 39, in captureTestImage
im = Image.open(imageData)
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1980, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file

I tried an other program to find out of the webcam was working, but it works just fine...
Does anyone know how to fix this?


Thanks in advance!

ps. sorry for my bad English, I'm Dutch

james1700
Posts: 3
Joined: Fri Aug 09, 2013 7:51 am

Re: Lightweight python motion detection

Mon Aug 19, 2013 12:20 pm

That sounds like something else is already running raspistill.

On your pi if you run:

Code: Select all

ps -ef | grep raspistill
Do you see any output for raspistill.

Return to “Camera board”