python - Not able to save captured image in right directory -


i working on project related image processing. capture image webcam , want display on webpage. using django framework web stuff.

program capture image webcam in views.py:

from django.shortcuts import render django.views.decorators.csrf import csrf_exempt import cv2  def home(request):     return render(request,'detect/home.html',{})  def get_image(camera):     retval, im = camera.read()     return im  def webcam():     camera_port = 0     ramp_frames = 30     camera = cv2.videocapture(camera_port)     in xrange(ramp_frames):         temp = get_image(camera)     print("taking image...")     camera_capture = get_image(camera)     file = "/detect/static/test_image.png"     cv2.imwrite(file, camera_capture)     del(camera)  @csrf_exempt def display(request):     webcam()     return render(request,'detect/display.html',{}) 

here screenshot of directory structure: enter image description here

if don't mention path , include name of image file(file = "test_image.png"), image gets saved in /moody/project. save image in /moody/project/detect/static/.

use fullpath / or relative path current dir, using dot ('.') before first '/' in filepath.

file = "./detect/static/test_image.png" 

Comments

Popular posts from this blog

php - isset function not working properly -

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -