コード例 #1
0
def setPoints(frame):
    if path.exists('images/p1.png'):
        os.remove('images/p1.png')
    cv.imwrite('images/p1.png', frame)
    with open('data/coordinates_1.yml', "w+") as points:
        generator = CoordinatesGenerator('images/p1.png', points, COLOR_RED)
        generator.generate()
コード例 #2
0
def main():
    logging.basicConfig(level=logging.INFO)

    cap = cv2.VideoCapture("./videos/sample1.mp4")

    ret, frame = cap.read()
    #cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
    #cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
    cv2.imwrite('test111.jpg', frame)


    start_frame = "4000"
    image_file = "./images/parking_lot_1.png"
    test_image = "test111.jpg"
    data_file = "./data/coordinates_1.yml"
    video_file = "./videos/sample1.mp4"
    #video_url = "parking_lot_1.mp4"
    video_url = "C:/Users/YHJ/PycharmProjects/parkingLot/DetectParking-develop/ParkingLot-master/parking_lot/videos/sample1.mp4"



    if image_file is not None:
        with open(data_file, "w+") as points:

            generator = CoordinatesGenerator(test_image, points, COLOR_RED)
            generator.generate()

    with open(data_file, "r") as data:
        points = yaml.load(data , Loader=yaml.FullLoader)
        print(points)
        detector = MotionDetector(video_file, points, int(start_frame))
        detector.detect_motion()
        print("sdfs")
コード例 #3
0
ファイル: main.py プロジェクト: ujjaldas132/parking-spot
def main():
    logging.basicConfig(level=logging.INFO)

    # args = parse_args()

    image_file = "images/parking_lot_1.png"  #args.image_file
    data_file = "data/coordinates_1.yml"  #args.data_file
    start_frame = 0  #args.start_frame

    if image_file is not None:
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points, COLOR_RED)
            generator.generate()
        storeCor = open("data\\pastCordinate.pickle", 'wb')

        # source, destination
        pickle.dump(generator.saveCordinate, storeCor)
        storeCor.close()
        print(generator.saveCordinate)
        logging.info(generator.saveCordinate)

    with open(data_file, "r") as data:
        points = yaml.load(data)
        # points = load(data, Loader=yaml.Loader)
        # detector = MotionDetector(args.video_file, points, int(start_frame))
        detector = MotionDetector("videos/parking_lot_1.mp4", points,
                                  int(start_frame))
        #pass the spot no which you want to spot
        # in image the spotno are 1 index
        spotNo = 0
        detector.detect_motion(spotNo)
コード例 #4
0
def main():
    args = parse_args()
    image_file = args.image_file
    data_file = args.data_file

    if image_file is not None:
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points, COLOR_RED)
            generator.generate()
コード例 #5
0
ファイル: generatePark.py プロジェクト: azseza/openCV
def main():
    args = prase_args()

    image = args.image

    print("image is good")
    with open('test.yaml', "w+") as file:
        header = "---\n"
        file.write(header)
        genrator = CoordinatesGenerator(image, file, COLOR_RED)
        genrator.generate()
コード例 #6
0
def main():

    print('main executed')
    logging.basicConfig(level=logging.INFO)

    image_file = "images/parking_lot_1.png"
    data_file = "data/coordinates_1.yml"
    start_frame = 400
    video_file = "videos/parking_lot_1.mp4"

    f = open("config.txt", "r")
    arr = {}
    for _ in range(0, 2):
        result = f.readline()
        arr[result.split(' : ')[0]] = result.split(' : ')[-1].split('\n')[0]
    print(arr)
    f.close()
    url = arr['img_url']

    img_resp_pic = requests.get(url)
    img_arr_pic = np.array(bytearray(img_resp_pic.content), dtype=np.uint8)
    img1_pic = cv2.imdecode(img_arr_pic, -1)
    filename = 'savedImage.jpg'
    cv2.imwrite(filename, img1_pic)

    #cv2.imshow("AndroidCamPic",img1_pic)
    #cv2.waitKey(0)==27

    #cv2.destroyWindow("AndroidCamPic")
    '''while True:
        img_resp= requests.get(url)
        img_arr= np.array(bytearray(img_resp.content),dtype=np.uint8)
        img = cv2.imdecode(img_arr, -1)
        
        cv2.imshow("AndroidCam",img)
        
        if cv2.waitKey(1)==27:
             break
    cv2.destroyWindow("AndroidCamPic")'''
    if filename is not None:
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(filename, points, COLOR_RED)
            generator.generate()

    with open(data_file, "r") as data:
        '''try:
            thread.start_new_thread( MotionDetector, ( ) )
            thread.start_new_thread( alpr, ( ) )
        except:
            print("Error: unable to start thread")'''
        points = yaml.load(data)
        detector = MotionDetector(video_file, points, int(start_frame))
        detector.detect_motion()
