MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. jasonarends
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    J
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 7
    • Groups 0

    jasonarends

    @jasonarends

    1
    Reputation
    645
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    jasonarends Unfollow Follow

    Best posts made by jasonarends

    • RE: Motion Detection with RaspiCam, Non-Module version

      @dam4 sounds like it might be working - especially based on these lines:

      [1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
      display_power=1
      ...
      [1:ml1] [NTC] [ALL] mlp_actions: End of event 1
      display_power=0
      

      I found a couple other config options and I think I was able to disable all the “event_newfile: File of type 2 saved to: /run/shm/lastsnap.jpg” stuff. I wonder if that’s what was causing memory leaks for @bhepler I set the pre_capture and post_capture to 0

      You might need to play with some of the settings for threshold and event_gap to get it to behave like you want but it sounds like you’re almost there. I set mine up in pm2 like mentioned earlier in the thread and it’s been working fine for the last day for me.

      posted in Tutorials
      J
      jasonarends

    Latest posts made by jasonarends

    • RE: Motion Detection with RaspiCam, Non-Module version

      @dam4 sounds like it might be working - especially based on these lines:

      [1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
      display_power=1
      ...
      [1:ml1] [NTC] [ALL] mlp_actions: End of event 1
      display_power=0
      

      I found a couple other config options and I think I was able to disable all the “event_newfile: File of type 2 saved to: /run/shm/lastsnap.jpg” stuff. I wonder if that’s what was causing memory leaks for @bhepler I set the pre_capture and post_capture to 0

      You might need to play with some of the settings for threshold and event_gap to get it to behave like you want but it sounds like you’re almost there. I set mine up in pm2 like mentioned earlier in the thread and it’s been working fine for the last day for me.

      posted in Tutorials
      J
      jasonarends
    • RE: Motion Detection with RaspiCam, Non-Module version

      @dam4
      Does your camera work outside of motion? Can you do

      raspistill -o cam.jpg
      

      and get a picture?

      If so, try launching motion with:

      /usr/local/bin/motion -c /etc/motion/motion.conf
      

      just to be sure that it’s reading the correct file, and then if you can watch the output and paste it here (or pastebin if it’s large) it might help us troubleshoot.

      Here’s what the first part of mine looks like with some of the config stuff cut out:

      [27690520:motion] [NTC] [ALL] motion_startup: Motion 4.0.1+gitb103dc0 Started
      [27690520:motion] [NTC] [ALL] motion_startup: Logging to syslog
      [27690520:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (INF)
      [27690520:motion] [INF] [ALL] conf_output_parms: Writing configuration parameters from all files (1):
      [27690520:motion] [INF] [ALL] Thread 0 - Config file: /etc/motion/motion.conf
      ---snip---
      [0:motion] [NTC] [ALL] main: Camera ID: 0 is from /etc/motion/motion.conf
      [0:motion] [NTC] [ALL] main: Camera ID: 0 Camera Name: (null) Device: /dev/video0
      [0:motion] [NTC] [ALL] main: Waiting for threads to finish, pid: 30877
      [1:ml1] [NTC] [ALL] motion_init: Camera 0 started: motion detection Enabled
      [1:ml1] [NTC] [VID] vid_start: Opening MMAL cam
      [1:ml1] [NTC] [VID] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 640 x 480 at 4 fps
      [1:ml1] [NTC] [VID] create_camera_component: MMAL camera component created
      [1:ml1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
      [1:ml1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 2 items
      [1:ml1] [INF] [ALL] mlp_detection: Lightswitch detected
      [1:ml1] [INF] [EVT] event_new_video: Source FPS 4
      [1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
      
      
      posted in Tutorials
      J
      jasonarends
    • RE: Motion Detection with RaspiCam, Non-Module version

      @dam4
      Hi, make sure that you’ve edited your motion.conf file that it is using according to the instructions in the original post:

      framerate 4 - run the detection video at 4 frames per second
      threshold 2500 - increase the # of pixels to trigger the screen. We want them to get close to the mirror
      minimum_motion_frames 2 - Motion must be detected in 2 consecutive frames (at 4 FPS)
      event_gap 60 - This is important. This is how long in seconds after no motion the screen will turn off.
      output_pictures off - Do not save images
      ffmpeg_output_movies off - Do not record video
      stream_port 0 - Turn off remote viewing
      webcontrol_port 0 - Turn off HTTP control of camera
      on_event_start vcgencmd display_power 1 - Important! This is the command to turn on the screen
      on_event_end vcgencmd display_power 0 - Important! This is the command to turn off the screen
      

      I’ve copied my config here: https://pastebin.com/61hiygKX (edit: updated conf)
      If you put motion.conf in /etc/motion it should pick it up by default without having to specify anything.

      Make sure you’ve set the event_gap, on_event_start, and on_event_end at the very least for testing.

      You can also just try running the command

      vcgencmd display_power 0
      

      by itself to make sure the command works to turn off the monitor.

      posted in Tutorials
      J
      jasonarends
    • RE: Motion Detection with RaspiCam, Non-Module version

      @dam4

      yep, you have the original motion binary in your home directory still, you can just remove that.

      posted in Tutorials
      J
      jasonarends
    • RE: Motion Detection with RaspiCam, Non-Module version

      @dam4 I had the same problem and couldn’t get the correct dependencies resolved, but I just got it to work on stretch by following the Abbreviated Building Guide instructions here: http://htmlpreview.github.io/?https://github.com/Motion-Project/motion/blob/master/motion_guide.html

      I had already tried the way you did so I had the motion.conf from the other build which I had modified, and it worked with that version.

      edit:

      sudo apt-get install autoconf automake build-essential pkgconf libtool libzip-dev libjpeg-dev git libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev
      cd ~ 
      git clone https://github.com/Motion-Project/motion.git 
      cd motion 
      autoreconf -fiv 
      ./configure 
      make 
      make install
      
      posted in Tutorials
      J
      jasonarends
    • RE: [MMM-Motion-Detection] Motion Detection through PiCam or USB Webcam

      Yes, this works:

      raspistill -o cam.jpg
      
      

      I see the preview on the monitor and the file gets saved.

      I added some additional debugging to the python code in this module and it is giving me a Null back when it does the .read() instead of an array. I’m not sure what’s different unless it has to do with the python-shell not working right or something in the picam.py code with the buffers.

      If I manually call the function in Python in the same way this code does, and it gives me back an array and works fine:

      pi@pi-3-mm:~/MagicMirror/modules/MMM-Motion-Detection/motiondetection $ python
      Python 2.7.13 (default, Jan 19 2017, 14:48:08)
      [GCC 6.3.0 20170124] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import picam
      >>> cam = picam.OpenCVCapture()
      >>> cam.start()
      >>> cam.read()
      array([[[ 24,  31,  58],
              [ 22,  29,  56],
              [ 21,  28,  55],
              ...,
              [ 12,  15,  23],
              [ 12,  15,  23],
              [ 12,  15,  23]],
      
             [[ 22,  29,  56],
              [ 23,  30,  57],
              [ 21,  28,  55],
              ...,
              [ 13,  16,  24],
              [ 12,  15,  23],
              [ 12,  15,  23]],
      
             [[ 23,  30,  57],
              [ 24,  31,  58],
              [ 21,  28,  55],
              ...,
              [ 14,  16,  24],
              [ 13,  16,  24],
              [ 12,  15,  23]],
      
             ...,
             [[131, 145, 173],
              [129, 143, 171],
              [128, 142, 170],
              ...,
              [ 25,  31,  72],
              [ 21,  27,  68],
              [ 27,  33,  74]],
      
             [[129, 143, 171],
              [129, 143, 171],
              [129, 143, 171],
              ...,
              [ 28,  34,  75],
              [ 23,  31,  71],
              [ 24,  32,  72]],
      
             [[129, 143, 171],
              [130, 144, 172],
              [130, 144, 172],
              ...,
              [ 31,  37,  78],
              [ 25,  33,  73],
              [ 21,  29,  69]]], dtype=uint8)
      
      
      posted in Utilities
      J
      jasonarends
    • RE: [MMM-Motion-Detection] Motion Detection through PiCam or USB Webcam

      I can’t seem to get this to initialize. I can capture images with my picam and show the preview in python, but I get this every time I start MM with this plugin:

      0|MagicMir | [MMM-Motion-Detection] Motion Detection started...
      0|MagicMir | [MMM-Motion-Detection] --------------------
      0|MagicMir | [MMM-Motion-Detection] PiCam starting...
      0|MagicMir | [MMM-Motion-Detection] Camera Failed to Initialize! Shutting Down.
      0|MagicMir | Whoops! There was an uncaught exception...
      0|MagicMir | { Error: process exited with code 1
      0|MagicMir |     at terminateIfNeeded (/home/pi/MagicMirror/modules/MMM-Motion-Detection/node_modules/python-shell/index.js:100:23)
      0|MagicMir |     at ChildProcess. (/home/pi/MagicMirror/modules/MMM-Motion-Detection/node_modules/python-shell/index.js:88:9)
      0|MagicMir |     at emitTwo (events.js:106:13)
      0|MagicMir |     at ChildProcess.emit (events.js:191:7)
      0|MagicMir |     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
      0|MagicMir |   executable: 'python',
      0|MagicMir |   options: null,
      0|MagicMir |   script: 'modules/MMM-Motion-Detection/motiondetection/motiondetection.py',
      0|MagicMir |   args: [ '{"useUSBCam":false,"interval":8,"motionStopDelay":120,"detectionThreshold":1000,"turnOffDisplay":true}' ],
      0|MagicMir |   exitCode: 1 }
      
      
      posted in Utilities
      J
      jasonarends