Capturing images from a webcam in Django with jpegcam
- Download the latest version and extract it. From the htdocs folder move 3 files somewhere to your SITE MEDIA: shutter.mp3, webcam.js, webcam.swf
- Edit webcam.js and set paths for swf_url and shutter_url. In my example: Around line 166 set a path to shutter.mp3 (it may be changed/fixed in future version):
- Now we can create an example view featuring the jpegcam widget. Here is slightly modded template from the example:
- In the template I've changed the path to webcam.js file and changed the URL that receives send images: Under /user/save_image/ I have add a view that will save the images.
- Code for the saving view looks like this:
- That should result in nicely working widget that shows the image from webcam and saves it on the server.
On the wiki there is also an example how to use jpegcam with a model based form (save and validate!). The model must exist and must have ImageField field.