User avatar
lpsw
Posts: 167
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Oct 27, 2019 6:06 am

underwhelmd wrote:
Sun Oct 20, 2019 2:19 pm
lpsw wrote:
Tue Aug 13, 2019 6:38 pm


In ~/pikrellcam/src/config.c, append the following line to the end of awb_mode_table (found around line 117):

Code: Select all

{ MMAL_PARAM_AWBMODE_GREYWORLD,     "greyworld" }

I have an error on make when I did this...

Code: Select all

config.c:129:2: error: expected ‘}’ before ‘{’ token
  { MMAL_PARAM_AWBMODE_GREYWORLD,     "greyworld" }
  ^
this is what it looks like in config.c -

Code: Select all

ParameterTable awb_mode_table[] =
        {
        { MMAL_PARAM_AWBMODE_OFF,           "off" },
        { MMAL_PARAM_AWBMODE_AUTO,          "auto" },
        { MMAL_PARAM_AWBMODE_SUNLIGHT,      "sunlight" },
        { MMAL_PARAM_AWBMODE_CLOUDY,        "cloudy" },
        { MMAL_PARAM_AWBMODE_SHADE,         "shade" },
        { MMAL_PARAM_AWBMODE_TUNGSTEN,      "tungsten" },
        { MMAL_PARAM_AWBMODE_FLUORESCENT,   "flourescent" },
        { MMAL_PARAM_AWBMODE_INCANDESCENT,  "incandescent" },
        { MMAL_PARAM_AWBMODE_FLASH,         "flash" },
        { MMAL_PARAM_AWBMODE_HORIZON,       "horizon" }
        { MMAL_PARAM_AWBMODE_GREYWORLD,     "greyworld" }
        };
What did I do wrong?
There's a missing comma at the end of the "horizon" line. Probably a typo; it's correct on my end.

Edit: I should have mentioned that a recent update has made this unnecessary, at least in my limited testing.
Last edited by lpsw on Sun Nov 24, 2019 2:11 am, edited 1 time in total.
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

wjburl
Posts: 35
Joined: Fri May 22, 2015 12:08 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Oct 27, 2019 9:43 pm

billw, I now have it resolved. BTW, thanks for responding. The problem occurred when I tried to make the drive a convenient name rather than use the very long UUID. I had reformated the drive from NTFS to ext4 and named the partition the same as the drive name. When I did that, it changed one of the two names by appending a 1 to the name. It's all a result of not being a very proficient Linux user. I don't think the files were even saved to the USB drive. I can now play the videos in a PC browser at a normal speed. I have an RPi 4B, but decided to use an RPi 3B+ because this unit will be outside and the summers here are very hot.

FloatingPi
Posts: 1
Joined: Wed Jul 26, 2017 10:01 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Nov 16, 2019 10:16 am

I have a number of pi's running Strech or Buster and the excellent Pikrellcam v4.3.1.
All are setup to copy the preview jpeg to a folder so I can review the moton capture events at a later time.
After a period of running the number of copied preview files is far fewer than the number of thumbs and mp4 files. Sometimes as few as 50%.
I've tried bypassing the preview-save script and putting the copy command directly in the on_motion_preview_save entry in pikrellcam.conf with no improvement.
Here is an example from the log file which is consistent with the files I end up with.

Code: Select all

17:55:24 : Motion record start - /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_17.55.18_29.h264
17:55:24 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/pi0w1_2019-11-15_17.55.18_29.jpg
17:55:24 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/pi0w1_2019-11-15_17.55.18_29.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_17.55.18_29.th.jpg 150x150 800 800 401 401; /home/pi/pikrellcam/scripts/preview-save  /run/pikrellcam/pi0w1_2019-11-15_17.55.18_29.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_17.55.18_29.th.jpg; rm -f /run/pikrellcam/pi0w1_2019-11-15_17.55.18_29.jpg
  convert /run/pikrellcam/pi0w1_2019-11-15_17.55.18_29.jpg -crop 800x800+1+1 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_17.55.18_29.th.jpg
cp /run/pikrellcam/pi0w1_2019-11-15_17.55.18_29.jpg /home/pi/pkmstills
17:55:56 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 4.000 -add /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_17.55.18_29.h264  /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_17.55.18_29.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_17.55.18_29.h264 ; rm -f /run/pikrellcam/video_converting; 
17:55:56 : Motion record stop (size:3.1MB < /tmp:2153.8MB)  vid_time:28.25  vid_fps:3.96  audio_frames:0  audio_rate:0
17:55:56 :     first detect: (direction )  totals - direction:24  burst:0  max burst count:0  audio:0  external:0
18:36:01 : Motion record start - /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.35.56_30.h264
18:36:02 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/pi0w1_2019-11-15_18.35.56_30.jpg
18:36:02 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/pi0w1_2019-11-15_18.35.56_30.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_18.35.56_30.th.jpg 150x150 800 800 401 401; rm -f /run/pikrellcam/pi0w1_2019-11-15_18.35.56_30.jpg
  convert /run/pikrellcam/pi0w1_2019-11-15_18.35.56_30.jpg -crop 800x800+1+1 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_18.35.56_30.th.jpg
18:36:21 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 4.000 -add /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.35.56_30.h264  /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.35.56_30.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.35.56_30.h264 ; rm -f /run/pikrellcam/video_converting; 
18:36:21 : Motion record stop (size:1.3MB < /tmp:2152.9MB)  vid_time:16.00  vid_fps:3.94  audio_frames:0  audio_rate:0
18:36:21 :     first detect: (burst )  totals - direction:2  burst:3  max burst count:2904  audio:0  external:0
18:36:37 : Motion record start - /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.36.32_31.h264
18:36:38 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/pi0w1_2019-11-15_18.36.32_31.jpg
18:36:38 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/pi0w1_2019-11-15_18.36.32_31.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_18.36.32_31.th.jpg 150x150 800 800 401 401; /home/pi/pikrellcam/scripts/preview-save  /run/pikrellcam/pi0w1_2019-11-15_18.36.32_31.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_18.36.32_31.th.jpg; rm -f /run/pikrellcam/pi0w1_2019-11-15_18.36.32_31.jpg
  convert /run/pikrellcam/pi0w1_2019-11-15_18.36.32_31.jpg -crop 800x800+1+1 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/pi0w1_2019-11-15_18.36.32_31.th.jpg
cp /run/pikrellcam/pi0w1_2019-11-15_18.36.32_31.jpg /home/pi/pkmstills
18:36:53 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 4.000 -add /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.36.32_31.h264  /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.36.32_31.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/pi0w1_2019-11-15_18.36.32_31.h264 ; rm -f /run/pikrellcam/video_converting; 
18:36:53 : Motion record stop (size:0.9MB < /tmp:2152.1MB)  vid_time:12.01  vid_fps:3.91  audio_frames:0  audio_rate:0
18:36:53 :     first detect: (burst )  totals - direction:0  burst:2  max burst count:480  audio:0  external:0
I'm at a loss to know what to try next so any advice on where I'm going wrong would be much appreciated.

Nestboxtech
Posts: 73
Joined: Fri Apr 11, 2014 9:45 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Nov 23, 2019 12:39 am

Hi Bill,
Just updated one of my birdbox IR cameras on Pi ZeroW / Buster Lite, and get the same purple colour in IR illumination as described below.
I tried sudo apt update && sudo apt dist-upgrade –y which didnt fix it.
I also followed the instruction below, then ran make in /home/pi/pikrellcam/src (no errors) this doesn't fix it either as far as I can see

Any help would be appreciated

Thanks,
Chris
kajan001 wrote:
Mon Oct 21, 2019 9:41 am
underwhelmd wrote:
Sun Oct 20, 2019 2:19 pm
lpsw wrote:
Tue Aug 13, 2019 6:38 pm


In ~/pikrellcam/src/config.c, append the following line to the end of awb_mode_table (found around line 117):

Code: Select all

{ MMAL_PARAM_AWBMODE_GREYWORLD,     "greyworld" }
Is this to fix the purple screen issue?
I recently had the problem but just ran an upgrade and that seems to have fixed it. I have not had any issues for 5 days since.

sudo apt update && sudo apt dist-upgrade -y

https://www.raspberrypi.org/forums/view ... 3&t=245994

https://raspberrypi.stackexchange.com/q ... 030_104580
http://nestboxtech.blogspot.co.uk/

User avatar
lpsw
Posts: 167
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Nov 23, 2019 6:29 am

Nestboxtech wrote:
Sat Nov 23, 2019 12:39 am

Is this to fix the purple screen issue?
To be precise, my change was to add support for the new awb algorithm (greyworld).
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

Nestboxtech
Posts: 73
Joined: Fri Apr 11, 2014 9:45 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Nov 23, 2019 9:50 am

Ah, I see, your code tweak was to add that awb algorithm to the available list in the 'Camera params' ... 'White balance' menu ?
I added your modification to the ~/pikrellcam/src/config.c file, then ran make on it. it does not seem to make a difference to the version of pikrellcam that is running however? I suspect I'm missing a step where the modified application file is rolled out to the installed instance (or something). I spotted the missing comma typo and the make command does not throw any errors relating to this modification.

In my setup, I use the noir camera with an IR cut and switch between while LED and IR leds in the day vs night. Due to this change in the firmware, I'm guessing I will now need to switch to the 'greyworld' awb at the same time when the system goes from day (white led) to night mode (IR led) - this assumes that I can make it available in pikrellcam

?Bill - can this please be added as an update to avoid the need to modify your code base?
Once it's available to use in pikrellcam, is there a ?FIFO command that I can use to switch between auto (daymode) to greyworld (nightmode)?

Thanks

lpsw wrote:
Sat Nov 23, 2019 6:29 am
Nestboxtech wrote:
Sat Nov 23, 2019 12:39 am

Is this to fix the purple screen issue?
To be precise, my change was to add support for the new awb algorithm (greyworld).
http://nestboxtech.blogspot.co.uk/

User avatar
lpsw
Posts: 167
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Nov 24, 2019 1:38 am

Ah, I see, your code tweak was to add that awb algorithm to the available list in the 'Camera params' ... 'White balance' menu ?
Correct
I added your modification to the ~/pikrellcam/src/config.c file, then ran make on it. it does not seem to make a difference to the version of pikrellcam that is running however? I suspect I'm missing a step where the modified application file is rolled out to the installed instance (or something).
Did you update the ~/.pikrellcam/pikrellcam.conf 'awb' setting to greyworld, and restart pikrellcam?
That should work. I have images I'll upload.

My settings in pikrellcam.conf:

Code: Select all

#               Raspberry Pi Initial Camera Parameters
#
sharpness 0
contrast 0
brightness 50
saturation 0
iso 0
shutter_speed 0
exposure_compensation 0
video_stabilisation false
raw_capture false
rotation 180
exposure_mode auto
image_effect none
hflip off
vflip off
crop 0 0 65536 65536
metering_mode average
white_balance greyworld
color_effect false 128 128
BTW, I have not performed a dist-upgrade. I'm running Pikrellcam 4.3.1, and did the apt update/apt upgrade thing earlier today:

Code: Select all

[email protected]:~/pikrellcam/media/stills $ uname -a
Linux pi-10 4.19.75+ #1270 Tue Sep 24 18:38:54 BST 2019 armv6l GNU/Linux
This tweak does not provide the 'greyworld' option to the GUI 'white bal' options under 'Setup'.
I'm not a PHP expert, but I'm sure billw is :)
(See edit, below)

