Ejemplo n.º 1
0
 def __init__(self):
     # Using OpenCV to capture from device 0. If you have trouble capturing
     # from a webcam, comment the line below out and use a video file
     # instead.
     # self.video = cv2.VideoCapture(0)
     self.video = cv2.VideoCapture(cameraIPURL)
     self.motionDetector = MotionDetector()
Ejemplo n.º 2
0
def main():
    logging.basicConfig(level=logging.INFO)
    puntosHomography = []

    config = FileReader(parse_args().config_file)

    image_file = config.getProp('image_file')
    video_file = config.getProp('video_file')
    data_file = config.getProp('data_file')
    start_frame = int(config.getProp('start_frame'))
    folder_photos = config.getProp('folder_photos')
    folder_photos_mobile = config.getProp('folder_photos_mobile')

    response = login().json()
    question1 = "¿Quiere configurar los estacionemiento? Escriba S/N!"
    if (QuestionInput.realize(question1)):
        drawCoordinates(image_file, data_file, response['token'])
    else:
        print("Bicicleteros:")
        res = getAllBicycleParkings(response['token'])
        question1_2 = "Elija un número de bicicletero existente:"
        if (QuestionInput.realizeNumberBicycle(question1_2) == 1):
            data_file = config.getProp('cache_data_file')

    question2 = "¿Quiere configurar con homografia el estacionemiento? Escriba S/N!"
    if (QuestionInput.realize(question2)):
        puntosHomography = get_image_homography(image_file)

    with open(data_file, "r") as data:
        points = yaml.load(data)
        #response = login().json()
        detector = MotionDetector(video_file, points, int(start_frame),
                                  folder_photos, response['token'],
                                  folder_photos_mobile)
        detector.detect_motion(puntosHomography)
def frameProcessor(queue):
    #processes and deals with motion capture
    out = DatasetSaver("test/testPic",
                       mode='picture',
                       maxPics=1000,
                       maxSpaceMb=20,
                       debug=dataset_config.debug)
    detector = MotionDetector(minMovementArea=dataset_config.min_area,
                              debug=dataset_config.debug)
    prev_frame = None

    while True:
        frame = queue.get(
            True)  #True -> block until there is a frame in the queue

        if prev_frame is None:
            prev_frame = frame
            continue
        if detector.isMovement(prev_frame, frame):
            if dataset_config.show:
                cv2.imshow("Saved_Frame", frame)
            out.write(frame)

        prev_frame = frame

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    out.release()  #Doesn't do anything since it's picture mode
    cv2.destroyAllWindows()
Ejemplo n.º 4
0
 def test_right_swipe2(self):
     logger.info("Testing Right Swipe2")
     md = MotionDetector("ZoeticRightSwipe2")
     md.update([20, 20, 20, 2000, 20, 20])
     md.update([20, 20, 20, 2000, 20, 20])
     md.update([20, 20, 20, 2000, 20, 20])
     md.update([2000, 2000, 20, 20, 20, 20])
     md.update([2000, 2000, 20, 20, 20, 20])
     md.update([20, 20, 20, 20, 2000, 20])
     del md
Ejemplo n.º 5
0
 def test_left_swipe(self):
     logger.info("Testing Left Swipe")
     md = MotionDetector("ZoeticLeftSwipe")
     md.update([20, 20, 20, 20, 2000, 20])
     md.update([2000, 2000, 20, 20, 20, 20])
     md.update([20, 20, 20, 2000, 20, 20])
     del md
Ejemplo n.º 6
0
 def test_delayed_swipe(self):
     logger.info("Testing Delayed Swipe")
     md = MotionDetector("ZoeticDelayedSwipe")
     md.update([20, 20, 20, 2000, 20, 20])
     time.sleep(0.5)
     md.update([2000, 2000, 20, 20, 20, 20])
     time.sleep(0.5)
     md.update([20, 20, 20, 20, 2000, 20])
     del md
     logger.info("\n\n")
Ejemplo n.º 7
0
class VideoCamera(object):
    def __init__(self):
        # Using OpenCV to capture from device 0. If you have trouble capturing
        # from a webcam, comment the line below out and use a video file
        # instead.
        # self.video = cv2.VideoCapture(0)
        self.video = cv2.VideoCapture(cameraIPURL)
        self.motionDetector = MotionDetector()

    def __del__(self):
        self.video.release()

    def get_frame(self):
        ret, frame = self.video.read()
        detectFrame = self.motionDetector.detect(frame)
        ret, jpeg = cv2.imencode('.jpg', detectFrame)
        return jpeg.tobytes()

    def save_frame_to_image(self, path):
        ret, frame = self.video.read()
        try:
            cv2.imwrite(path, frame)
        except IOError:
            pass
Ejemplo n.º 8
0
import time
from networkConnection import NetworkConnection
from motionDetector import MotionDetector
from broker import Broker

DETECTOR_PIN = 34

connection = NetworkConnection()
connection.do_connect()
print("is connected: " + str(connection.isConnected()))
motionDetector = MotionDetector(DETECTOR_PIN)
broker = Broker()

while True:
    time.sleep(1)
    if not connection.isConnected():
        connection.do_connect()
    if motionDetector.check() == True:
        broker.objectDetected()
    

Ejemplo n.º 9
0
#!/usr/bin/env python

import sys
import Image
import ImageChops

from motionDetector import MotionDetector
from Filters.filter import Filter
from Filters.erosion import ErosionFilter
from Filters.difference import DifferenceFilter
from Filters.threshold import ThresholdFilter

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print 'Usage:', sys.argv[0], '<image1> <image2'
        sys.exit(1)
    
    motion = MotionDetector(sys.argv[1])
    motion.launchCPU()
Ejemplo n.º 10
0
from motionDetector import MotionDetector

from dataset_config import save_location, min_area, show, debug

###Setting up IP camera
os.system("sudo /home/nvidia/setup_camera.sh")

#cap = cv2.VideoCapture('rtsp://*****:*****@169.254.132.241:554/h264/ch1/main/av_stream')
cap = RobustCamera(0)
out = DatasetSaver(
    "test/testPics",  # should become test/testPic_0 etc
    mode='picture',
    maxPics=1000,
    maxSpaceMb=100,
    debug=debug)  # 100mb
detector = MotionDetector(minMovementArea=min_area, debug=debug)

#backgroundFrame = cv2.imread("backgroundImage.jpg")
prev_frame = None  # for motion detection

while True:
    #out = cv2.VideoWriter('video_' + str(start_count) + "_" + dt_string + '.avi',cv2.VideoWriter_fourcc('D','I','V','X'), 30, (1280,720))
    #out = cv2.VideoWriter(video_string_name, cv2.VideoWriter_fourcc('D','I','V','X'), 30, (1280,720))

    ret, frame = cap.read()
    frame = cv2.resize(frame, (1280, 720))
    #height, width = frame.shape[:2]

    if prev_frame is None:
        prev_frame = frame  #so that prev_frame is not none
        continue