Skip to content

Commit

Permalink
v0.2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
wzyy2 committed Jan 12, 2015
1 parent a08797b commit ea91bff
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion optional-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ How to install depends on app.<br>

# 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)
6 changes: 4 additions & 2 deletions optional-app/webcam/django/html/webcam.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
}
});
}
$("#surface").attr('src', "temp.jpg?t=" + Math.random());
});
});
$("#refresh").click( function(){
Expand Down Expand Up @@ -82,8 +83,9 @@ <h1>
</center>
</div>
<div class="row">
<center>
<img id="surface" src="temp.jpg" style="margin-top: 60px;"></img>
<center style="margin-top: 60px;">
<h1>snapshot<h1>
<img id="surface" src="temp.jpg" style="margin-top: 20px;"></img>
</center>
</div>

Expand Down
Binary file added optional-app/webcam/django/tmp/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions optional-app/webcam/django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -44,15 +46,16 @@ 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:
return HttpResponse(simplejson.dumps({'msg':'fail'}))

def close_camera(request):
global camera
del(camera)
camera.release()
camera = None
return HttpResponse(simplejson.dumps({'msg':'ok'}))


Expand Down

0 comments on commit ea91bff

Please sign in to comment.