billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Aug 16, 2015 4:05 pm

YvesG wrote:Is it possible to add a button under "system" that do a "git pull origin" to update from UI?
It would be a nice convenience and I'll look at doing it. The only complication would be that there
should be a feedback to the user that the update was successful or not.

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Aug 16, 2015 5:20 pm

billw wrote:
YvesG wrote:Is it possible to add a button under "system" that do a "git pull origin" to update from UI?
It would be a nice convenience and I'll look at doing it. The only complication would be that there
should be a feedback to the user that the update was successful or not.
fwiw ime the best way to handle this kind of thing (deploys from git) is to use the same model that is used in the ruby world to deploy webapps with capistrano. The model is pretty simple and uses symlink from a "current" directory to point to the actual checkout you want to use. This allows you to have multiple checkouts and rollback if you need to. So basically an update would look like this:
- clone a new directory name under the tag/version you want to upgrade to (this can be smarter, hardlinks etc, to avoid taking unnecessary space with stuff that hasn't change)
- save where the current symlinks are pointing to
- point the symlink from the "current" directory to the new version
- test/whatever
- if stuff isn't working repoint the symlinks to the previous "good" version.

I don't know that you want to do all that work but thought I'd share even if just for inspiration. As soon as I have the basics working here I'd love to give back even just a bit by maybe doing a few of these simpler things (I can't really do C stuff).

lassiko
Posts: 10
Joined: Tue May 12, 2015 7:04 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Aug 17, 2015 6:28 am

This is probably not direct PiKrellCam issue but maybe someone can advice what to do:

For some reason my camera picture has went really blurry. I did remove the camera and cleaned the lens etc so issue is not there.
All camera/picture settings are same as it has been before.

Maybe some issues with actual camera module?
https://dl.dropboxusercontent.com/u/467 ... 1.58_0.jpg
https://dl.dropboxusercontent.com/u/467 ... 2.41_0.jpg

User avatar
jbeale
Posts: 3581
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 18, 2015 2:20 am

Blurry image is not software
Maybe something got on the lens?

lassiko
Posts: 10
Joined: Tue May 12, 2015 7:04 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 18, 2015 5:36 am

jbeale wrote:Blurry image is not software
Maybe something got on the lens?
I did cleaned the lens as i though that this was the issue. It happened suddenly so i assume now that it is now someway faulty camera module.

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 18, 2015 3:11 pm

Hey Billw,

I can end up with quite long periods of motion (10 minutes) and that creates a couple problems I'm wondering about:

- is boxing threaded? it looks like it since it seems to be using exec_child_event that calls exec_command that uses a fork, but again, not a C guy really, might be missing something
- were you planning to add some kind of ceiling to avoid runaway processes? I had this with raspimjpeg a few times, process would get stuck recording and file grow to several GBs. It would be great to have a stop condition
- related to that it would be great to be able to chunk longer periods of motion, which would also result in faster boxing. so basically if motion lasts longer than ceiling, close the file, kick off boxing and start a new file. This would also help with avoiding disk full conditions due to boxing taking 2x the space with the temp file written to disk and before the original h264 is removed.

thoughts?

also regarding installation, if people already have apache installed, install nginx and then use 80 as a default port, the install script will fail because nginx will fail to install since the start script will fail due to the port being already in use. I don't see yet a clear way to handle this, but for now to help folks who might be having problems with that to just check is apache is installed and warn them about it.

YvesG
Posts: 46
Joined: Wed Oct 03, 2012 6:54 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 18, 2015 4:36 pm

@jbeale hi,
there is a mismatch between the time displayed in the live video and the thumb
For a thumb at 16:18 but in fact it should be 18:18 (live stream is 18:18 and pi is 18:18 too)
Do you have this issue as well?

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 18, 2015 5:18 pm

YvesG wrote:@jbeale hi,
there is a mismatch between the time displayed in the live video and the thumb
For a thumb at 16:18 but in fact it should be 18:18 (live stream is 18:18 and pi is 18:18 too)
Do you have this issue as well?
fwiw I'm not seeing this, just triggered a few recordings and looked at others and they all match.

speaking of thumbs, @billw, I just realized they have the cnt labels stuff on them, had motion on one at the bottomof the screen and it's got labels all over. not huge, but thought I'd mentioned.

User avatar
jbeale
Posts: 3581
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 19, 2015 12:44 am