Hope this helps.

Edit: Added pics...
These stills were taken from the pikrellcam GUI at night with only a single 15W LED lamp on
Here's one with awb = greyworld:
https://imgur.com/OmKO7h5
And one with awb = auto:
https://imgur.com/RkebZra

Edit: Adding greyworld awb option to the GUI:
At our or around line 1032 in ~/pikrellcam/src/display.c, the white_balance_entry array is defined for the GUI.
Just add 'greyworld' to the end of the array, make, and restart pikrellcam.
Yay, no PHP knowledge required.
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

kajan001
Posts: 22
Joined: Wed Feb 13, 2019 7:15 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Dec 03, 2019 9:00 am

Is there any way to "artificially" trigger a motion event after a motion video has reached its time limit?

I set the video time limit to 5-6 minutes because the Pi0 i am using cannot handle the conversion of too big files. However, there are times that I would like pikrellcam to start a motion event recording right after time-limit has been reached.

I am wondering if I can use an @ command for this?
If I type: echo "motion trigger 1" > ~/pikrellcam/www/FIFO
I will start a motion event but what could I use to trigger the command i.e. when video time limit is reached then ......


I have tried other solution:
- increase motion sensitivity - gets me too many false alarms
- longer pre/post capture - becomes too heavy for the Pi0 to handle
- longer video time limit - see above.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Dec 04, 2019 9:01 pm

