use motion mplayer luvcview under Lubuntu

0 4362
Post Last Edited by jay at 2014-7-30 03:59

I just use the software to test CSI. Let us first download the software via the following command.
  1. sudo apt-get install mplayer luvcview
Copy the Code

In mplayer view camera, you can use the following command.
mplayer tv:// -tv driver=v4l2:input=0:width=640:height=480:fps=25 -vo x11.
of course, provided that you have installed the camera driver, and i installed several drivers.
  1. modprobe ov5640
  2. modprobe sun4i_csi0
Copy the Code

and then i want save yuv image. I use the command luvcview -c and it prompts

Next i ust the command to save yuv video and it displays

I use another tool called motion. and it's very powerful. I first download via the command
sudo apt-get install motion

After installation, need to modify the file motion.conf under /etc/motion/ directory. motion.conf is motion procedures and operator interface file. By modifying motion.conf in configuration to control the motion of running. When running #motion int the terminal, it will be shown in the current directory terminal looking motion.conf, did not find this time, to find the /etc/motion/motion.conf. So, I put a copy of this document, placed under /root, then every run into root in motion.
Before running, first modify this file /root/motion.conf, this is my motion.conf
  1. # Minimal motion example config file provided by the

  2. # Debian motion package - for basic webcam operation.

  3. #

  4. # You most certainly want to investigate

  5. # /usr/share/doc/motion/examples/motion-dist.conf.gz

  6. # for further configuration options. Also, refer to the

  7. # motion man page and /usr/share/doc/motion/motion_guide.html

  8. # for detailed information on configuration options.

  9. daemon off

  10. quiet on

  11. locate on

  12. # You may very well need to change this (check with 'dmesg'

  13. # after plugging in your webcam).

  14. videodevice /dev/video0

  15. # Image size in pixels (valid range is camera dependent).

  16. width 320

  17. height 240

  18. framerate 25

  19. quality 85

  20. auto_brightness off

  21. # General threshold level and noise threshold

  22. # level (for distinguishing between noise and motion).

  23. threshold_tune off

  24. threshold 4500

  25. noise_level 64

  26. # Initial brightness, contrast, hue (NTSC), and saturation.

  27. # 0 = disabled (valid range 0-255).

  28. brightness 0

  29. contrast 0

  30. saturation 0

  31. hue 0

  32. # Encode movies in real-time (install ffmpeg before enabling).

  33. ffmpeg_cap_new on

  34. # Codec to be used by ffmpeg for the video compression.

  35. # Supported formats: mpeg4, msmpeg4.

  36. ffmpeg_video_codec msmpeg4

  37. # Target base directory for pictures and films (you may need

  38. # to change this (or change its permissions) depending on

  39. # which system user runs motion).

  40. target_dir /root/motion/snapshots

  41. # Define a port number (e.g. 8000) to enable the mini-http server.

  42. # 0 = disabled.

  43. webcam_port 8081

  44. # Set to 'off' to allow anybody (not just localhost) to view the

  45. # webcam via the mini-http server (http://hostname:port).

  46. webcam_localhost off

  47. snapshot_interval 1

  48. snapshot_filename snapshot

  49. webcam_quality 50

  50. webcam_maxrate 8

  51. on_event_start /root/motion/on_motion_detected

  52. on_event_end /root/motion/on_motion_end

  53. gap 10
Copy the Code

Significance of these specific configuration, see the motion official wiki http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome.
the file under /root/motion/on_motion_detected, it can be a program, a script may be, as long as it can be performed
on_motion_detected following douctments
  1. #!/bin/bash

  2. echo "111111111111111on_motion_detected1111111111111111"

  3. DATE=$(date +"%Y%m%d%H%M%S")

  4. #DATE=$(date -d "-1 sec" +%Y%m%d%H%M%S)

  5. ALARM_TIME="/root/tmp/videotime"

  6. echo "$DATE" > $ALARM_TIME
Copy the Code

The on_motion_end is used to send e-mail, it will end after detecting movement, speaking to shoot down the motion avi video sent to the specified mailbox. this shell script file on-motion_end as follows
  1. #!/bin/bash

  2. echo "111111111111111on_motion_end1111111111111111"

  3. DIRC="/root/motion/snapshots/"

  4. VIDEOTIME="/root/tmp/videotime"

  5. TIME=$(cat $VIDEOTIME)

  6. ALARM_EMAIL="/root/tmp/myalarm.txt"

  7. echo "Subject: Motion detected - $TIME - $DIRC" > $ALARM_EMAIL

  8. echo "">> $ALARM_EMAIL

  9. echo "Motion detected - check $TIME.avi">>$ALARM_EMAIL


  11. #first trying of sending the avi video

  12. echo $MAILBODY | mutt -s $TIME -a $DIRC*$TIME.avi skpsun@163.com

  13. #second trying of sending the avi video

  14. TIME=$(expr $TIME - 1)

  15. echo $MAILBODY | mutt -s $TIME -a $DIRC*$TIME.avi skpsun@163.com
Copy the Code

Of course, before successfully automatically send e-mail, firsst confirm whether mailx correctly installed and configure ssmpt. Otherwise, you need to install both programs
  1. apt-get install heirloom-mailx ssmtp
Copy the Code

Then the following configuration in /etc/ssmtp/ssmtp.conf in
In /etc/ssmtp/ssmtp.conf, set the following
  1. root=youraccount@gmail.com

  2. mailhub=smtp.gmail.com:587

  3. rewriteDomain=

  4. hostname=smtp.gmail.com:587


  6. AuthUser=youraccount

  7. AuthPass=yourpasword

  8. FromLineOverride=YES # optional

  9. In /etc/ssmtp/revaliases:

  10. root:youraccount@gmail.com:smtp.gmail.com:587

  11. mainuser:youraccount@gmail.com:smtp.gmail.com:587
Copy the Code

And enter the command line
# mail youraccount@gmail.com to test, send press ctrl + D after writing the message body
You have to log in before you can reply Login | Sign Up

Points Rules