コード例 #7
0
def main():
    
    logging.basicConfig(level=logging.INFO)

    args = parse_args()

    image_file = args.image_file
    data_file = args.data_file
    start_frame = args.start_frame
    
    if image_file is not None:
            with open(data_file, "w+") as points:
                generator = CoordinatesGenerator(image_file, points, COLOR_RED)
                generator.generate()
    
    while(1>0) :
        
        capture_duration = 10
        
        cap = cv2.VideoCapture(1)
        
        start_time = time.time()

        if(cap.isOpened()== False):
            print("error")
        fourcc = cv2.VideoWriter_fourcc(*'mp4v')
        out = cv2.VideoWriter('videos/output.mp4', -1, 20.0, (640,480))
        
        while(int(time.time() - start_time) < capture_duration):
            ret, frame = cap.read()
            if ret == True:
                out.write(frame)
                cv2.imshow('Frame',frame)
                if cv2.waitKey(1) & 0xFF == ord('q'):
                    break
            else:
                break
        cap.release()
        out.release()
        cv2.destroyAllWindows()
        
          
        

        with open(data_file, "r") as data:
            points = yaml.load(data,Loader=yaml.FullLoader)
            
            #CALL MotionDetector from motion_detector.py
            detector = MotionDetector(args.video_file, points, int(start_frame))
            detector.detect_motion()
コード例 #8
0
ファイル: main.py プロジェクト: Avinash987/Deep_Learning
def main():
    logging.basicConfig(level=logging.INFO)

    image_file = "images/parking_lot_1.png"
    data_file = "data/coordinates_1.yml"
    start_frame = 400
    video_file = "videos/parking_lot_1.mp4"

    if image_file is not None:
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points, COLOR_RED)
            generator.generate()

    with open(data_file, "r") as data:
        points = yaml.load(data)
        detector = MotionDetector(video_file, points, int(start_frame))
        detector.detect_motion()
コード例 #9
0
def read_name(name):
    global video_name
    video_name = name

    file_list = glob.glob('videos/*.*')
    for x in file_list:
        f = x.lstrip('videos\\\\').rstrip('.mp4')
        if f == video_name:
            video_file = 'videos/' + video_name + '.mp4'
            image_file = get_first_frame(video_name, video_file)
            data_file = 'data/' + video_name + '.yml'
            if image_file is not None:
                with open(data_file, "w+") as points:
                    generator = CoordinatesGenerator(image_file, points,
                                                     COLOR_RED)
                    generator.generate()
            return 'success'
        return ''
コード例 #10
0
def main():
    logging.basicConfig(level=logging.INFO)

    args = parse_args()

    image_file = args.image_file
    data_file = args.data_file
    start_frame = args.start_frame

    if image_file is not None:
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points, COLOR_RED)
            generator.generate()

    with open(data_file, "r") as data:
        points = yaml.safe_load(data)
        detector = MotionDetector(args.video_file, points, int(start_frame))
        detector.detect_motion()
コード例 #11
0
ファイル: main.py プロジェクト: lsalazar1/ParkingLot
def main():
    logging.basicConfig(level=logging.INFO)

    args = parse_args()

    image_file = args.image_file
    data_file = args.data_file
    start_frame = args.start_frame

    # If image file is provided, prompt user to generate rectangles
    if image_file is not None:
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points, COLOR_RED)
            generator.generate()

    # Read coordinates_1.yml in...
    with open(data_file, "r") as data:
        points = yaml.load(data)
        detector = MotionDetector(args.video_file, points, int(start_frame))
        detector.detect_motion()
コード例 #12
0
ファイル: main.py プロジェクト: legoblocks/ParkingLot
def main():
    logging.basicConfig(level=logging.INFO)

    args = parse_args()

    image_file = args.image_file
    data_generate_file = args.data_generate_file
    data_file = args.data_file
    video_file = args.video_file
    start_frame = args.start_frame

    # generate coordinate based data map.
    if image_file is not None and args.data_generate_file:
        with open(data_generate_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points, COLOR_RED)
            generator.generate()

    # read from coordinate data map
    if data_file is not None and video_file is not None:
        with open(data_file, "r") as data:
            #points = yaml.load(data)
            points = yaml.safe_load(data)
            detector = MotionDetector(video_file, points, int(start_frame))
            detector.detect_motion()
コード例 #13
0
def createyaml():
    data_file = "data.yaml"
    try:
        File = open(data_file)
        File.close
    except FileNotFoundError:
        File = open(data_file, 'w')
        File.close
        print("IOError")
    cap = cv2.VideoCapture(VIDEO)

    if cap.isOpened():
        for i in range(30):
            read_flag, img = cap.read()
        cv2.imwrite("image.png", img)
        cap.release()
        image_file = "image.png"
        with open(data_file, "w+") as points:
            generator = CoordinatesGenerator(image_file, points,
                                             colors.COLOR_RED)
            generator.generate()
            start.configure(state=NORMAL)
    else:
        print("Error. Video camera not connected")