Menu

[Solved]-Trying Program Code Capture Image Camera Webpage Using Python Flask Server Getting Errors Q37249975

i am trying to program a code that will capture image from thecamera through a webpage by using python and flask server but i amgetting some errors

the webpage works fine but when i press capture it breaks andgives me error

here is the code and i highlighted where the error is and therest is correct:

from flask import Flask, render_template, request, redirect,url_for, make_response
import abd
import RPi.GPIO as GPIO
import picamera #import PiCamera
#from time import sleep

app = Flask(__name__)
app._static_folder = “/home/pi/hope”
@app.route(‘/’)
def index():

        returnrender_template(‘index.html’)
@app.route(‘/<changepin>’, methods=[‘POST’])
def reroute(changepin):

        changePin =int(changepin)

        if changePin ==1:
               abd.stop()
        elif changePin ==2:
               abd.left()
        elif changePin ==3:
               abd.right()
        elif changePin ==4:
               abd.forward()
        elif changePin ==5:
               abd.reverse()
        elif changePin ==9:
               abd.up()
        elif changePin ==10:
                       abd.down()
        else:
               abd.stop()
        response =make_response(redirect(url_for(‘index’)))
        return(response)
@app.route(‘/snap/’)
def snap():
        with picamera.PiCamera()as camera:camera.capture(‘drone.jpg’)
        returnapp.send_static_file(‘drone’)

        #response =make_response(redirect(url_for(‘index’)))
        #return(response)

app.run(debug=True, host=’0.0.0.0′, port=8000)

——–

this is the error message:

mmal: mmal_vc_port_enable: failed to enable portvc.null_sink:in:0(OPQV): ENOSPC
mmal: mmal_port_enable: failed to enable connected port(vc.null_sink:in:0(OPQV))0x7570b530 (ENOSPC)
mmal: mmal_connection_enable: output port couldn’t be enabled
172.20.10.3 – – [22/Apr/2019 23:52:55] “GET /snap/ HTTP/1.1” 500-
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1997, in__call__
    return self.wsgi_app(environ,start_response)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1985, inwsgi_app
    response = self.handle_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1540, inhandle_exception
    reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1982, inwsgi_app
    response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1614, infull_dispatch_request
    rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1517, inhandle_user_exception
    reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1612, infull_dispatch_request
    rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1598, indispatch_request
    returnself.view_functions[rule.endpoint](**req.view_args)
File “/home/pi/hope/app.py”, line 39, in snap
    with picamera.PiCamera() ascamera:camera.capture(‘drone.jpg’)
File “/usr/share/pyshared/picamera/camera.py”, line 433, in__init__
    self._init_preview()
File “/usr/share/pyshared/picamera/camera.py”, line 513, in_init_preview
    self,self._camera.outputs[self.CAMERA_PREVIEW_PORT])
File “/usr/share/pyshared/picamera/renderers.py”, line 558, in__init__
   self.renderer.inputs[0].connect(source).enable()
File “/usr/share/pyshared/picamera/mmalobj.py”, line 2212, inenable
    prefix=”Failed to enable connection”)
File “/usr/share/pyshared/picamera/exc.py”, line 184, inmmal_check
    raise PiCameraMMALError(status, prefix)
PiCameraMMALError: Failed to enable connection: Out ofresources
172.20.10.3 – – [22/Apr/2019 23:52:55] “GET/snap/?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1″200 –
172.20.10.3 – – [22/Apr/2019 23:52:55] “GET/snap/?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1″200 –
172.20.10.3 – – [22/Apr/2019 23:52:55] “GET/snap/?__debugger__=yes&cmd=resource&f=debugger.jsHTTP/1.1” 200 –
172.20.10.3 – – [22/Apr/2019 23:52:55] “GET/snap/?__debugger__=yes&cmd=resource&f=console.pngHTTP/1.1” 200 –

Expert Answer


Answer to i am trying to program a code that will capture image from the camera through a webpage by using python and flask server… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *