Not able to save captured image in right directory
<p>I am working on a project related to image processing. I would like to capture an image from a webcam and want to display it on webpage. I am using django framework for web stuff. </p>

<p>Program to capture image from webcam in views.py:</p>

<pre><code>from django.shortcuts import render
from 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)
    for i 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',{})
</code></pre>

<p>Here is a screenshot of my directory structure:
<a href="http://i.stack.imgur.com/OneNO.png" rel="nofollow"><img src="http://i.stack.imgur.com/OneNO.png" alt="enter image description here"></a></p>

<p>If I don't mention any path and only include the name of the image file(file = "test_image.png"), the image gets saved in /moody/project.
I would like to save image in /moody/project/detect/static/.</p>

<p>Use the fullpath from / or the relative path from your current dir, using a dot ('.') before the first '/' in the filepath.</p>

<pre><code>file = "./detect/static/test_image.png"
</code></pre>

python django opencv