oguime
Posts: 15
Joined: Fri Feb 14, 2014 3:14 am

Record camera video

Fri Feb 14, 2014 3:39 am

I've installed a magnetic sensor on my door to receive notifications on Notify My Android and Prowl whenever that door is opened (through a 433.92MHz receiver connected to an Arduino UNO with Ethernet shield and PushingBox).

I also would like to record a 5 to 30 second video triggered by the same sensor from a camera pointed to the door using my Raspberry, but have not found a simple way of doing it.

Should I use a webcam, ip camera or pi camera module? What software on the Pi would be capable of saving the video on demand, instead of using motion capture?

Ideas are welcome, thanks.

oguime
Posts: 15
Joined: Fri Feb 14, 2014 3:14 am

Re: Record camera video

Sat Feb 15, 2014 10:59 pm

Jay found a nice way of saving video from a Foscam ip camera to the Pi at http://wrice.blogspot.com.br/2013/07/re ... video.html.

Tested his script and worked fine, still need to trigger recording from the Arduino, limit the recording length and maybe upload the resulting file to the cloud.

Hugh-Roger
Posts: 27
Joined: Sat Jan 18, 2014 12:31 am

Re: Record camera video

Tue Feb 18, 2014 5:06 pm

You can use raspivid to capture video from a command

see
http://www.raspberrypi.org/camera
e.g.
Capture a 10s video:
raspivid -o video.h264 -t 10000

If you can trigger a switch you can invoke this (and any other) command via the GPIO using pibutton
http://www.mhr.me.uk/projects/pibutton.html

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

Re: Record camera video

Tue Feb 18, 2014 5:36 pm