YvesG wrote:@jbeale hi,
there is a mismatch between the time displayed in the live video and the thumb
For a thumb at 16:18 but in fact it should be 18:18 (live stream is 18:18 and pi is 18:18 too)
Do you have this issue as well?
Interesting, i have never seen that on my systems. The thumb time comes from the filesystem time when the image was saved. Still, thumb and video times all agree for me.

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 19, 2015 3:35 am

spikedrba wrote:Hey Billw,
- is boxing threaded? it looks like it since it seems to be using exec_child_event that calls exec_command that uses a fork, but again, not a C guy really, might be missing something
Boxing is not done in a pikrellcam thread but is a fork to a separate boxing process which
pikrellcam does not wait on. So boxing is a background process and pikrellcam catches the
child exit signal and checks for the boxing process pid so that it knows when the boxing
process ends.
- were you planning to add some kind of ceiling to avoid runaway processes? I had this with raspimjpeg a few times, process would get stuck recording and file grow to several GBs. It would be great to have a stop condition
- related to that it would be great to be able to chunk longer periods of motion, which would also result in faster boxing. so basically if motion lasts longer than ceiling, close the file, kick off boxing and start a new file. This would also help with avoiding disk full conditions due to boxing taking 2x the space with the temp file written to disk and before the original h264 is removed.
A stuck recording would be a major bug in the program and I would think I would need to
tackle the bug! I haven't seen anything like that happen yet. But I can look at having a
recording length limit as a basic option, that shouldn't be a problem.
also regarding installation, if people already have apache installed, install nginx and then use 80 as a default port, the install script will fail because nginx will fail to install since the start script will fail due to the port being already in use. I don't see yet a clear way to handle this, but for now to help folks who might be having problems with that to just check is apache is installed and warn them about it.
The install script already warns that port 80 should not be selected if it's otherwise in use... so
I'm not sure I want to get into trying to figure out how a system might be configured. There's
web servers other than nginx and apache.

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 19, 2015 3:41 am

spikedrba wrote: speaking of thumbs, @billw, I just realized they have the cnt labels stuff on them, had motion on one at the bottomof the screen and it's got labels all over. not huge, but thought I'd mentioned.
Turn ON: Setup->Motion->Settings->Preview_Clean
The labels can still show up occasionally because of a video/preview path timing issue, but I
think I can do something about that.

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 19, 2015 4:29 pm

Hey @Billw,

thanks for the info in previous posts, all make sense. A few more things:

- this morning I found one of the new outdoor cameras I deployed PKC to wasn't recording. The OSD was saying that motion was detected and a new video file created, same in the log, but no file was to be found. I couldn't see any issues with the system, nothing in syslog or similar. Eventually I restarted pikrellcam and video files started showing up again. Sorry I can't provide any more info to pinpoint the problem.

- while running PKC with -vm from your suggestion in a previous post I noticed this:

Code: Select all

/home/pi/pikrellcam/scripts-dist/_thumb: line 42: [: YO: integer expression expected
it seems like a $ is missing:

Code: Select all

if [ "---->MISSING $ <---- YO" -lt 0 ]; then
  YO=0
fi
- Regarding motion, I'm looking at the output of -vm and have a few question (here's a sample for ref)

Code: Select all

cvec[0]: x,y(29,46) dx,dy(10,-1) mag2,count(101,70) reject:22 box:12x12
   in_box_count:31 motion:0 vetical: 0 sparkle:0
cvec[1]: x,y(36,40) dx,dy(8,-1) mag2,count(65,248) reject:32 box:22x24
   in_box_count:265 motion:2 vetical: 0 sparkle:0
any:372 reject:54 sparkle:0 sparkle_expma:0.6
09:11:25 motion count:1 fail:1 window:1  

cvec[0]: x,y(28,43) dx,dy(9,-1) mag2,count(82,109) reject:33 box:14x16
   in_box_count:61 motion:2 vetical: 0 sparkle:0
cvec[1]: x,y(35,39) dx,dy(8,-1) mag2,count(65,196) reject:36 box:20x20
   in_box_count:214 motion:2 vetical: 0 sparkle:0
any:375 reject:69 sparkle:1 sparkle_expma:0.6
09:11:25 motion count:2 fail:0 window:0  ***MOTION***
- you print one every GOP or something?
- cvec seems to refer to the region, correct? I only had movement in regions 0 and 1
- why in the paste above in the secong group it says **MOTION** but not in the first one? the global counter if I'm reading that right it's 2 and I have a threshold of 4. that said in_box_count are definitely high enough.