kajan001 wrote:
Tue Dec 03, 2019 9:00 am
Is there any way to "artificially" trigger a motion event after a motion video has reached its time limit?

I set the video time limit to 5-6 minutes because the Pi0 i am using cannot handle the conversion of too big files. However, there are times that I would like pikrellcam to start a motion event recording right after time-limit has been reached.

I am wondering if I can use an @ command for this?
If I type: echo "motion trigger 1" > ~/pikrellcam/www/FIFO
I will start a motion event but what could I use to trigger the command i.e. when video time limit is reached then ......
You can create an on_motion_begin command or an on_motion_end command to restart a motion video. The script would
do the echo "motion trigger 1" > ~/pikrellcam/www/FIFO

Look for on_motion_begin and on_motion_end in ~/.pikrellcam/pikrellcam.conf and search for them in the Help page.

If using an on_motion_end script, you can just restart a motion video record immediately.

If using an on_motion_begin script, you would read the contents of the /run/pikrellcam/motion-events file and wait
for a "<end>" tag before starting a new motion video. See the scripts-dist/example-motion-events file for how to do
that. The advantage here is you could process motion events and decide if you want to restart a video based on a
history of motion detects. But this could get complicated, so maybe a simple decision in a on_motion_end script would
be much easier.

kajan001
Posts: 22
Joined: Wed Feb 13, 2019 7:15 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Dec 10, 2019 10:07 am

Thanks Bill!

I have not quite got it to work but I will continue experimenting until I get it right.

If I understand this correctly another motion_event will be initialised when the "current" motion_event ends, but I am a little unsure when a motion event actually ends. Is it when no more motion is triggered or is it "no more motion + post capture" ?

Also I cannot find the /run/pikrellcam/motion-events file you are speaking of:

Code: Select all

[email protected]:/run/pikrellcam $ ls -a
.  ..  mjpeg.jpg  mjpeg.jpg.part  state
Ideally i would like a script to initiate a motion event when video time limit is reached but there seems to be no straight forward way to do this

Return to “Camera board”