oguime wrote:...I also would like to record a 5 to 30 second video... Should I use a webcam, ip camera or pi camera module? What software on the Pi would be capable of saving the video on demand, instead of using motion capture?
Any of those could work, recording video on demand. If price/performance ratio matters to you, the R-Pi camera gives you good resolution and video quality (unless there isn't enough light) which you cannot match at that price with a USB camera and especially not an IP camera.

The main downside to the R-Pi camera is (1) you need to make your own housing for it and (2) it needs to be quite close to the R-Pi due to the short flex cable- unless you separately purchase a longer cable. Also (3) if you need good low-light performance, you'll have to add your own light, which could be an IR illuminator if you go with the Pi-NoIR model.

I've used both the R-Pi camera and some IP cameras in an application like this. If you get an IP camera specified for low-light it will work better at night, but you will likely pay 4x as much, and during the day the Pi camera's image quality is still superior.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17547
Joined: Sat Jul 30, 2011 7:41 pm

Re: Record camera video

Tue Feb 18, 2014 6:39 pm

There a possibility we might get some better low light performance. There are some recently found issues in the exposure code in the driver that when fixed may help. Not promising anything though, but will be interesting to see if it helps.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

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

Re: Record camera video

Tue Feb 18, 2014 8:04 pm

jamesh wrote:There a possibility we might get some better low light performance. There are some recently found issues in the exposure code in the driver that when fixed may help. Not promising anything though, but will be interesting to see if it helps.
That would certainly be excellent news if performance improved, although I wouldn't expect much. The good low-light IP cameras I have use a larger "1/3-inch format" sensor and also have lower resolution, so more silicon area per pixel. On the other hand, if you get on-chip 2x2 binning to work, I would expect some improvement in low light.

oguime
Posts: 15
Joined: Fri Feb 14, 2014 3:14 am

Re: Record camera video

Wed Feb 19, 2014 12:42 am

The Pi camera image quality seems nice but I'm leaning towards using IP cameras because they are easier to find in Brazil and Foscam clones are cheaper than buying a second Pi.

And I'll probably install a second camera pointing to the front door and I want to see if a single Raspberry can handle both.

Still have to make it work for a preset amount of time, and upon being commanded by the arduino. A Python web service, maybe?

Hugh-Roger
Posts: 27
Joined: Sat Jan 18, 2014 12:31 am

Re: Record camera video

Wed Feb 19, 2014 10:53 am

jbeale wrote:
I've used both the R-Pi camera and some IP cameras in an application like this. If you get an IP camera specified for low-light it will work better at night, but you will likely pay 4x as much, and during the day the Pi camera's image quality is still superior.
I may be misunderstanding your point, but I have set up a couple of raspberry pi "IP cameras" recently, to work alongside a Foscam IP camera. The Foscam works at night (within the constraints of its inbuilt IR Leds), does its own motion detection/FTP/Email etc and cost £70.

A Raspberry pi costs around £30 board, £12 Wifi dongle, $5 PSU, £5 SD Card, £20 Camera = £72. And I still dont have an IP66 enclosure for it.

As far as I can see, if one is interested in pure cost effectiveness alone, the Raspberry Pi is not a sensible route.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17547
Joined: Sat Jul 30, 2011 7:41 pm

Re: Record camera video

Wed Feb 19, 2014 1:10 pm

Hugh-Roger wrote:
jbeale wrote:
I've used both the R-Pi camera and some IP cameras in an application like this. If you get an IP camera specified for low-light it will work better at night, but you will likely pay 4x as much, and during the day the Pi camera's image quality is still superior.
I may be misunderstanding your point, but I have set up a couple of raspberry pi "IP cameras" recently, to work alongside a Foscam IP camera. The Foscam works at night (within the constraints of its inbuilt IR Leds), does its own motion detection/FTP/Email etc and cost £70.

A Raspberry pi costs around £30 board, £12 Wifi dongle, $5 PSU, £5 SD Card, £20 Camera = £72. And I still dont have an IP66 enclosure for it.

As far as I can see, if one is interested in pure cost effectiveness alone, the Raspberry Pi is not a sensible route.
That's the inherent difference between dedicated and multiple purpose parts.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

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

Re: Record camera video

Wed Feb 19, 2014 2:53 pm

Hugh-Roger wrote:I may be misunderstanding your point, but I have set up a couple of raspberry pi "IP cameras" recently, to work alongside a Foscam IP camera. The Foscam works at night (within the constraints of its inbuilt IR Leds), does its own motion detection/FTP/Email etc and cost £70.

A Raspberry pi costs around £30 board, £12 Wifi dongle, $5 PSU, £5 SD Card, £20 Camera = £72. And I still dont have an IP66 enclosure for it.
.
Fair enough, if you are starting from scratch and don't need much resolution. Coming from the 5 MPixel R-Pi camera, the cheap Foscam cameras I found are only 0.3 Mpixel, 640x480 so I didn't consider them. The OP already has a working R-Pi setup doing his door sensor, so I understood the question as a camera accessory for a Pi, given that the R-Pi itself is not part of the cost equation. He would only need the $25 camera board, and I was comparing a 3 Mpixel IP camera (bare board with lens- no housing) which cost me over $100 from Ebay.

oguime
Posts: 15
Joined: Fri Feb 14, 2014 3:14 am

Re: Record camera video

Wed Feb 19, 2014 3:20 pm

jbeale and Hugh-Roger,

Perhaps I have not explained my setup properly... The door sensor has an 433.92MHz transmitter and I have an Arduino with RF receiver and Ethernet shield that receives the signal from the sensor and sends a notification through the Internet.

I already have a Raspberry Pi rev.B and wanna add it to the setup to record a short video from the door whenever the sensor chimes in, but have not decided what camera (or combination of cameras) I will use.

I already have a Foscam and by my initial tests it could work, but it's resolution is quite bad when compared to the Pi camera, as jbeale pointed out.

I could also buy a single Pi camera and relocate the Raspberry close to one of my doors (it's in the office now) and use both, but that would require implementing distinct image acquisition methods.

I really appreciate both points of view and will keep exploring the alternatives.

Do you have suggestions on how to trigger the recording over ethernet?

johnmcd
Posts: 9
Joined: Fri Mar 01, 2013 8:38 pm

Re: Record camera video

Fri Feb 21, 2014 3:53 pm

I have a similar setup (except motion sensors at front and back doors, both covered by Foscam cameras), and I played around for a while with capturing video when motion triggered but I ran into a number of issues in getting it to work consistently, so I switched to an approach where I take 5 snapshots 1 second apart when motion is detected. Here's a rough idea of what the snapshot code looks like:

...
response = urllib.request.urlopen(http://192.168.1.204:8123/snapshot.cgi? ... mypassword)
data = response.read()
snapshot_file = open('/home/myuser/snapshots/filename.jpg, 'wb')
snapshot_file.write(data)
snapshot_file.close()
...

The folder 'snapshots' is a smb mount on my home's NAS server. If I'm away from the house I just have the RPi send me an email with the 5 snapshots attached, and if I'm home the RPi notifies a small Windows tray program that runs on all of the house computers that pops up a window and displays the snapshots in a continuous loop until the user hits the 'Dismiss' button. It's been running for a few weeks and everything works great so far.

Just an idea of an alternative approach that eliminates the complexity of handling video.

John

oguime
Posts: 15
Joined: Fri Feb 14, 2014 3:14 am

Re: Record camera video

Sun Feb 23, 2014 5:02 pm

Hi John,

Taking a series of snapshots is a good idea, but I'm currently exploring the Raspberry hardware acceleration capabilities with the help of the GStreamer-devel discussion list.

I've used Python 3 with GStreamer to encode video from the foscam camera and will create a web service that the Arduino can access to start recording.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 10 guests