thanks,

Spike

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 19, 2015 8:12 pm

spikedrba wrote: - Regarding motion, I'm looking at the output of -vm and have a few question (here's a sample for ref)

Code: Select all

cvec[0]: x,y(29,46) dx,dy(10,-1) mag2,count(101,70) reject:22 box:12x12
   in_box_count:31 motion:0 vetical: 0 sparkle:0
cvec[1]: x,y(36,40) dx,dy(8,-1) mag2,count(65,248) reject:32 box:22x24
   in_box_count:265 motion:2 vetical: 0 sparkle:0
any:372 reject:54 sparkle:0 sparkle_expma:0.6
09:11:25 motion count:1 fail:1 window:1  

cvec[0]: x,y(28,43) dx,dy(9,-1) mag2,count(82,109) reject:33 box:14x16
   in_box_count:61 motion:2 vetical: 0 sparkle:0
cvec[1]: x,y(35,39) dx,dy(8,-1) mag2,count(65,196) reject:36 box:20x20
   in_box_count:214 motion:2 vetical: 0 sparkle:0
any:375 reject:69 sparkle:1 sparkle_expma:0.6
09:11:25 motion count:2 fail:0 window:0  ***MOTION***
- you print one every GOP or something?
- cvec seems to refer to the region, correct? I only had movement in regions 0 and 1
- why in the paste above in the secong group it says **MOTION** but not in the first one? the global counter if I'm reading that right it's 2 and I have a threshold of 4. that said in_box_count are definitely high enough.
cvecs are printed when they have mag/count above the limits. Each region can have only
one cvec and if there's no motion in a region, no cvec.

In the second goup, motion for both cvec[0] and cvec[1] was valid so the entire frame passed
as motion detected. In the first goup, cvec[1] passed but cvec[0] failed so motion for the entire
frame was invalid. cvec[0] failed because it did not pass the density check. The total count
was 70 but only 31 vectors were in the density check box. There are different check ratios for
density and rejects as a function of total passing vector count in each region.

I settled on these ratios over time as I tested, but before long I will be making them user tunable
so you can experiment with various settings.

In pikrellcam it's not just detecting motion, but also looking for a reason to reject motion.
It's how I can get a good tradeoff between good desired motion detection and good
undesirable motion rejection. Noise over a frrame from distributed action like branches or
grass blowing or the occasional camera "burp" tends to produce lower density events and/or
high reject counts. At default settings motion is checked 6 times a second so I'm really not
concerned that detection is not 100% accurate for all frames. If one frame fails, one of the
next few will probably pass and I'm happy because this scheme cuts way down on false
detects.

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 19, 2015 11:14 pm

thank Billw.

I'll bite the bullet and read the code, I guess I have to if I wanna really understand what's going on.

Btw the write issue happened again, in fact i happened 6hrs ago, about 1hr after things were working again. Log file again is showing lots of activity as expected, videos and thumbnails were created, but then no trace of them on disk. I tried a dd/writing to disk in the same directory and there were no problems, so the sd card seems intact. Really no clue at what's going on.

Anything I can do to help debugging?

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Aug 20, 2015 5:53 am

spikedrba wrote: Btw the write issue happened again, in fact i happened 6hrs ago, about 1hr after things were working again. Log file again is showing lots of activity as expected, videos and thumbnails were created, but then no trace of them on disk. I tried a dd/writing to disk in the same directory and there were no problems, so the sd card seems intact. Really no clue at what's going on.

Anything I can do to help debugging?
Stop pikrellcam from the web page and run a verbose pikrellcam (pikrellcam -v) from a terminal.
You can get possible boxing error information that way that does not go into the log file.
Somebody else had an issue with boxing and maybe that's what is happening. What is your
setup (video bitrate, resolution), Also, next tiime it happens, do something that restarts the
camera without restarting pikrellcam to see if that makes things work again. The camera
restarts if you change video resolution or bitrate. But first change resolution to something and then
back to what you are using. Then if that doesn't work, change video bitrate because that
restarts the camera and re initializes the video circular buffer.

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Aug 21, 2015 5:04 pm

