Ejemplo n.º 1
0
    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
        }
Ejemplo n.º 2
0
    def __init__(self):
        self.cap = cv2.VideoCapture(0)
        self.fourcc = cv2.cv.CV_FOURCC(*'XVID')
        self.out = cv2.VideoWriter('data/' + subject + '/' + video +'/output.avi', -1, 9, (width, height))
        self.detector = dlib.get_frontal_face_detector()
        self.predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
        # 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}
Ejemplo n.º 3
0
 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
     
     #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 = 13.,
                                       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}
Ejemplo n.º 4
0
    def __init__(self, ip, user, password):
        #Imaging device - must be a connected camera (not an ip camera or mjpeg
        #stream)

        # self.camera = ipCamera(ip,
        # user=user,
        # password=password)
        self.camera = VideoFile(
            'C:\Users\Ashok Fernandez\Desktop\PulseDetector\Bill_Clinton.avi')
        self.w, self.h = 0, 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=25.,
                                          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
        }
Ejemplo n.º 5
0
    def __init__(self, filename=(sys.argv[1] if len(sys.argv) > 1 else None)):
        if filename is None:
            raise Exception("Filename unset")

        self.camera = VideoStream(filename=filename)  # first camera by default
        self.bpms = []

        # 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)

        while self.main_loop():
            sys.stderr.write(". ")
        sys.stderr.write("\n\n")
Ejemplo n.º 6
0
    def __init__(self,filename=(sys.argv[1] if len(sys.argv) > 1 else None)):
        if (filename is None):
            raise Exception("Filename unset")

        self.camera = VideoStream(filename=filename) #first camera by default
        self.bpms = []

        #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.)


        while (self.main_loop()):
            sys.stderr.write(". ")
        sys.stderr.write("\n\n")
from lib.processors import findFaceGetPulse
import networkx as nx

"""
Simple tool to visualize the design of the real-time image analysis

Everything needed to produce the graph already exists in an instance of the
assembly.
"""

#get the component/data dependancy graph (depgraph) of the assembly
assembly = findFaceGetPulse()
graph = assembly._depgraph._graph

#prune a few unconnected nodes not related to the actual analysis
graph.remove_node("@xin")
graph.remove_node("@xout")
graph.remove_node("driver")

#plot the graph to disc as a png image
ag = nx.to_agraph(graph)
ag.layout('dot')
ag.draw('design.png')
from lib.processors import findFaceGetPulse
import cv2
cam = cv2.VideoCapture(0)
image,frame = cam.read()
cam.release()
proc = findFaceGetPulse(bpm_limits = [50,160],
                                          data_spike_limit = 2500.,
                                          face_detector_smoothness = 10.) 
proc.frame_in = frame
proc.run()
output_frame = proc.frame_out
print output_frame
exit