Raspberry pi motion detection using raspi camera - linux

I have installed motion, in pi3. connected pi camera. configured motion.conf according to my needs(pi/motion/)and started motion. still i am not able to see the pics created. any additional steps needed to configure this. steps in detail.
1.Connected raspi cam
2.Installed motion.
3.raspistill command worked.
4.edited motion.conf
started motion "sudo service motion start"
Later,Found that we need to create /dev/video0, so executed
sudo modprobe bcm2835-v4l2
Added below to etc/modules
/#camera with
v4l2 driver bcm2835-v4l2
After this also its not working any idea, where/what to check next?

Make sure motion is using motion.conf. It's something very stupid but I remember struggling with it because if you don't tell the program to look at /etc/motion/motion.conf it will try to find motion.conf in your current folder.
So you may want to specify the conf location with :
motion -c /path/to/motion.conf

Related

XRUSB raspberry pi

I'm working with a raspberry pi connected with xrusb to a controller using python.I use make file to Compile and install the common usb serial driver module and it works fine. After reboot i have problem. The driver is lost. I have to install the module again using this
modprobe usbserial
insmod ./xr_usb_serial_common.ko
Any idea?
Now my answer might be off because of the way you say "install the driver". I bet the make script most likely just loaded the driver just like you did via modprobe.
In order to get the module to be loaded at boot time, you need to tell udev what to load/do during bootup. And tell the kernel to load your driver.. Otherwise it assumes you don't want it to be loaded at boot time.
Either you can do a automatic module handling via:
#nano /etc/modules-load.d/usbserial.conf
usbserial
or, you can specify options:
#nano /etc/modprobe.d/usbserial.conf
options usbserial parameter_name=parameter_value
Here's some documentation on how this works:
http://man7.org/linux/man-pages/man5/modules-load.d.5.html
https://wiki.archlinux.org/index.php/kernel_modules
(Even if you're not running Arch on your RPi, they still have one of the best documentation websites for Linux out there. User friendly, in depth etc. So apply the information there to your Distribution, they should be very much the same this day and age)
I found maybe a temporary solution so i can finish my project and look for the best way later.
I make a script to run after reboot to load the driver.
use:
sudo crontab -e
then go to the bottom and write
#reboot bash /your/path/script/script.sh
`

Raspberry Pi stuck on script at startup

I wanted to have my Raspberry Pi update the system clock from a GPS on start up but now something has gone wrong and I can't login.
I created a bash script that calls 'sudo -i' and a few other gpsd related instructions. I pointed the /etc/profile towards the script. If I Ctrl+C to get to a prompt I get root access but the directories are listing nothing when I use the 'ls' command. If I exit from root I get stuck again. I figure that if I could delete the bash script the problem would go away but I don't know how to view that partition of the SD card on a PC. Any suggestions?
Ok, I solved the problem. There is a ext4 partition editor called ExtFS for Windows. You can view and edit an ext4 partition easily in this program. You can download it here.

Stop Raspberry Pi from running program at boot

I was trying to figure out how to run a program at boot, but after realizing this program is an infinite loop, I have no way of getting out, or back to the terminal. Right when I give the Pi power it just goes right to the program on a black background. I don't remember exactly what I did to make it run at boot, I believe I just added some code in a place right above something that said "exit 0" and below something that says "esac". I don't remember the command that even got me there. (I am new to the Pi and Python and have just been playing around..unsucessfully.)
If anyone could help me either delete this program or get me to be able to edit it so I can fix the infinite loop that would be great. I'd rather not have to completely over-write the sd card with a fresh raspbian. But like I said I can't do anything at boot, and Ctrl + C doesn't do anything nor Ctrl + Alt + Delete.
EDIT: When I put the SD card in my computer, I see a list of 11 files:
bootcode
cmdline
config
fixup
fixup_cd
issue
kernel
kernel_cutdown
kernel_emergency
start.elf
start_cd.elf
None of these mean anything to me...
Update: Looks like I failed to get that you want to interrupt the running bootprocess and stop the script.
The simplest idea would be to turn of the pi, unplug the sd card and plug it into your desktop, (re)move the script and boot again.
Processes spawned during boot are stored in scripts in /etc/init.d/.... These scripts are called by the init process, the first process on a Linux machine (PID:1)
But init starts not all scripts in /etc/init.d. This depends on the run level. On a debian system there are 7 run levels.
For every run level there is a folder called like:
/etc/rc0.d
...
/rc6.d
in which are softlinks to scripts from /etc/init.d are stored.
To remove a script from being executed on every boot you'll delete all links from that folders. Usually on debian systems this is done using the update-rc.d tool:
update-rc.d NAME_OF_INIT_SCRIPT remove
You should also have a look at the file /etc/rc.local
Alt + PrintScn + k to kill the process stuck running from rc.local
You can use the cmdline.txt.
First, add or modify the cmdline.txt file on your sd card. Add "init=/bin/sh", then restart your Pi, and you can see a command line prompt.
Type 'sudo nano /etc/rc.local' to edit the file, and comment or delete the line containing the error. After that restart.
I had exactly the same issue, couldn't quit the process using CTRL+C. I edited the cmdline.txt like stated above, but then the pi didn't load the necessary usb drivers for my keyboard.
So eventually I logged in over SSH to the pi, and modified my rc.local file that way.
In my case worked combination "Alt" + "F4", it stops the current session and opens the login screen
I had the same problem as explained at the beginning of this Post. My Python app was caught in an endless loop.
I tried the Ctrl+Alt+F2 Command as recommended in many posts found in Internet without any terminal window being open. Apparently, after many other trials and reboots I saw a glimpse of a Terminal window each time the loop of my application restarted. It was impossible to catch anything until I started recording the screen using the slow motion video of my mobile phone and, yes, a terminal window with the Linux prompt was active, and able to accept keyboard entries.
All I did was (almost blindly) editing the culprit file with the
sudo nano filename command
and entering some characters in order to actually corrupt such file, saving and closing it, a rebooting the Pi.
At the end of the boot, the file produced an error but the system kept ready to operate.
I was then able to fix the bug in a normal way.
It hope this may be useful to others. In my case it spared me of burning a new Raspbian and losing all my previous work.
I got myself stuck in exactly the same problem. Luckily I had the ssh enabled, apparently this is disabled by default on Raspbian Jessie, so this may not work for all.
The exit 0 is the line in /etc/rc.local where you would have added in the script that is now running in a continuous mode. If you can ssh into the Pi using Putty and the Pi's IP address then
sudo nano /etc/rc.local
Scroll down to the bottom of the file and remove the offending program, then sudo reboot
They way to prevent this issue from happening is to add an & (ampersand) to the end of the line to fork the process and run it as a separate process like so
python /home/pi/myscript.py &
as specified in https://www.raspberrypi.org/documentation/linux/usage/rc-local.md
The ampersand allows the command to run in a separate process and continue booting with the process running.

Ubuntu Command Line to force running application from secondary (or specific) monitor

I'm creating an application (command line script) to play videos directly to the secondary monitor, which is connected either via VGA or HDMI.
The video player itself is cvlc, with command cvlc -f myvideo.avi.
Can anyone please help about the script to run the cvlc directly to secondary monitor regardless of which monitor it was launched from.
i've tried DISPLAY=":0.1" vlc -f myvideo.avi, but results a scrambled unusable video player.
Thanks.
Try using the --x11-display :0.1 flag. It's not part of the --help output but I use it on my 2.0.1 vlc.

Beagleboard Angstrom Linux, Image Capture Script streamer alternative

I want to take a snapshot from my logitech webcam with desired resolution and save the image by using linux bash script. I need to do it on my beagleboard with Angstrom image. In my beagleboard i can capture with using cheese. But i dont know how to capture in terminal with script.
In my host computer i am using streamer with
streamer -c /dev/video0 -b 16 -o outfile.jpeg
But i dont know how to take snapshots in Angstrom. Can you make suggestions?
How can i capture with command line?
Regards
I've used mjpg-streamer with some success. It sends a video stream through port 8080, although you can change that by editing the startup script.
I used instructions from here, although I skipped the make install part and just run it off my home directory. Worked both with the default Angstrom image and with Debian running off the SD card (i.e., non-flashed).
You can view the stream by pointing your browser (either local or over-the-LAN) to http://beagle.address:8080/?action=x, where x is stream or snapshot. I trust those parameters are self-explanatory :).
You can use a text-based browser such as links to open the URL, and links will then prompt you for the filename of the image. That's for testing, then I suppose you can find a way to save the snapshot without human intervention if you intend to use it from a script.
I'm using gstreamer to capture webcam input on Beaglebone using a logitech webcam. You'll need gstreamer with gstreamer-utils installed. I'm using Ubuntu and they can be found from the standard repos. Here's the CLI command:
gst-launch v4l2src num-buffers=1 ! ffmpegcolorspace ! video/x-raw-yuv,width=320,height=240 ! jpegenc ! filesink location=test.jpg
Unfortunately, I'm experiencing some issues after some images as the pipeline freezes on v4l2src. Maybe you'll have better luck with your setup.

Resources