it's been running overnight from a screen session and I haven't seen any problems, recording was still going when I checked now. I've stopped the shell process and restarted it from the web interface to see if it makes a difference, but as it stands neither of the two cameras had an issue yesterday/this morning. Don't know what happened two days ago.

I have however a few puzzling videos from last night that I can't explain. I have two cameras at a gate, one with a wide angle picking up the entire street and one focused on the gate at license plate level. In 99.9% of the cases I have a video on both cameras for each car coming by, however at around midnight I have one camera only showing the rear of a car going through the gate (how was motion not detected for the front??) and no video at all on the wide angle. Similarly, during the day, I have two videos where the close up camera stopped recording when the car wasn't through yet, which makes no sense. With the pre_capture the video starts correctly before the card enters the frame and normally it finishes after the car disappeared, but in this one the car is still 3/4 in it. And the car wasn't stopping, so it's not like the event_gap kicked it.

couple requests to help with debugging:
- can we make the logged event timestamped?
- is there any way to "tag" motion information as per output of -vm with the video they refer to? that way I could go back and review the videos from last night and clearly see what the motion detection system saw

thanks,

Spike

YvesG
Posts: 46
Joined: Wed Oct 03, 2012 6:54 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Aug 21, 2015 7:07 pm

jbeale wrote:
YvesG wrote:@jbeale hi,
there is a mismatch between the time displayed in the live video and the thumb
For a thumb at 16:18 but in fact it should be 18:18 (live stream is 18:18 and pi is 18:18 too)
Do you have this issue as well?
Interesting, i have never seen that on my systems. The thumb time comes from the filesystem time when the image was saved. Still, thumb and video times all agree for me.
It was a timezone issue:
edit : /etc/php5/fpm/php.ini
adjust your timezone : date.timezone = Europe/Paris
restart php5-fpm : /etc/init.d/php5-fpm restart

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Aug 21, 2015 10:44 pm

spikedrba wrote: couple requests to help with debugging:
- can we make the logged event timestamped?
- is there any way to "tag" motion information as per output of -vm with the video they refer to? that way I could go back and review the videos from last night and clearly see what the motion detection system saw
OK, I added log timestamps and the verbose motion debug output has the video filename inserted
when there's a valid motion detect.

In case the issue you had with no video being saved is because the boxing failed for some
reason, the h264 file now is not deleted if MP4Box returns an error code. So if it happens to
you again, there should at least be a h264 file you can test play with omxplayer to see if it
is corrupted or not.

And also, the log file can now be viewed/deleted from the web page under the System panel.

EDIT: Just updated the log page to put the log lines in a scrolled view and scroll to bottom on page load.

EDIT2: By the way, after git pull origin, pikrellcam needs to be restarted. There's some pikrellcam
changes that were needed to get the web log file delete function to work. Did anybody know that
www-data does not have permission to delete a file created in /tmp by user pi even if the file has
all write permission bits set? I didn't.
So it means pikrellcam must be running for the web page delete log function to work.

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Aug 24, 2015 8:29 pm

Hi,
first: i like this program, thank you folr your work. About building some full featuered Surveillance Cams with
Day&Night, IR Beamer, Pan/Tilt with pikrellcam.

Think I've found a bunch of errors:

Background: I've attached a IR Cut Filter Switcher to a Pi Night Cam with CS mount and made a little Electronics
to control the Switch with GPIO. So far it works.

I've made 2 scripts in the scripts dir, which send a cmd to the GPIO FIFO, in this case 'day' or 'night' and the python script behind
the fifo does the action.

Part of script night:

Code: Select all

echo "\$0=$0 \$1=$1 \$2=$2" >> /tmp/pikrellcam.log

LOG_FILE=/tmp/pikrellcam.log

#$1

if [ "$LOG_FILE" == "" ]
then
        LOG_FILE = /dev/null
fi


if [ -e /tmp/hw-pt-control-wiring.fifo.in ]
then
        echo "night" > /tmp/hw-pt-control-wiring.fifo.in
        echo "IR Cut Filter switch to night." >> $LOG_FILE
fi


at-commands.conf, added some lines:
daily sunset+5 "$C/night $G $P"
daily sunset+5 "@saturation -99"
daily sunrise-5 "$C/day $G $P"
daily sunrise-5 "@saturation 0"

The errors I've found:


1. saturation -99 should make b&w at night
doesnt work. Maybe reason is 3. below.
echo "saturation -99" >/home/pi/pikrellcam/www/FIFO works!

