def __init__(self): self.firebase = firebase.FirebaseApplication( 'https://hackhealth-c0852.firebaseio.com', None) result = self.firebase.get('/Rooms/room2', None) sessionID = result['sessionID'] tokenID = result['token'] self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" self.key_controls = { "s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam } # self.vidcap = cv2.VideoCapture(0) output = Popen([ './sdlexample', '-a', '46113352', '-s', sessionID, '-t', tokenID, '-d', 'patient' ], stdout=PIPE) size = (480, 640) self.vidcap = VideoCaptureYUV(output.stdout, size)
def __init__(self, args): # assumes connected camera uses cam0 by default serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) # self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = {#"s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, "f": self.write_csv}
def __init__(self): #Imaging device - must be a connected camera (not an ip camera or mjpeg #stream) self.camera = Camera(camera=0) #first camera by default self.w,self.h = 0,0 self.pressed = 0 #Containerized analysis of recieved image frames (an openMDAO assembly) #is defined next. #This assembly is designed to handle all image & signal analysis, #such as face detection, forehead isolation, time series collection, #heart-beat detection, etc. #Basically, everything that isn't communication #to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits = [50,160], data_spike_limit = 2500., face_detector_smoothness = 10.) #Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Cardiac info - raw signal, filtered signal, and PSD" #Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = {"s" : self.toggle_search, "d" : self.toggle_display_plot, "f" : self.write_csv}
def __init__(self, args, camera_obj): super(getPulseApp, self).__init__() # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 camera = camera_obj self.cameras.append(camera) self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.bpm = 0 self.frame_count = 0 self.frames_with_face = 0
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = { "s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, "f": self.write_csv }
def __init__(self, args, camera_obj): super(getPulseApp, self).__init__() # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Internet # UDP self.cameras = [] self.selected_cam = 0 camera = camera_obj self.cameras.append(camera) self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500.0, face_detector_smoothness=10.0) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods # (A GUI window must have focus for these to work) self.bpm = 0 self.frame_count = 0 self.frames_with_face = 0
def __init__(self, args): #tried to use droidcam from playstore,this won't work like that serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" self.key_controls = { "s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, "f": self.write_csv }
def toggle_search(self): """ Toggles a motion lock on the processor's face detection component. Locking the forehead location in place significantly improves data quality, once a forehead has been sucessfully isolated. """ #state = self.processor.find_faces.toggle() # state = self.processor.find_faces_toggle() # print("face detection lock =", not state) self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.)
def __init__(self, args): self.COUNTER = 0 self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) self.plot_title = "Real-Time Heart Rate"
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud name = args.name self.send_serial = False self.send_udp = False self.name = name self.fileName = [] # print(name) self.cameras = [] self.selected_cam = 0 for i in xrange(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 self.writeCSV = False # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = {"s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, "f": self.write_csv}
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = { "s": self.toggle_search, "d": self.toggle_display_plot }
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 for i in xrange(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 # procesamiento de imagenes, parametros self.processor = findFaceGetPulse(bpm_limits=[50, 160],data_spike_limit=2500.,face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods self.key_controls = {"s": self.toggle_search,"c": self.toggle_cam}
def __init__(self): self.w, self.h = 0, 0 self.pressed = 0 self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # print(self.processor.dpath) self.flag_end = False # if "Ctrl + e" is pressed on the GUI it will be True --> end program # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods # (A GUI window must have focus for these to work) self.key_controls = {"s": self.toggle_search, "d": self.toggle_display_plot}
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) self.key_controls = {}
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 for i in xrange(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = {"s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, "f": self.write_csv}
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud self.send_serial = False self.send_udp = False self.video_flag = False if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP self.cameras = [] self.selected_cam = 0 for i in range(3): camera = Camera(camera=i) # first camera by default if camera.valid or not len(self.cameras): self.cameras.append(camera) else: break self.w, self.h = 0, 0 self.pressed = 0 # Containerized analysis of received image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods #(A GUI window must have focus for these to work) self.key_controls = { "s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, "f": self.write_csv, "v": self.toggle_video } self.video = cv2.VideoCapture('video1.avi') #self.video.set(cv2.CAP_PROP_FPS, 16) self.csvn = "Webcam-pulse" fps = self.video.get(cv2.CAP_PROP_FPS) print "Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format( fps) #Creates a blank image of 200x200 size to initialise self.irframe blank_image = np.zeros((400, 400, 3), np.uint8) self.irframe = blank_image #self.irframe = None self.callbackFlag = False
def __init__(self, args): # Imaging device - must be a connected camera (not an ip camera or mjpeg # stream) serial = args.serial baud = args.baud video = args.video self.Tx = False self.environment = [] self.ser = None self.kill = False self.vidname = "" self.send_serial = False self.send_udp = False self.question_number = "-1" if serial: self.send_serial = True if not baud: baud = 9600 else: baud = int(baud) self.serial = Serial(port=serial, baudrate=baud) udp = args.udp if udp: self.send_udp = True if ":" not in udp: ip = udp port = 5005 else: ip, port = udp.split(":") port = int(port) self.udp = (ip, port) self.sock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP if video: self.vidname = video self.cameras = [] self.selected_cam = 0 if args.url is not None: camera = Camera(camera=args.url) self.cameras.append(camera) elif args.video_dir is None: # Real-time for camera=0, read from one video # first camera by default camera = Camera(camera=0, vid=self.vidname) if camera.valid or not len(self.cameras): self.cameras.append(camera) else: print('Error: No camera was found') else: # read all videos from a directory in a sequence self.video_names = glob.glob(args.video_dir + '/*.mp4') self.video_names.sort() for i in range(len(self.video_names)): # start from the first video camera = Video(vid=self.video_names[i]) if camera.valid or not len(self.cameras): self.cameras.append(camera) self.w, self.h = 0, 0 # self.record = False self.sz = (int(self.cameras[self.selected_cam].cam.get( cv2.CAP_PROP_FRAME_WIDTH)), int(self.cameras[self.selected_cam].cam.get( cv2.CAP_PROP_FRAME_HEIGHT))) self.fourcc = cv2.VideoWriter_fourcc(*'MP4V') self.fps = 25 self.q = 0 # self.out = None self.pressed = 0 # Containerized analysis of recieved image frames (an openMDAO assembly) # is defined next. # This assembly is designed to handle all image & signal analysis, # such as face detection, forehead isolation, time series collection, # heart-beat detection, etc. # Basically, everything that isn't communication # to the camera device or part of the GUI self.processor = findFaceGetPulse(bpm_limits=[50, 160], data_spike_limit=2500., face_detector_smoothness=10.) self.processor.init_temp = args.init_temp # Init parameters for the cardiac data plot self.bpm_plot = False self.plot_title = "Data display - raw signal (top) and PSD (bottom)" # Maps keystrokes to specified methods # (A GUI window must have focus for these to work) self.key_controls = { "s": self.toggle_search, "d": self.toggle_display_plot, "c": self.toggle_cam, # "g": self.start_record, # "f": self.stop_record }