User avatar
lpsw
Posts: 228
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: 38
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: 2
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: 228
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: 228
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

pi@pi-10:~/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: 32
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: 415
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: 32
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

pi@raspberrypi:/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

dburg
Posts: 6
Joined: Tue Jul 03, 2018 2:06 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Dec 20, 2019 2:57 am

FloatingPi wrote:
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.
In your log, examine the "execl" lines with "_thumb". Sometimes preview-save is called, and sometimes it isn't. I ran into this a while back and did a little digging. What I found is that the "thumb_convert(void)" function in pikrellcam.c is responsible for calling the on_motion_preview_save_cmd. Around line 686, the following condition must be met to call the on_motion_preview_save_cmd:

Code: Select all

	
	if (   *pikrellcam.on_motion_preview_save_cmd
	    && (   (vcb->state & VCB_STATE_MOTION_RECORD)
	        || (   pikrellcam.motion_stills_record
			    && !pikrellcam.thumb_convert_done
	           )
	       )
	   )
I found that, when this "if" statement is executed, the value of vcb->state is sometimes VCB_STATE_MOTION_RECORD, and sometimes VCB_STATE_MOTION_RECORD_START. On the occasions that it is VCB_STATE_MOTION_RECORD_START, the on_motion_preview_save_cmd won't be called.

You might try changing this "if" statement (at src/pikrellcam.c line 687) to use VCB_STATE_MOTION instead of VCB_STATE_MOTION_RECORD. It should catch both cases.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Mar 01, 2020 9:31 am

@dburg
Thanks for your reply. I was starting to wonder if I was making this up.
Your description of preview_save failing to run in a rather unpredictable way chimes exactly with what I'm seeing.

I have some programming skills but unfortunately no C experience at all and fear that after a simple text file change there will be compilation and I know not what other 'stuff' to learn.
I'm tempted to try and follow this through as I have a testbed in a pi0w that consistently behaves this way but fear this may prove a step to far down the rabbit hole for a C virgin.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Mar 02, 2020 7:40 am

Post deleted: is no longer relevant
Last edited by kajan001 on Tue Apr 28, 2020 2:47 pm, edited 1 time in total.

User avatar
rleyden
Posts: 75
Joined: Thu Jun 14, 2012 2:17 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Apr 18, 2020 3:28 pm

