Exemplo n.º 1
0
def nnw():
    det = Detector()
    global result
    while True:
        if(len(frame) != 0):
            result = det.process_img(frame)
Exemplo n.º 2
0
 def __init__(self):
     self.filename = "file.jpg"
     #modelPath = 'research/ssd_mobilenet_v1_coco_2017_11_17'
     self.objectDetection = Detector(self.filename)
Exemplo n.º 3
0
from PIL import Image
from flask import send_file
import time
from urllib.parse import unquote
def get_dataDict(data):
    data_dict={}
    for text in data.split("&"):
        key,value=text.split("=")
        value_1=unquote(value)
        data_dict[key]=value_1
    return data_dict


app = Flask(__name__)

detector = Detector()

# detector.detectNumberPlate('twocar.jpg')

@app.route("/")
def index():
    return render_template('index.html')


@app.route("/", methods=['POST'])
def upload():
    if request.method == 'POST':
        startTime=time.time()
        received_file = request.files['file']
        imageFileName = received_file.filename
        if received_file:
Exemplo n.º 4
0
import socket
import sys
import threading
import cv2
import numpy as np
import time
import copy
from ObjectDetector import Detector
from random import randint

det = Detector()
while True:
    then = time.time()
    path = "C:/Users/jalak/Desktop/car/Self-Driving-Car/production/drive/pics/0" + str(1021) + ".jpg"
    frame = cv2.imread(path,-1)
    result = det.process_img(frame)
    print(time.time() -then)
Exemplo n.º 5
0
from ObjectDetector import Detector
import io
from flask import Flask, render_template, request, send_from_directory, send_file, Response,jsonify
from PIL import Image
import requests
import os
import img_transforms
from flask_cors import CORS, cross_origin
from com_ineuron_firensmoke.com_ineuron_utils.utils import decodeImage

app = Flask(__name__)
detector = Detector(filename="file.jpg")

RENDER_FACTOR = 35

os.putenv('LANG', 'en_US.UTF-8')
os.putenv('LC_ALL', 'en_US.UTF-8')

app = Flask(__name__)
CORS(app)


# @cross_origin()
class ClientApp:
    def __init__(self):
        self.filename = "file.jpg"
        #modelPath = 'research/ssd_mobilenet_v1_coco_2017_11_17'
        self.objectDetection = Detector(self.filename)


def run_inference(img_path = 'file.jpg'):
Exemplo n.º 6
0
from flask import Flask, render_template, Response
import cv2
from ObjectDetector import Detector

app = Flask(__name__)
dect = Detector()
camera = cv2.VideoCapture(0)  # use 0 for web camera
#  for cctv camera use rtsp://username:password@ip_address:554/user=username_password='******'_channel=channel_number_stream=0.sdp' instead of camera


def gen_frames():  # generate frame by frame from camera
    while True:
        # Capture frame-by-frame
        success, frame = camera.read()  # read the camera frame
        frame = dect.detectObject(frame)
        if not success:
            break
        else:
            # ret, buffer = cv2.imencode('.jpg', frame)
            # frame = buffer.tobytes()
            yield (b'--frame\r\n'
                   b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n'
                   )  # concat frame one by one and show result


@app.route('/video_feed')
def video_feed():
    """Video streaming route. Put this in the src attribute of an img tag."""
    return Response(gen_frames(),
                    mimetype='multipart/x-mixed-replace; boundary=frame')
Exemplo n.º 7
0
def upload():
    if request.method == 'POST':
        file = Image.open(request.files['file'].stream) #ambil file
        file = file.resize((200,300), Image.ANTIALIAS) #resize , biar sesuai sama target size di tf
        det = Detector() 
        return(det.detectObject(file))#panggil fungsi detect ,parameter file yg di upload atau request via api
Exemplo n.º 8
0
import os
import cv2
from PIL import Image
from ObjectDetector import Detector

# frame
currentframe = 1
object_detector = Detector() 

# Read the video from specified path
cam = cv2.VideoCapture("VIRAT.mp4")   # VIRAT dataset
cam.set(cv2.CAP_PROP_FPS, 30)
fps = cam.get(cv2.CAP_PROP_FPS)

while True:
    # reading from frame
    ret, frame = cam.read()
    if ret:
        frame = Image.fromarray(frame, 'RGB')
        # video is still left continue creating images
        object_detector.ROI(frame)
        currentframe += 1
    else:
        break

# Release all space and windows once done
object_detector.release()
cam.release()
cv2.destroyAllWindows()
Exemplo n.º 9
0
def video_feed():
    return Response(gen(Detector()),
                    mimetype='multipart/x-mixed-replace; boundary=frame')
Exemplo n.º 10
0
from ObjectDetector import Detector
import io

from flask import Flask, render_template, request

from PIL import Image
from flask import send_file

app = Flask(__name__)

detector1 = Detector()


# detector.detectNumberPlate('twocar.jpg')


@app.route("/")
def index():
    return render_template('index.html')


if __name__ == "__main__":
    app.run()