stephencassidy
Posts: 37
Joined: Mon Aug 19, 2013 11:12 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Jul 23, 2015 9:18 pm

Hi! Firstly can I just say that this program so far is excellent :D

Now my question.

I have been tinkering with MotionEye (another very good camera application) and I can run a script to enable a great night time image with the following commands

Code: Select all

v4l2-ctl --set-ctrl=scene_mode=8
v4l2-ctl --set-ctrl=exposure_dynamic_framerate=1
sudo modprobe bcm2835-v4l2 max_video_width=1280 max_video_height=720
and I would get a fairly good night time image.
night.png
night.png (46.22 KiB) Viewed 5254 times
but I can't get any better than this.
night2.png
night2.png (31.99 KiB) Viewed 5254 times
any advice on which settings I can change to get a better night image?

Thanks and keep up the good work

Ste

kevw
Posts: 22
Joined: Wed Aug 27, 2014 1:49 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Jul 23, 2015 10:13 pm

Hi Ste,

have you tried a lower video fps, say 5 for starters?

Cheers,

Kev

stephencassidy
Posts: 37
Joined: Mon Aug 19, 2013 11:12 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Jul 23, 2015 10:56 pm

Thank Kev. Just tried 5fps and that has worked :)

Ste

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 2:14 am

The first full day using the "action area thumbnail" worked very well! One image caught my eye, a bird-squirrel chase in the driveway with a perfectly framed thumbnail. My other software would not have triggered on or recorded such a small area of motion.

https://www.youtube.com/watch?v=QeaJRK4 ... e=youtu.be
BirdSquirrel_2015-07-23_12.55.40_179.th.jpg
BirdSquirrel_2015-07-23_12.55.40_179.th.jpg (6.99 KiB) Viewed 5154 times
Last edited by jbeale on Fri Jul 24, 2015 2:59 am, edited 2 times in total.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 2:31 am

caldimerda wrote:Ah. No picture at night. I would normally (raspimjpeg) get a reasonable image in dim light. There's an IR light too so it should work all night. But the image is black so there's a setting not right. Exposure mode is 'night'. Saturation -99. Any ideas?
Maybe somebody else knows a setting, but I've only been able to get improvement by setting the
video fps low at night (around 6 fps). The camera is likely hitting limits with the 24 fps default.
So all I know to suggest is at night reduce video_fps, mjpeg_divider, and video_mp4box_fps and
set night exposure mode, and then restore the settings in the morning.

I was going to suggest the at-commands.conf file would be a good place to do this, but I'm just
now seeing a problem with the sunrise/sunset times and I'll look at that tomorrow.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 2:43 am

The only way to get reasonable night-time images (still or video) with the R-Pi camera in my experience, is to use long exposures, like 4 fps or less. If you specify the frame rate as 24 fps (which by default PiKrellCam does), then the camera is forced to use 1/24 sec exposure, and that doesn't show much at night. (You might think that only applies during video record, but due to the pre-roll buffer the video mode is always active.) There is a second effect which makes it even worse for video- something in the RPi video pipeline crushes near-black pixels to full black, probably to improve H.264 compression, but that means below a certain brightness threshold there is simply no image left.

In the other program, "RPi Cam Web Interface", you may notice that 'night' exposure works well with usable preview images IF you have no buffer enabled (0 ms) with what looks like 1/2 second exposure (?). As soon as you enable the camera pre-roll buffer (or a motion event is detected), the video mode is enabled, frame rate goes up and the image turns black at night time.

monty_burns_007
Posts: 7
Joined: Sun Dec 08, 2013 6:44 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 9:10 am

Hi, I've been using this software for a couple of day.
I changed from RPi Cam Web Interface to PikrellCam after a hint of jbeale.

I mainly want to use timelapsing for the moment.
Rpi Cam Web Interface worked great, but it seems PikrellCam is more promissing. (Motion, ...)