2. daily sunset+5 "$C/night $G $P"
Parameters dont get applied
Log shows 21:58:56 : execl:[/home/pi/pikrellcam/scripts/night]
$0=/home/pi/pikrellcam/scripts/night $1= $2=

3. when starting pikrellcam, the actual 'sunset' or 'sunrise' defined parameters/scripts seem not to get applied.
The program doesnt cath up all the at time of start valid settings:
Log shows:

Code: Select all

========================================================
2015-08-24 22:04:16 ======== PiKrellCam started ========
========================================================
at_command_add [daily] at: sunset  command: [@exposure_mode night]
at_command_add [daily] at: sunset+10  command: [@video_fps 4]
at_command_add [daily] at: sunset+10  command: [@video_mp4box_fps 4]
at_command_add [daily] at: sunset+10  command: [@mjpeg_divider 1]
at_command_add [daily] at: sunset+5  command: [@saturation -99]
at_command_add [daily] at: sunset+5  command: [$C/night $G $P]
at_command_add [daily] at: sunrise-10  command: [@video_fps 24]
at_command_add [daily] at: sunrise-10  command: [@video_mp4box_fps 24]
at_command_add [daily] at: sunrise-10  command: [@mjpeg_divider 4]
at_command_add [daily] at: sunrise  command: [@exposure_mode auto]
at_command_add [daily] at: sunrise-5  command: [@saturation 0]
at_command_add [daily] at: sunrise-5  command: [$C/day $G $P]
using FIFO: /home/pi/pikrellcam/www/FIFO
using mjpeg: /run/pikrellcam/mjpeg.jpg
22:04:16 : execl:[/home/pi/pikrellcam/scripts-dist/_init /home/pi/pikrellcam /home/pi/pikrellcam/media /run/pikrellcam/mjpeg.jpg /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log]
  www/media link is already set to /home/pi/pikrellcam/media
  /home/pi/pikrellcam/www/config.php: LOG_FILE not changed.
  /home/pi/pikrellcam/www/config.php: MJPEG_FILE not changed.
  /home/pi/pikrellcam/www/config.php: FIFO_FILE not changed.
  /home/pi/pikrellcam/www/config.php: PIKRELLCAM not changed.
22:04:16 : execl:[/home/pi/pikrellcam/scripts/startup /home/pi/pikrellcam /home/pi/pikrellcam/media /tmp/pikrellcam.log]
  MOUNT_DISK is not set.
22:04:16 : circular buffer allocate: 15,00 MBytes (20 seconds at 6,0 Mbits/sec)
sunrise/sunset times: valid  dawn/dusk times: valid
  dawn:    5:45
  sunrise: 6:20
  sunset:  20:16
  dusk:    20:50
Br.
Thomas

spikedrba
Posts: 75
Joined: Fri Feb 28, 2014 2:19 am

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Aug 24, 2015 8:33 pm

tomtgrp wrote:Hi,
Background: I've attached a IR Cut Filter Switcher to a Pi Night Cam with CS mount and made a little Electronics
to control the Switch with GPIO. So far it works.
Thomas,

I'm trying to do the same thing, I would be very grateful if you could share where you sourced your parts and a diagram/explanation of your circuit. Are you using an hbridge? Where did you source your IR cut filter? the one I found on ebay is for M12 lenses and seem to want more than 5v to work well.

thank you in advance,

Spike

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Aug 24, 2015 9:16 pm

spikedrba wrote:
tomtgrp wrote:Hi,
Background: I've attached a IR Cut Filter Switcher to a Pi Night Cam with CS mount and made a little Electronics
to control the Switch with GPIO. So far it works.
Thomas,

I'm trying to do the same thing, I would be very grateful if you could share where you sourced your parts and a diagram/explanation of your circuit. Are you using an hbridge? Where did you source your IR cut filter? the one I found on ebay is for M12 lenses and seem to want more than 5v to work well.

thank you in advance,

Spike
So lets start:

I used successful the CS-mount Variant, the M12 Variant needs Lenses with a Backfocus (the distance between end of Lens and Top of Chip of about 6mm)

The Switchers are from ebay, e.g.:
M12:
http://www.ebay.de/itm/IR-CUT-M12-Mount ... 1543275604
CS-Mount:
http://www.ebay.de/itm/CS-Mount-Lens-HP ... 1961628671

There are a lot of similar types, still trying to find low profile types.