Has anyone tried to port pikrellcam to the Jetson Nano? You may well ask, "Doesn't the Nano have equivalent programs?" Well, not quite and I really like pikrellcam. There are several nice software example programs on the Nano that get partway there, like "doorcam", (https://medium.com/@ageitgey/build-a-ha ... cb8c891fd
and web_streamer,
https://maker.pro/nvidia-jetson/tutoria ... with-flask
.
" Motion" is not directly available and would require a V4L driver to use the RPi V2 camera.
The Nano uses GStreamer as below

Code: Select all

GSTREAMER_PIPELINE = 'nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3280, height=2464, format=(string)NV12, framerate=21/1 ! nvvidconv flip-method=0 ! video/x-raw, width=960, height=616, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink wait-on-eos=false max-buffers=1 drop=True'
to access the RPi camera. I suspect this would also be a problem for pikrellcam.
A quick look at the source code for pikrellcam with references to bcm_host.h, etc, suggests the program is more tightly tied to the Raspberry Pi than I previously appreciated. Porting is beyond anything I should consider personally.

Eventually, I hope to combine motion detection and object recognition for my particular use, detecting herons attacking my koi pond with very few false alarms.

lyalc
Posts: 2
Joined: Sun Apr 26, 2020 10:34 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Apr 26, 2020 10:55 am

This is a good tool and learning more all the time, using it.
However the email function is not working consistently.

I could not get the 'ssmtp' email package working, however the msmtp and mpack package are working - both from the command line, and occasionally when motion events are detected.
Enabling the msmtp log shows no errors, when that 'mpack' command in the preview-save script is executed.
Pikrellcam Log extract below being when the preview-save script executes/logs, also showing motion detect events that did not result in an email.
the mpack and Param lines are logging statements in the preview-save script, as part of my troubleshoot so far

Pi Zero W
uname output: Linux raspberrypi 4.19.97+ #1294 Thu Jan 30 13:10:54 GMT 2020 armv6l GNU/Linux
pi
@raspberrypi:~ $ pikrellcam --version
4.3.
1
Any suggestions, or dumb things I've missed please?
Thanks

Code: Select all

16:25:45 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2020-04-26_16.25.41_45.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.25.41_45.th.jpg 150x150 81 80 600 116; /home/pi/pikrellcam/scripts/preview-save  /run/pikrellcam/motion_2020-04-26_16.25.41_45.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.25.41_45.th.jpg; rm -f /run/pikrellcam/motion_2020-04-26_16.25.41_45.jpg
  convert /run/pikrellcam/motion_2020-04-26_16.25.41_45.jpg -crop 81x81+560+76 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.25.41_45.th.jpg
mpack -s pikrellcam@raspberrypi /run/pikrellcam/motion_2020-04-26_16.25.41_45.jpg pi@gmail.com &
Params /run/pikrellcam/motion_2020-04-26_16.25.41_45.jpg /home/pi/pikrellcam/media  /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.25.41_45.th.jpg
16:25:55 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 24.002 -add /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.25.41_45.h264  /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.25.41_45.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.25.41_45.h264 ; rm -f /run/pikrellcam/video_converting; 
16:25:55 : Motion record stop (size:7.4MB < /tmp:2582.0MB)  vid_time:9.96  vid_fps:24.00  audio_frames:0  audio_rate:0
16:25:55 :     first detect: (direction )  totals - direction:1  burst:0  max burst count:0  audio:0  external:0
16:31:04 : Motion record start - /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.00_46.h264
16:31:04 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/motion_2020-04-26_16.31.00_46.jpg
16:31:04 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2020-04-26_16.31.00_46.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.31.00_46.th.jpg 150x150 80 80 600 107; rm -f /run/pikrellcam/motion_2020-04-26_16.31.00_46.jpg
  convert /run/pikrellcam/motion_2020-04-26_16.31.00_46.jpg -crop 80x80+560+67 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.31.00_46.th.jpg
16:31:14 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 24.002 -add /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.00_46.h264  /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.00_46.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.00_46.h264 ; rm -f /run/pikrellcam/video_converting; 
16:31:14 : Motion record stop (size:7.0MB < /tmp:2576.8MB)  vid_time:9.96  vid_fps:24.00  audio_frames:0  audio_rate:0
16:31:14 :     first detect: (direction )  totals - direction:1  burst:0  max burst count:0  audio:0  external:0
16:31:47 : Motion record start - /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.43_47.h264
16:31:47 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/motion_2020-04-26_16.31.43_47.jpg
16:31:47 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2020-04-26_16.31.43_47.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.31.43_47.th.jpg 150x150 80 80 606 108; rm -f /run/pikrellcam/motion_2020-04-26_16.31.43_47.jpg
  convert /run/pikrellcam/motion_2020-04-26_16.31.43_47.jpg -crop 80x80+566+68 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.31.43_47.th.jpg
16:31:57 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 24.002 -add /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.43_47.h264  /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.43_47.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.31.43_47.h264 ; rm -f /run/pikrellcam/video_converting; 
16:31:57 : Motion record stop (size:7.5MB < /tmp:2571.2MB)  vid_time:10.00  vid_fps:24.00  audio_frames:0  audio_rate:0
16:31:57 :     first detect: (direction )  totals - direction:1  burst:0  max burst count:0  audio:0  external:0
16:33:42 : Motion record start - /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.33.38_48.h264
16:33:42 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg
16:33:42 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.33.38_48.th.jpg 150x150 91 86 606 109; /home/pi/pikrellcam/scripts/preview-save  /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.33.38_48.th.jpg; rm -f /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg
  convert /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg -crop 91x91+561+64 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.33.38_48.th.jpg
mpack -s pikrellcam@raspberrypi /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg pi@gmail.com &
Params /run/pikrellcam/motion_2020-04-26_16.33.38_48.jpg /home/pi/pikrellcam/media  /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.33.38_48.th.jpg
16:33:55 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 24.002 -add /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.33.38_48.h264  /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.33.38_48.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.33.38_48.h264 ; rm -f /run/pikrellcam/video_converting; 
16:33:55 : Motion record stop (size:9.3MB < /tmp:2564.2MB)  vid_time:13.00  vid_fps:24.00  audio_frames:0  audio_rate:0
16:33:55 :     first detect: (direction )  totals - direction:4  burst:0  max burst count:0  audio:0  external:0
16:36:22 : Motion record start - /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.36.16_49.h264
16:36:22 :   preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/motion_2020-04-26_16.36.16_49.jpg
16:36:22 :   execl[wait:0]: /home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2020-04-26_16.36.16_49.jpg /tmp/pikrellcam.log /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.36.16_49.th.jpg 150x150 80 80 600 107; rm -f /run/pikrellcam/motion_2020-04-26_16.36.16_49.jpg
  convert /run/pikrellcam/motion_2020-04-26_16.36.16_49.jpg -crop 80x80+560+67 			-resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2020-04-26_16.36.16_49.th.jpg
16:36:59 :   execl[wait:0]: nice -n 5 MP4Box -quiet -tmp /tmp -fps 24.002 -add /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.36.16_49.h264  /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.36.16_49.mp4 2> /dev/null && rm -f /home/pi/pikrellcam/media/videos/motion_2020-04-26_16.36.16_49.h264 ; rm -f /run/pikrellcam/video_converting; 
16:36:59 : Motion record stop (size:28.3MB < /tmp:2542.9MB)  vid_time:38.04  vid_fps:24.00  audio_frames:0  audio_rate:0

dburg
Posts: 6
Joined: Tue Jul 03, 2018 2:06 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Apr 26, 2020 7:47 pm

@lyalc, your logs are consistent with the behavior described in: viewtopic.php?f=43&t=115583&start=1475#p1583101

If you are comfortable making changes to the C code and rebuilding, you might try the solution in that post.

lyalc
Posts: 2
Joined: Sun Apr 26, 2020 10:34 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Apr 26, 2020 11:51 pm

Thanks dburg - applying that fix has resolved the problem of inconsistent emailing of alerts/snapshots in my environment.

Editing the code and recompiling is right in the outer boundary of my skillset, so glad everything worked!
cheers

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

using PKC with new HQ Pi camera (12 MP)

Tue May 05, 2020 1:45 am

I just got the new "high quality" C/CS mount, 12MP Pi camera. I am pleased to see it works OK with PiKrellCam, as usual!
It would be great if (time permitting!) the program could eventually be updated to support the full 12MP resolution for still images. 'raspistill' generates 4056x3040 jpegs by default with this camera.

EDIT: Nevermind! I didn't realize I could simply edit /home/pi/.pikrellcam/pikrellcam.conf to enter in the correct still_width and still_height values.

EDIT2: Pikrellcam seems to be hanging up sometimes with the new 12MP camera. I am wondering if there is some buffer overflow, if the preview image size is being sent at a larger resolution than the v1 or v2 cameras used (?)

Here are some photos: https://photos.app.goo.gl/nRtHb8SZJcTgYJ5v9
Below: still frame from PiKrellCam of some leaves, using Nikon 100mm lens and new RPi HQ camera:
PiKrellCam_2020-05-04_18.59.52_small.jpg
PiKrellCam_2020-05-04_18.59.52_small.jpg (94.76 KiB) Viewed 1773 times

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue May 05, 2020 5:42 pm

The HQ camera photos look like a great improvement. If only I had tried to get an order in before they sold out. But I'll eventually get an HQ camera and have a pikrellcam update then.

In the meantime, if you care to try it, bypass the GUI and edit pikrellcam.conf by hand after quitting pikrellcam. Set still_width and still_height to values appropriate for the HQ camera and see if it works.

arnauld
Posts: 22
Joined: Wed Oct 14, 2015 2:12 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 07, 2020 3:11 pm

I am pleased to see it works OK with PiKrellCam, as usual
@jbeale

Nice, thank you. What about focusing?
--
arnauld

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri May 08, 2020 2:25 pm

arnauld wrote:
Thu May 07, 2020 3:11 pm
Nice, thank you. What about focusing?
Focusing is possible but it is a challenge, trying to optimize a 4k image using a 800 pixel preview updated at only 2 fps. Running headless over the builtin wifi, no faster preview rate seemed to work stably; but I am not sure if the limit is really wifi or something internal to PiKrellCam with the new Pi-HQ camera. I am using a Pi-4B with the camera.

You can use the crop function set in .pikrellcam/pikrellcam.conf to examine a small portion of the image to aid focusing. It would be nice if there was a simple one-button control on the web page to flip back and forth between a small center crop and the full frame. The lenses I have require extremely fine adjustments to maximize the focus. The smallest motion I can achieve by hand makes a noticeable difference in focus.

geronimobb
Posts: 3
Joined: Tue Feb 10, 2015 9:56 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun May 24, 2020 11:25 pm

Anyone having trouble setting up the rtsp stream following the guidelines in this forum?

I tried a fresh install (raspbian, pikrellcam, gstreamer, ...) but with a pi noir, and i get a segmenation fault when starting the streamer manually.

baza1969uk
Posts: 1
Joined: Fri Jun 05, 2020 9:54 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jun 05, 2020 10:01 pm

Hi all,

Just stumbled upon Pikrellcam and found it very interesting indeed! Is this forum still active?

So far I have it compiled on a Pi3B, and working very well! I've just connected servos and got them working too.
The documentation provided made it all relatively simple, so good work whoever did all this! :D
What I'm really after though, is to enable motion tracking using the servos. I cant seem to find an option to do this though..
Can anyone help please?
Thank you!

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jun 06, 2020 6:11 pm

jbeale wrote:
Fri May 08, 2020 2:25 pm
arnauld wrote:
Thu May 07, 2020 3:11 pm
Nice, thank you. What about focusing?
Focusing is possible but it is a challenge, trying to optimize a 4k image using a 800 pixel preview updated at only 2 fps. Running headless over the builtin wifi, no faster preview rate seemed to work stably; but I am not sure if the limit is really wifi or something internal to PiKrellCam with the new Pi-HQ camera. I am using a Pi-4B with the camera.

You can use the crop function set in .pikrellcam/pikrellcam.conf to examine a small portion of the image to aid focusing. It would be nice if there was a simple one-button control on the web page to flip back and forth between a small center crop and the full frame. The lenses I have require extremely fine adjustments to maximize the focus. The smallest motion I can achieve by hand makes a noticeable difference in focus.
I'm now working with an HQ camera and finding that I can get normal preview updates only if I reduce video_fps to 20 (this with 1024 pixel preview on a Pi4). The conversion of the preview jpegs just cannot keep up otherwise and jpeg frames are dropped. I don't know if this is something that can be improved or if this just will be an unavoidable trade off between video_fps and preview update rate.

I've added (not released yet) a zoom function which can be remembered as part of the preset settings. You will be able to temporarily zoom in for focusing or save a zoom setting as part of a preset so switching to a zoom view will be as simple as clicking the preset up/down buttons.

It shouldn't be too long before I get this update released.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jun 06, 2020 6:30 pm

baza1969uk wrote:
Fri Jun 05, 2020 10:01 pm
Hi all,

Just stumbled upon Pikrellcam and found it very interesting indeed! Is this forum still active?

So far I have it compiled on a Pi3B, and working very well! I've just connected servos and got them working too.
The documentation provided made it all relatively simple, so good work whoever did all this! :D
What I'm really after though, is to enable motion tracking using the servos. I cant seem to find an option to do this though..
Can anyone help please?
Thank you!
There are a lot of variables in how motion tracking could work so my idea was to have a mechanism for it and then come up with some examples showing how to do it. I just have not done any examples yet.

The idea is that motion tracking would be done in an on_motion_begin script that reads the /run/pikrellcam/motin-events file and issues servo moves as motion events are reported during a motion recording. There is an example script "example-motion-events" which could be a starting point. A script could watch the x,y values of the overall motion frame vector or watch motion vectors in individual motion regions. In response my idea was that servos could be moved through a range of presets so motion regions would be valid for all servo positions. Or servos could be step moved but right now they can only be moved a step at a time. I would need to add a variable step move for that to be useful. So the script would need to write commands like "preset prev_position", "preset next_position", or "servo pan_left", "servo pan_right" to the FIFO.

Maybe I will yet get around to writing a useful demo script that does that.

Return to “Camera board”