I have 3 questions regarding PiKrellCam :
- Can the annotation text be moved from top to for ex. bottom right ?
- Can the timelapse auto file names be customized ? I'd like to use a timelapse file name like the still naming where date / time is included. Not TL_000x_yyyy where yyy is just a counter a x is the timelapse nr.
- What adapation is config files has to be made to auto create the timelapse video on the pi ?

Until now I always make timelapse video on PC with for ex.: Quicktime.

caldimerda
Posts: 67
Joined: Tue Oct 09, 2012 9:41 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 10:28 am

Maybe somebody else knows a setting, but I've only been able to get improvement by setting the
video fps low at night (around 6 fps). The camera is likely hitting limits with the 24 fps default.
So all I know to suggest is at night reduce video_fps, mjpeg_divider, and video_mp4box_fps and
set night exposure mode, and then restore the settings in the morning.

I was going to suggest the at-commands.conf file would be a good place to do this, but I'm just
now seeing a problem with the sunrise/sunset times and I'll look at that tomorrow.

Thanks for the advice. I'll have a tinker tonight. I recall setting fps at night down to 20 but I'd not done anything else.

G7BWP
Posts: 2
Joined: Tue Oct 09, 2012 1:43 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 12:29 pm

Having tried to install this software suite I have run into a small problem: The installer program assumes there is a user "pi" and therefore throws a number of errors. This is due to my RPi not having a user "pi" - that user was deleted a long time ago. Is there any possibility that the installer could handle running from another users home directory and set the www-data permissions correctly ? Having spent many months with the camera working brilliantly I have been intrigued by what seems to be a good easily configurable means of motion detection.

Regards,

Guy

stephencassidy
Posts: 37
Joined: Mon Aug 19, 2013 11:12 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 12:52 pm

Is there a list of commands available for the various camera controls?

I would like if possible to set the framerate and the brightness at dusk and dawn if possible.

Thanks

ste

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 6:07 pm

monty_burns_007 wrote: I have 3 questions regarding PiKrellCam :
- Can the annotation text be moved from top to for ex. bottom right ?
There's no setting for position in the V2 or V3 annotate header. Right now there's only support
for V3, but eventually I'll get to putting in support for V3.
- Can the timelapse auto file names be customized ? I'd like to use a timelapse file name like the still naming where date / time is included. Not TL_000x_yyyy where yyy is just a counter a x is the timelapse nr.
Those are considered intermediate files and only the final timelapse video name can be configured.
There needs to be a consistent naming scheme so the set of files can be pattern matched to pass
to the avconv or whatever program. What sort of configuration do you need in the individual files?
If you have your own timelapse-end script where you can post process the files, could that allow you to do what you want?
- What adapation is config files has to be made to auto create the timelapse video on the pi ?
Put the timelapse commands in the ~/.pikrellcam.conf/at-commands.conf file, for example:

Code: Select all

Sat 8:00 tl_start  60
Sat 17:00 tl_end
You can have tl_hold on / tl_hold off commands if you want periods where timelapse is not taken.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 6:15 pm

G7BWP wrote:Having tried to install this software suite I have run into a small problem: The installer program assumes there is a user "pi" and therefore throws a number of errors.
While at various places I explicitly say /home/pi in the docutmentation, I meant for it to be
installable as another user. I think the program itself is set up to handle an alternate user but I
see I slipped up in a couple of places in the installer. I'll try to fix that and shortly maybe you can
try again. I'll post here when I push an update with an updated installer and if you get errors after that,
please post the errors.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 6:30 pm

stephencassidy wrote:Is there a list of commands available for the various camera controls?
I would like if possible to set the framerate and the brightness at dusk and dawn if possible.
ste
I need to make a list. For now, look in ~/.pikrellcam.conf and most settings there that are not a
command or filename template can be set throught the FIFO or in an at-command.conf. So in
~/.pikrellcam/at-commands.conf for example (if you change video_fps you should also
change mp4_box_fps and mjpeg_divider):

Code: Select all