They run with about 4.5 V

The circuit diagram of the switch control, also contains wiring for 2 Servos for Pan/Tilt and a real time clock (optional) attached below.

The control program (quick&dirty), attached in the zip file.
It creates a fifo in /tmp, pikrellcam can write cmds (echo "day" > tmp/fifoname") to this fifo.


added to /etc/rc.local before the pikrellcam stuff:
/usr/bin/python /root/hw-pt-control-wiring.py &

Hope this helps for now & perhaps gets improved by the community.

May be a Supplyer one day builds a Pi Camera Module with integrated IR Cut Filter Switch.

Next step is some integration of Pan-Tilt and Ir Cut controls in the Pikrellcam Web Interface.

Br
Thomas
Attachments
hw-pt-control-wiring.zip
control program for shutter & pan tilt
(1.41 KiB) Downloaded 220 times
Adapterplatine.jpg
Circuit diagram IC Cut Filter Switch Controller
Adapterplatine.jpg (63.61 KiB) Viewed 4966 times

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 1:59 am

tomtgrp wrote: Part of script night:

Code: Select all

echo "\$0=$0 \$1=$1 \$2=$2" >> /tmp/pikrellcam.log
at-commands.conf, added some lines:
daily sunset+5 "$C/night $G $P"
daily sunset+5 "@saturation -99"
daily sunrise-5 "$C/day $G $P"
daily sunrise-5 "@saturation 0"

The errors I've found:


1. saturation -99 should make b&w at night
doesnt work. Maybe reason is 3. below.
echo "saturation -99" >/home/pi/pikrellcam/www/FIFO works!

2. daily sunset+5 "$C/night $G $P"
Parameters dont get applied
Log shows 21:58:56 : execl:[/home/pi/pikrellcam/scripts/night]
$0=/home/pi/pikrellcam/scripts/night $1= $2=

3. when starting pikrellcam, the actual 'sunset' or 'sunrise' defined parameters/scripts seem not to get applied.
The program doesnt cath up all the at time of start valid settings:
Log shows:

Code: Select all

========================================================
2015-08-24 22:04:16 ======== PiKrellCam started ========
========================================================
at_command_add [daily] at: sunset  command: [@exposure_mode night]
at_command_add [daily] at: sunset+10  command: [@video_fps 4]
at_command_add [daily] at: sunset+10  command: [@video_mp4box_fps 4]
at_command_add [daily] at: sunset+10  command: [@mjpeg_divider 1]
at_command_add [daily] at: sunset+5  command: [@saturation -99]
at_command_add [daily] at: sunset+5  command: [$C/night $G $P]
at_command_add [daily] at: sunrise-10  command: [@video_fps 24]
at_command_add [daily] at: sunrise-10  command: [@video_mp4box_fps 24]
at_command_add [daily] at: sunrise-10  command: [@mjpeg_divider 4]
at_command_add [daily] at: sunrise  command: [@exposure_mode auto]
at_command_add [daily] at: sunrise-5  command: [@saturation 0]
at_command_add [daily] at: sunrise-5  command: [$C/day $G $P]
using FIFO: /home/pi/pikrellcam/www/FIFO
using mjpeg: /run/pikrellcam/mjpeg.jpg
22:04:16 : execl:[/home/pi/pikrellcam/scripts-dist/_init /home/pi/pikrellcam /home/pi/pikrellcam/media /run/pikrellcam/mjpeg.jpg /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log]
  www/media link is already set to /home/pi/pikrellcam/media
  /home/pi/pikrellcam/www/config.php: LOG_FILE not changed.
  /home/pi/pikrellcam/www/config.php: MJPEG_FILE not changed.
  /home/pi/pikrellcam/www/config.php: FIFO_FILE not changed.
  /home/pi/pikrellcam/www/config.php: PIKRELLCAM not changed.
22:04:16 : execl:[/home/pi/pikrellcam/scripts/startup /home/pi/pikrellcam /home/pi/pikrellcam/media /tmp/pikrellcam.log]
  MOUNT_DISK is not set.
22:04:16 : circular buffer allocate: 15,00 MBytes (20 seconds at 6,0 Mbits/sec)
sunrise/sunset times: valid  dawn/dusk times: valid
  dawn:    5:45
  sunrise: 6:20
  sunset:  20:16
  dusk:    20:50
This seemed to work for me. I made a night script with

Code: Select all

echo "\$0=$0 \$1=$1 \$2=$2" >> /tmp/pikrellcam.log
and put in the at-commands.conf:

Code: Select all

daily sunset+5 "$C/night $G $P"
daily sunset+5 "@saturation -99"
The saturation worked and in the log file, I got:

Code: Select all

20:07:00 : execl:[/home/pi/pikrellcam/scripts/night /tmp/pikrellcam.log /home/pi/pikrellcam/www/FIFO]
$0=/home/pi/pikrellcam/scripts/night $1=/tmp/pikrellcam.log $2=/home/pi/pikrellcam/www/FIFO
I've been making some changes that I hope to put up in a day or so and to that I'll add a bunch
of debug output to the at-commands runs. So after the next update you can get some debugging
that will hopefully figure this out.

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 1:17 pm

Hello,

did a complete reinstall, changed some things and figured out:

1.
changed the ir-cut-filter script, see zip.
put a job in at-commands:

Code: Select all

#test
#daily minute "$C/ir-cut-switch night $G"
daily minute "$C/ir-cut-switch day $G"
Result:ok, every minute a switching occurs

Code: Select all

14:45:00 : execl:[/home/pi/pikrellcam/scripts/ir-cut-switch day /home/pi/pikrellcam/log/pikrellcam.log]
14:45:00 :  $0=/home/pi/pikrellcam/scripts/ir-cut-switch $1=day $2=/home/pi/pikrellcam/log/pikrellcam.log $3=
14:45:00 :  IR Cut Filter switch to day.

2. Logfile isn't shown in Browser
created a subdir 'log' in /home/pi/pikrellcam to get the logs survive a reboot
changed ./pikrellcam/pikrellcam.conf

Code: Select all

log_file log/pikrellcam.log
Rebooted
search for log_file:

Code: Select all

[email protected] ~ $ grep -i log_file pikrellcam/www/*.php
pikrellcam/www/config.php:      define("LOG_FILE", "LOG_FILE");
pikrellcam/www/log.php:$log_file = LOG_FILE;
pikrellcam/www/log.php: $file = fopen(LOG_FILE, "r");
pikrellcam/www/log.php://                       unlink("$log_file");
There is a missing $ in scripts-dist/_init Line 52

Code: Select all

CMD="/LOG_FILE/c\       define\(\"LOG_FILE\", \"$LOG_FILE\"\);"
Changed the script, log shown now

3.
One Problem still stays, I think this isn't trivial:
After a reboot the commands in at-commands must be applied
Example:

Code: Select all

# Adjust camera parameters in the evening: sunset{+-offset}
daily sunset "@exposure_mode night"
daily sunset+10 "@video_fps 4"
daily sunset+10 "@video_mp4box_fps 4"
daily sunset+10 "@mjpeg_divider 1"
daily sunset+5 "@saturation -99"
daily sunset+5 "$C/ir-cut-switch night $G"

# Adjust camera parameters in the morning sunrise{+-offset}
daily sunrise-10 "@video_fps 24"
daily sunrise-10 "@video_mp4box_fps 24"
daily sunrise-10 "@mjpeg_divider 4"
daily sunrise "@exposure_mode auto"
daily sunrise-5 "@saturation 0"
daily sunrise-5 "$C/ir-cut-switch day $G"
Reboot (e.g. Power loss) occurs at 10:00
Pikrellcam must now apply on startup: video_fps 24,video_mp4box_fps 24,mjpeg_divider 4,exposure_mode auto, ir-cut-switch day

Reboot (e.g. Power loss) occurs at 22:00
Pikrellcam must now apply on startup: video_fps 4,video_mp4box_fps 4,mjpeg_divider 1,exposure_mode night, ir-cut-switch night

Br
Thomas
Attachments
files.zip
Files ir-cut
(2.92 KiB) Downloaded 230 times

punacmc
Posts: 31
Joined: Tue Nov 19, 2013 4:07 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 6:17 pm

Is there any plan to have an option for full video resolution? I know it's only 15fps, however I think that the increased resolution would be nice in some situations.

billw
Posts: 405
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 7:22 pm

punacmc wrote:Is there any plan to have an option for full video resolution? I know it's only 15fps, however I think that the increased resolution would be nice in some situations.
I'll add it to the TODO. It would be trivial except that right now I'm not constraining the fps to what's
allowed for a given resolution and I think I should do that.

Return to “Camera board”