This question has been flagged
1 Reply
12250 Views

I'm beginner in odoo.

I want create module live stream rtsp in odoo (ip camera)

I tried stream rtsp python using opencv and Flask. It working.

Now, I try with odoo but not working. I think function url_for("function_name") not working 
Does this exist in Odoo? I can't find it or any alternatives.

Code with open cv and Flask
- camera.py

import cv2

class VideoCamera(object):

def __init__(self):

self.video = cv2.VideoCapture("rtsp://192.168.137.71:8080/h264_pcm.sdp")

def __del__(self):

self.video.release()

def get_frame(self):

success, image = self.video.read()

# We are using Motion JPEG, but OpenCV defaults to capture raw images,

# so we must encode it into JPEG in order to correctly display the

# video stream.

ret, jpeg = cv2.imencode('.jpg', image)

return jpeg.tobytes()


- main.py

from flask import Flask, render_template, Response

from camera import VideoCamera

app = Flask(__name__)

@app.route('/')

def index():

return render_template('index.html')

def gen(camera):

while True:

frame = camera.get_frame()

yield (b'--frame\r\n'

b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')

@app.route('/video_feed')

def video_feed():

return Response(gen(VideoCamera()),

mimetype='multipart/x-mixed-replace; boundary=frame')

if __name__ == '__main__':

app.run(host='0.0.0.0', debug=True)

- index.html


<html>

<head>

<title>Video Streaming</title>

</head>

<body style="margin:0px">

<img style="width:100%;height: 100%;" id="bg" src="{{ url_for('video_feed') }}">

</body>

</html>

thank you very much.

Avatar
Discard
Best Answer

hi james did you solve this issue?

Avatar
Discard