daily dusk "@brightness 70"
daily dusk "@video_fps 6"
daily dusk "@mjpeg_divider 1"
daily dusk "@mp4_box_fps 6"
daily sunrise "@brightness 70"
daily sunrise "@video_fps 24"
daily sunrise "@mjpeg_divider 6"
...
BUT!!! You have wait just a bit. Setting video_fps was not settable through an at-command
and I have just fixed that but the git repository is not updated yet. Also last night I noticed an
issue with the sunrise/sunset calculation and that is what I have to look at now. I'll post a message
here when I push an update.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 6:48 pm

jbeale wrote:The first full day using the "action area thumbnail" worked very well! One image caught my eye, a bird-squirrel chase in the driveway with a perfectly framed thumbnail.
Nice video! Where can I get a bird like that? The last place I lived, the squirrels were always
dropping great volumes of pine cone fragments all over my driveway.

stephencassidy
Posts: 37
Joined: Mon Aug 19, 2013 11:12 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 7:03 pm

Awesome, thank you so much

Ste

caldimerda
Posts: 67
Joined: Tue Oct 09, 2012 9:41 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 9:05 pm

OK, done a quick test.. In Raspimjpeg, I set "exposure mode" to night and I see an image just fine on the Pi noir. When I stop the program and start pikrellcam and then change "exposure mode" to night I continue to get a black screen. So whatever that setting does, it doesn't appear to be doing it!

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Jul 24, 2015 9:23 pm

Hey billw,

Very impressive, thank you for this incredible effort!

I've been using RPi Cam Web for a while on 2 RPi B+, and it's developed very well. My experience for updating (as of late) has been difficult, largely to RaspiMJPEG stopping after updating. So I switched one of them to PiKrellCam.

One feature I've really wanted was Motion Regions. Finally! This should help reduce false positives.

One thing I did like in RPiCam, and that was the screen of thumbnails I could go through and choose which videos I wanted to review, and trash the rest. Having to look at every video would be more time consuming (well, for me anyhow).

Is there a way to do this, or is it being considered?

Tom

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 12:05 am

caldimerda wrote:OK, done a quick test.. In Raspimjpeg, I set "exposure mode" to night and I see an image just fine on the Pi noir. When I stop the program and start pikrellcam and then change "exposure mode" to night I continue to get a black screen.
Yes, I've done that too... now, in Raspimjpeg, set the camera "buffer" variable to anything but the default (0). With the pre-detect buffer on (force video mode), then you will see that the Raspimjpeg image becomes just as dark as pikrellcam. The difference is that pikrellcam has the video mode on all the time, because it is pre-buffering the video all the time. In general, the RPi video mode at (x) fps forces the exposure to (1/x) seconds regardless of "night" exposure setting; that is the cause of the darker image at night, regardless of what program you are using.

You can make either program yield a brighter image in video mode by specifying a lower frame rate (fps).

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 12:10 am

boomlikethat wrote:One thing I did like in RPiCam, and that was the screen of thumbnails I could go through and choose which videos I wanted to review, and trash the rest. Having to look at every video would be more time consuming (well, for me anyhow)
It's not yet preconfigured, but I have my instance of pikrellcam set up to generate and display a page of thumbnails which show only the active motion region for each event. (I haven't yet actually linked each thumbnail to the corresponding video, although that is a mere matter of fixing the PHP.) viewtopic.php?f=43&t=115583&start=25#p792773

When your thumbnail shows just the active motion area, even a small image can give you a good idea of what the event was. Here is the afternoon in a glance. You can see two detects of moving tree branch shadows, but still pretty good overall at finding the notable activity.
Image

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 2:16 am

I've pushed an update and sun times should be working. Those that want to change frame fps
at night can put lines like this in ~/.pikrellcam/at-commands.conf:

Code: Select all

# sunrise/sunset or dawn/dusk (times are reported in the log file)
# Motion is detected and preview updated at video_fps/mjpeg_divider so
# mjpeg_divider should be changed when video_fps is changed.  Also change
# video_mp4_box to track video_fps or mp4 will be slow or fast motion.
#
# 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"

