diff --git a/optional-app/README.md b/optional-app/README.md
index 70e7b1d..b61b916 100644
--- a/optional-app/README.md
+++ b/optional-app/README.md
@@ -4,4 +4,4 @@ How to install depends on app.
# webcam #
-![image](http://blog.iotwrt.com/wp-content/uploads/2015/01/webcam.png)
+![image](http://blog.iotwrt.com/wp-content/uploads/2015/01/webcam1.png)
diff --git a/optional-app/webcam/django/html/webcam.html b/optional-app/webcam/django/html/webcam.html
index 0ace096..7006f44 100644
--- a/optional-app/webcam/django/html/webcam.html
+++ b/optional-app/webcam/django/html/webcam.html
@@ -48,6 +48,7 @@
}
});
}
+ $("#surface").attr('src', "temp.jpg?t=" + Math.random());
});
});
$("#refresh").click( function(){
@@ -82,8 +83,9 @@
-
-
+
+ snapshot
+
diff --git a/optional-app/webcam/django/tmp/cancel.png b/optional-app/webcam/django/tmp/cancel.png
new file mode 100644
index 0000000..82524e1
Binary files /dev/null and b/optional-app/webcam/django/tmp/cancel.png differ
diff --git a/optional-app/webcam/django/views.py b/optional-app/webcam/django/views.py
index ff01765..26e214f 100644
--- a/optional-app/webcam/django/views.py
+++ b/optional-app/webcam/django/views.py
@@ -25,14 +25,16 @@ def index(request):
return HttpResponse(t.render(c))
def image(request):
+ global camera
http = HttpResponse(mimetype='image/jpeg')
if camera != None:
retval, img = camera.read()
cv2.imwrite(cwd + "django/tmp/tmp.jpg" , img)
ret_img = Image.open(cwd + "django/tmp/tmp.jpg")
- # img.save(http,'png')
- # img = Image.frombytes("RGB", (size_x, size_y), im)
ret_img.save(http,'JPEG')
+ else:
+ ret_img = Image.open(cwd + "django/tmp/cancel.png")
+ ret_img.save(http,'png')
return http
def open_camera(request):
@@ -44,7 +46,7 @@ def open_camera(request):
camera = cv2.VideoCapture(camera_port)
camera.set(cv.CV_CAP_PROP_FRAME_WIDTH,320)
camera.set(cv.CV_CAP_PROP_FRAME_HEIGHT,240)
- camera.set(cv.CV_CAP_PROP_FPS,1)
+ camera.set(cv.CV_CAP_PROP_FPS,10)
retval, img = camera.read() #light led
return HttpResponse(simplejson.dumps({'msg':'ok'}))
except:
@@ -52,7 +54,8 @@ def open_camera(request):
def close_camera(request):
global camera
- del(camera)
+ camera.release()
+ camera = None
return HttpResponse(simplejson.dumps({'msg':'ok'}))