def __init__(self): ''' this function initiate the data_receiver class ''' # latent partameters self.dir_offset = 120 self.voice_width = np.pi / 2 ## initiate tty receiver self.opencv_version = int(cv.__version__[0]) ## set fisheye camera params self.image_width = 1280 self.image_height = 960 self.cx = self.image_width / 2 self.cy = self.image_height / 2 self.R1 = 100 self.R2 = self.cy self.map_x = None self.map_y = None self.voice_width = int(self.voice_width / 2 / np.pi * self.image_width) self.output_width = int(2.0 * ((self.R2 + self.R1) / 2) * np.pi) self.output_height = int(self.R2 - self.R1) self.final_height = self.output_height * 2 self.scene_center = int(self.output_width / 2) self.build_map(self.image_width, self.image_height, self.output_width, self.output_height, self.R1, self.R2, self.cx, self.cy) # initiate the image receiver ## add all the camera capture into list self.cam_capture = cv.VideoCapture('/dev/video0') self.cam_capture.set(cv.CAP_PROP_FRAME_WIDTH, self.image_width) self.cam_capture.set(cv.CAP_PROP_FRAME_HEIGHT, self.image_height) self.cam_capture.set(cv.CAP_PROP_FOURCC, cv.VideoWriter.fourcc('M', 'J', 'P', 'G')) self.ret = None self.frame = None self.audio_frame = None self.dewarping_frame = None self.final_frame = np.zeros((self.final_height, self.output_width, 3)) # define face detector self.face_detector = cv.CascadeClassifier( 'haarcascade_frontalface_default.xml') self.faces = None self.face_detection_state = 1 self.face_detection_thread = None self.virtual_webcam = streamer.Streamer('/dev/video6', self.output_width, self.final_height) self.virtual_webcam.start() # load audio detection self.vad = webrtcvad.Vad(3) self.speech_count = 0 self.chunks = [] self.doa_chunks = int(DOA_FRAMES / VAD_FRAMES) self.direction = 0 self.availability = 0 self.audio_thread = threading.Thread(target=self.audio_processing) print('data receiver initiated')
def __init__(self): self.settings = settings.Settings() list.__init__( self, [ Channel("BBC TV", "tv", self.settings), Channel("ITV", "itv", self.settings), # Channel("Channel 4", "ch4", self.settings), # Channel("Five", "five", self.settings), # Channel("BBC Podcasts", "podcast", self.settings), Channel("BBC Radio", "radio", self.settings), # Channel("Hulu", "hulu", self.settings), ]) self.downloader = downloader.Downloader(self.settings) self.streamer = streamer.Streamer(self.settings)
def play_channel(self, request_stream): xml_streamer = self.get_data_(self.PLAY_CHANNEL_CMD_, request_stream.to_xml()) if xml_streamer == None or len(xml_streamer) == 0: raise DVBLinkError(DVBLinkStatus.STATUS_INVALID_DATA) return streamer.Streamer(xml_streamer)
def toc(): import time if 'startTime_for_tictoc' in globals(): return time.time() - startTime_for_tictoc """ getFirstImage(path) im = cv2.imread('frame0.jpg') plt.imshow(im) plt.show() """ path = '/media/aviv/DC5C192D5C190444/ourCam25_3_24' ster = streamer.Streamer(path, 10) for i in range(2200): im = ster.getNext() im = ster.getNext() matplotlib.pyplot.imshow(im) matplotlib.pyplot.show() #location of the traffic light in the first frame up, down, left, right = 280, 340, 581, 603 template = im[up:down, left:right] matplotlib.pyplot.imshow(template) matplotlib.pyplot.show() diff = [0, 0] imClone = im.copy() for i in range(900):
def __init__(self, ffmpeg, *args): webserver.Server.__init__(self, *args, request_class=APIRequest) self.control = Control() self.fifo = util.FIFO() self.streamer = streamer.Streamer(ffmpeg)
def __init__(self, parent, debug=False, name=None, bindIp='0.0.0.0', bindPort=0, destinationIp='', destinationHost='', destinationPort=0, socketFamily=AdapterIP.IPv4, logHighLevelEvents=True, logLowLevelEvents=False, recordRcvSound=False, recordSndSound=False, payloadType=SutLibraries.Codecs.A_G711U, defaultSound=SOUND_SINE_1K, rtpVersion=2, initialSeqNumber=None, ssrcValue=None, inactivityTimeout=2.0, sessionId=None, agentSupport=False, agent=None, shared=False): """ Raw RTP client. This class inherit from the UDP adapter. @param parent: parent testcase @type parent: testcase @param name: adapter name used with from origin/to destination (default=None) @type name: string/none @param bindIp: bind on ip @type bindIp: string @param bindPort: bind on port @type bindPort: integer @param destinationIp: destination ip @type destinationIp: string @param destinationPort: destination port @type destinationPort: integer @param destinationHost: destination host @type destinationHost: string @param logHighLevelEvents: log high level events (default=True) @type logHighLevelEvents: boolean @param logLowLevelEvents: log low level events (default=False) @type logLowLevelEvents: boolean @param recordRcvSound: bufferize the sound received and save the RTP flow in a rtp file. If the codec is supported then the flow is saved in a wave file. @type recordRcvSound: boolean @param recordSndSound: bufferize the sound sent and save the RTP flow in a rtp file. If the codec is supported then the flow is saved in a wave file. @type recordSndSound: boolean @param payloadType: SutLibraries.Codecs.A_G711U (default) | SutLibraries.Codecs.A_G711A @type payloadType: intconstant @param defaultSound: SutAdapters.RTP.SOUND_SINE_1K (default) | SutAdapters.RTP.SOUND_WHITE_NOISE | SutAdapters.RTP.SOUND_SILENCE @type defaultSound: intconstant @param rtpVersion: rtp version (default=2) @type rtpVersion: integer @param initialSeqNumber: initial sequence number @type initialSeqNumber: integer/none @param ssrcValue: ssrc @type ssrcValue: integer/none @param socketFamily: socket family @type socketFamily: string @param sessionId: session identifier for high level events @type sessionId: string/none @param debug: active debug mode (default=False) @type debug: boolean @param agentSupport: agent support to use a remote socket (default=False) @type agentSupport: boolean @param agent: agent to use when this mode is activated @type agent: string/None @param shared: shared adapter (default=False) @type shared: boolean """ # check agent if agentSupport and agent is None: raise TestAdapterLib.ValueException(TestAdapterLib.caller(), "Agent cannot be undefined!") if agentSupport: if not isinstance(agent, dict): raise TestAdapterLib.ValueException( TestAdapterLib.caller(), "agent argument is not a dict (%s)" % type(agent)) if not len(agent['name']): raise TestAdapterLib.ValueException( TestAdapterLib.caller(), "agent name cannot be empty") if unicode(agent['type']) != unicode(AGENT_TYPE_EXPECTED): raise TestAdapterLib.ValueException( TestAdapterLib.caller(), 'Bad agent type: %s, expected: %s' % (agent['type'], unicode(AGENT_TYPE_EXPECTED))) # init adapter TestAdapterLib.Adapter.__init__(self, name=__NAME__, parent=parent, debug=debug, shared=shared, realname=name, agentSupport=agentSupport, agent=agent) self.logHighLevelEvents = logHighLevelEvents self.logLowLevelEvents = logLowLevelEvents self.__testcase = parent self.__debugmode = debug # init udp layer self.udp = AdapterUDP.Client(parent=parent, debug=debug, name=name, bindIp=bindIp, bindPort=bindPort, destinationIp=destinationIp, destinationPort=destinationPort, destinationHost=destinationHost, socketFamily=socketFamily, separatorDisabled=True, inactivityTimeout=inactivityTimeout, logEventSent=False, logEventReceived=False, parentName=__NAME__, agentSupport=agentSupport, agent=agent, shared=shared) # callback udp self.udp.handleIncomingData = self.onIncomingData self.udp.preStopListening = self.stopSending self.udp.onInactivity = self.onInactivity # inherent udp functions self.startListening = self.udp.startListening self.sendData = self.udp.sendData self.isStopped = self.udp.isStopped self.isListening = self.udp.isListening self.hasReceivedData = self.udp.hasReceivedData self.setDestination = self.udp.setDestination self.setSource = self.udp.setSource # rtp options self.cfg = {} self.cfg['version-rtp'] = rtpVersion self.cfg['record-rcv-rtp'] = recordRcvSound self.cfg['record-snd-rtp'] = recordSndSound self.cfg['payload-type'] = payloadType self.cfg['default-sound'] = defaultSound self.cfg['framing-interval'] = float(0) self.cfg['initial-seq'] = initialSeqNumber self.cfg['ssrc-chosen'] = ssrcValue self.cfg['session-id'] = sessionId # agent self.cfg['agent-support'] = agentSupport if agentSupport: self.cfg['agent-name'] = agent['name'] # init the RTP encoder/decoder self.rtpCodec = codec.Codec(parent=self) self.bufIn = '' self.bufOut = '' self.buf_AudioET = None # audio encoding type # sending thread init self.rtpStreamer = streamer.Streamer() self.defaultPayloads = defaultpayloads.DefaultPayloads(parent=parent, debug=debug) self.sendingThread = SendingThread(parent=self) self.sendingThread.start() # high events self.last_pkt_sent = None self.last_pkt_recv = None # check config self.__checkConfig()
def spawn_new_worker(self, new_id): streamer_id = new_id worker = streamer.Streamer(streamer_id) worker.start() self.pool[streamer_id] = worker