# 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"
G7BWP - The installer is changed to handle non pi user, but I don't have a setup to test with
so please post any errors you get if you try to install again.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 3:23 am

jbeale wrote:
boomlikethat wrote:One thing I did like in RPiCam, and that was the screen of thumbnails I could go through and choose which videos I wanted to review, and trash the rest. Having to look at every video would be more time consuming (well, for me anyhow)
It's not yet preconfigured, but I have my instance of pikrellcam set up to generate and display a page of thumbnails which show only the active motion region for each event. (I haven't yet actually linked each thumbnail to the corresponding video, although that is a mere matter of fixing the PHP.) viewtopic.php?f=43&t=115583&start=25#p792773
It was only when I saw the results after you asked for the motion
area feature that I began to think a thumbnail screen page would be nice.

So I haven't had a chance to do anything about it and it looks like you
are already nearly there. Maybe if I just wait a little longer you might
have it all done before I could even start on it.

That would be fine with me!

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 4:31 am

I put this into /home/pi/.pikrellcam/at-commands.conf

Code: Select all

daily start "@video_fps 4"
however, the log at /tmp/pikrellcam.log shows an error, and I see the actual fps remained at 24 fps. I was able to set it manually with the onscreen controls, and see the much improved brightness at night. Maybe the update (git fetch, and rerun install) didn't work? How do I find out what version of pikrellcam I have running?

Code: Select all

2015-07-24 21:25:05 ==== PiKrellCam started ====
using FIFO: /home/pi/pikrellcam/www/FIFO
using mjpeg: /run/pikrellcam/mjpeg.jpg
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: MJPEG_FILE not changed.
  /home/pi/pikrellcam/www/config.php: FIFO_FILE not changed.
  /home/pi/pikrellcam/www/config.php: PIKRELLCAM not changed.
execl:[/home/pi/pikrellcam/scripts/startup /home/pi/pikrellcam /home/pi/pikrellcam/media /tmp/pikrellcam.log]
  MOUNT_DISK is not set.
circular buffer allocate: 11.00 MBytes (11 seconds at 8.0 Mbits/sec)
Bad command: [video_fps] [4]

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 5:18 am

billw wrote: Maybe if I just wait a little longer you might have it all done before I could even start on it.
Here is a very simple, no-frills thumbnail index page. You can click on any image to play the associated video.

Create "thumbs.php" with the code below, and put it in the directory /home/pi/pikrellcam/www/ so you can see it in your browser at <my.pi.ip.addr>/thumbs.php

This assumes you have enabled the "motion area only" thumbnails as described here, and still filenames have the form *.th.jpg
This also assumes that videos are in media/videos/ and thumbnail images are in media/stills/ relative to the PHP file, so you'll have it edit it at the bottom where it says showGallery("media/videos/","media/stills/"); if your file structure is something else.

Code: Select all

<?php
// display JPEG images in directory in name order, with clickable links
function showGallery( $pathToVideo, $pathToThumbs )
{
  $cols = 4;  // how many columns on the HTML page

  $output = "<html>";
  $output .= "<head><title>Thumbnails</title></head>";
  $output .= "<body>";
  $output .= "<center><h3><a href=index.php>PiKrellCam</a></h3></center>";
  $output .= "<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">";
  $output .= "<tr>";

  $dir = opendir( $pathToThumbs );  // open the directory
  $a=array();  // hold filenames in array so we can sort them in order
  while (false !== ($fname = readdir($dir)))  // loop through directory
  {
    if (substr($fname, -4) == '.jpg') // select only *.jpg filenames
    { $a[]=$fname; } // add this filename to the array
  }
  closedir( $dir ); // close the directory, all done reading
  $counter = 0;     // count how many images total so far
  sort($a);         // sorts the array of filenames in-place
  foreach($a as $fname){
      $vname = rtrim($fname, ".th.jpg") . ".mp4"; // filename X.th.jpg becomes X.mp4
      $output .= "<td valign=\"middle\" align=\"center\"><a href=\"{$pathToVideo}{$vname}\">";
      $output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
      $output .= "</a></td>";
      $counter += 1;
      if ( $counter % $cols  == 0 ) { $output .= "</tr><tr>"; }
  }
  $output .= "</tr> </table> </body> </html>"; // end of HTML file
  echo $output;  // send out the completed HTML web page
}
showGallery("media/videos/","media/stills/");  // video and thumbnail directories
?>
Also I changed index.php to add a button next to VIDEO and STILL, to link to the new "thumbs.php" page:

Code: Select all

        <div id="container" class="top-margin">
      Files:
      <a href="media.php?dir=<?php echo VIDEO_DIR; ?>"
        class="btn-control"
      >Videos</a>
      <a href="media.php?dir=<?php echo STILL_DIR; ?>"
        class="btn-control"
      >Stills</a>
      <a href="thumbs.php"
        class="btn-control"
        style="margin-right:20px;"
      >Thumbs</a>
      Enable:
Last edited by jbeale on Sat Jul 25, 2015 3:36 pm, edited 2 times in total.

G7BWP
Posts: 2
Joined: Tue Oct 09, 2012 1:43 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 12:16 pm

I have reinstalled pikrellcam to run under a user name other than "pi", apart from initially forgetting to start pikrellcam, it now works perfectly with no errors.
Thanks for a rapid code tweak.
Guy

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Jul 25, 2015 3:27 pm

jbeale wrote:
billw wrote: Maybe if I just wait a little longer you might have it all done before I could even start on it.
Here is a very simple, no-frills thumbnail index page. You can click on any image to play the associated video.

Create "thumbs.php" with the code below, and put it in the directory /home/pi/pikrellcam/www/ so you can see it in your browser at <my.pi.ip.addr>/thumbs.php

This assumes you have enabled the "motion area only" thumbnails as described here, and still filenames have the form *.th.jpg
This also assumes that videos are in media/videos/ and thumbnail images are in media/stills/ relative to the PHP file, so you'll have it edit it at the bottom where it says showGallery("media/videos/","media/stills/"); if your file structure is something else.

Code: Select all

<?php
// display JPEG images in directory in name order, with clickable links
function showGallery( $pathToVideo, $pathToThumbs )
{
  $cols = 4;  // how many columns on the HTML page

  $output = "<html>";
  $output .= "<head><title>Thumbnails</title></head>";
  $output .= "<body>";
  $output .= "<center><h3><a href=index.php>PiKrellCam</a></h3></center>";
  $output .= "<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">";
  $output .= "<tr>";

  $dir = opendir( $pathToThumbs );  // open the directory
  $a=array();  // hold filenames in array so we can sort them in order
  while (false !== ($fname = readdir($dir)))  // loop through directory
  {
    if (substr($fname, -4) == '.jpg') // select only *.jpg filenames
    { $a[]=$fname; } // add this filename to the array
  }
  closedir( $dir ); // close the directory, all done reading
  $counter = 0;     // count how many images total so far
  sort($a);         // sorts the array of filenames in-place
  foreach($a as $fname){
      $vname = rtrim($fname, ".th.jpg") . ".mp4"; // filename X.th.jpg becomes X.mp4
      $output .= "<td valign=\"middle\" align=\"center\"><a href=\"{$pathToVideo}{$vname}\">";
      $output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
      $output .= "</a></td>";
      $counter += 1;
      if ( $counter % $cols  == 0 ) { $output .= "</tr><tr>"; }
  }
  $output .= "</tr> </table> </body> </html>"; // end of HTML file
  echo $output;  // send out the completed HTML web page
}
showGallery("media/videos/","media/stills/");  // video and thumbnail directories
?>
@jbeale:
Thanks for doing that, I'm not a big programmer, so that helps!

Return to “Camera board”