Esempio n. 1
0
def main():
    def callback(frame, depth, fps):
        # Normalize the depth for representation
        min, max = depth.min(), depth.max()
        depth = np.uint8(255 * (depth - min) / (max - min))

        # Unable to retrieve correct frame, it's still depth here
        put_text(frame, "{1}x{0}".format(*frame.shape), Gravity.TOP_LEFT)
        put_text(depth, "{1}x{0}".format(*depth.shape), Gravity.TOP_LEFT)

        put_text(depth, "%.1f" % fps, Gravity.TOP_RIGHT)

        cv2.imshow('frame', frame)
        cv2.imshow('depth', depth)

    with Camera(cv2.CAP_OPENNI2) as cam:
        print("Camera: %dx%d, %d" %
              (cam.get(cv2.CAP_OPENNI_IMAGE_GENERATOR +
                       cv2.CAP_PROP_FRAME_WIDTH),
               cam.get(cv2.CAP_OPENNI_IMAGE_GENERATOR +
                       cv2.CAP_PROP_FRAME_HEIGHT),
               cam.get(cv2.CAP_OPENNI_IMAGE_GENERATOR + cv2.CAP_PROP_FPS)))
        cam.capture(callback, False)

    cv2.destroyAllWindows()
Esempio n. 2
0
 def setUpClass(cls):
     serino = "MDEVICE"
     #serino = "56c051e1"
     if len(sys.argv) > 1:
         serino = sys.argv[1]
     cls.mod = Camera(serino, "Camera")
     cls.mod_cfg = GetConfigs("Camera")
     cls.mod.test_times = 0
     cls.mod.dicttesttimes = cls.mod_cfg.get_test_times()
     for test_time in cls.mod.dicttesttimes:
         cls.mod.test_times += int(cls.mod.dicttesttimes[test_time])
Esempio n. 3
0
 def __init__(self, device, mod):
     self.device = connect_device(device)
     self.logger = createlogger(mod)
     self.log_path = create_folder()
     self.camera = Camera(self.device, "task_camera")
     self.product = Configs("common").get("product", "Info")
     if self.product == "Sprints":
         from common.chrome import Chrome
         self.browser = Chrome(self.device, "task_browser")
     else:
         self.browser = Browser(self.device, "Browser")
     self.tel = Telephony(self.device, "task_tel")
     self.message = Message(self.device, "task_message")
     self.settings = Settings(self.device, "switch_nw")
     self.suc_times = 0
     self.mod_cfg = GetConfigs(mod)
     self.test_times = 0
     self.dicttesttimes = self.mod_cfg.get_test_times()
     for test_time in self.dicttesttimes:
         self.test_times += int(self.dicttesttimes[test_time])
     self.test_times = self.test_times * 2 + 4
     self.logger.info("Trace Total Times " + str(self.test_times))
Esempio n. 4
0
def read_camera_params(extrinsic_data_path, camera_data_path):
    """Read camera's parameters.

    :param extrinsic_data_path: path of the extrinsic data
    :param camera_data_path: path of the camera's data
    :return: camera's params
    :rtype: Camera
    """
    extrinsic_data = np.load(extrinsic_data_path)
    rotation_matrix = extrinsic_data['rotationMatrix']
    translation_vector = extrinsic_data['translationVector']

    camera_data = np.load(camera_data_path)
    intrinsic_matrix = camera_data['IntrinsicMatrix']
    return Camera(rotation_matrix, translation_vector, intrinsic_matrix)
Esempio n. 5
0
 def __init__(self,device,mod):
     self.device = connect_device(device)
     self.logger = createlogger(mod)
     self.log_path = create_folder()
     self.camera = Camera(self.device,"task_camera")
     self.product = Configs("common").get("product","Info") 
     if self.product == "Sprints":
         from common.chrome import Chrome
         self.browser = Chrome(self.device,"task_browser")
     else:
         self.browser = Browser(self.device,"Browser")
     self.tel = Telephony(self.device,"task_tel")
     self.message = Message(self.device,"task_message")
     self.settings = Settings(self.device,"switch_nw")
     self.suc_times = 0
     self.mod_cfg = GetConfigs(mod)
     self.test_times = 0
     self.dicttesttimes = self.mod_cfg.get_test_times()
     for test_time in self.dicttesttimes: self.test_times += int(self.dicttesttimes[test_time]) 
     self.test_times =  self.test_times*2 + 4
     self.logger.info("Trace Total Times " + str(self.test_times))  
Esempio n. 6
0
class MultiTask(Common):
    def __init__(self, device, mod):
        self.device = connect_device(device)
        self.logger = createlogger(mod)
        self.log_path = create_folder()
        self.camera = Camera(self.device, "task_camera")
        self.product = Configs("common").get("product", "Info")
        if self.product == "Sprints":
            from common.chrome import Chrome
            self.browser = Chrome(self.device, "task_browser")
        else:
            self.browser = Browser(self.device, "Browser")
        self.tel = Telephony(self.device, "task_tel")
        self.message = Message(self.device, "task_message")
        self.settings = Settings(self.device, "switch_nw")
        self.suc_times = 0
        self.mod_cfg = GetConfigs(mod)
        self.test_times = 0
        self.dicttesttimes = self.mod_cfg.get_test_times()
        for test_time in self.dicttesttimes:
            self.test_times += int(self.dicttesttimes[test_time])
        self.test_times = self.test_times * 2 + 4
        self.logger.info("Trace Total Times " + str(self.test_times))

    def remove(self):
        self.logger.debug("remove all opened activities")
        self.device.press.menu()
        if self.device(description="Clear all").wait.exists(timeout=2000):
            self.device(description="Clear all").click()
            self.device.delay(5)
            return True
        return False

    def start(self):
        self.logger.debug("Start Some activities")
        self.logger.debug("Launch Contacts")
        #self.tel.start_app("Contacts")
        self.tel.enter_contacts()
        self.device.delay(3)
        self.logger.debug("Launch Message")
        self.message.start_app("Messaging")
        self.device.delay(3)
        self.logger.debug("Launch Dialer")
        #self.tel.start_app("Call")
        self.tel.enter_dialer()
        self.device.delay(3)
        self.logger.debug("Launch Camera")
        self.camera.start_app("Camera")
        self.device.delay(3)
        self.logger.debug("Launch Browser")
        #self.browser.start_app("Browser")
        self.browser.enter()

    def make_call(self, number):
        if self.tel.enter_dialer():
            try:
                if self.tel.call_from_dialer(number):
                    self.suc_times += 1
                    self.logger.info("Trace Success Make Call")
                    return True
                else:
                    self.save_fail_img()
                    return False
            except Exception, e:
                self.save_fail_img()
                #                 common.common.log_traceback(traceback.format_exc())
                return False
Esempio n. 7
0
        y0, ys = s["ys"]
        xvec = np.array(s['translation_x'])
        yvec = np.array(s['translation_y'])
        
        def idx(x,y):
            return y+x*ys
            #return x+y*xs
        print([idx(x,0) for x in xrange(xs)])
        
        cameras = {idx(x,y): Camera(idx(x,y),{
            'x':x,'y':y,
            'distortion':s['distortion'],
            'distortion-depth':s['distortion-depth'],
            'kalibration':s['kalibration'],
            'kalibration-depth':s['kalibration-depth'],
            'rotation':s['rotation'],
            'translation':np.array(s['translation']) + x*xvec + y*yvec,
            'img_file':s['img_file'].format(s['camera_id'],idx(x,y)),
            'img_directory':args.rgb,
            'depth_file':s['depth_file'].format(s['camera_id'],idx(x,y)),
            'depth_directory':args.depth
        }) for x in xrange(xs) for y in xrange(ys)}
else:
    with open('cameraSettings.json') as file:
        camera_settings = json.load(file)
        cameras = {id: Camera(id,settings) for id,settings in enumerate(camera_settings)}

xyCamera = {(c.x,c.y) : c for id,c in cameras.items()}

n, m, k = xs, args.m, args.k
dibrCams = {}
Esempio n. 8
0
        cameras = {
            idx(x, y): Camera(
                idx(x, y), {
                    'x':
                    x,
                    'y':
                    y,
                    'distortion':
                    s['distortion'] if 'distortion' in s else None,
                    'distortion-depth':
                    s['distortion-depth'] if 'distortion-depth' in s else None,
                    'kalibration':
                    s['kalibration'],
                    'kalibration-depth':
                    s['kalibration-depth']
                    if 'kalibration-depth' in s else s['kalibration'],
                    'rotation':
                    s['rotation'],
                    'translation':
                    np.array(s['translation']) + x * xvec + y * yvec,
                    'img_file':
                    s['img_file'].format(s['camera_id'], idx(x, y)),
                    'img_directory':
                    args.rgb,
                    'depth_file':
                    s['depth_file'].format(s['camera_id'], idx(x, y)),
                    'depth_directory':
                    args.depth
                })
            for x in xrange(xs) for y in xrange(ys)
        }
Esempio n. 9
0
class MultiTask(Common):
    def __init__(self,device,mod):
        self.device = connect_device(device)
        self.logger = createlogger(mod)
        self.log_path = create_folder()
        self.camera = Camera(self.device,"task_camera")
        self.product = Configs("common").get("product","Info") 
        if self.product == "Sprints":
            from common.chrome import Chrome
            self.browser = Chrome(self.device,"task_browser")
        else:
            self.browser = Browser(self.device,"Browser")
        self.tel = Telephony(self.device,"task_tel")
        self.message = Message(self.device,"task_message")
        self.settings = Settings(self.device,"switch_nw")
        self.suc_times = 0
        self.mod_cfg = GetConfigs(mod)
        self.test_times = 0
        self.dicttesttimes = self.mod_cfg.get_test_times()
        for test_time in self.dicttesttimes: self.test_times += int(self.dicttesttimes[test_time]) 
        self.test_times =  self.test_times*2 + 4
        self.logger.info("Trace Total Times " + str(self.test_times))  
                  
    def remove(self):
        self.logger.debug("remove all opened activities")
        self.device.press.menu()
        if self.device(description= "Clear all").wait.exists(timeout = 2000):
            self.device(description= "Clear all").click()
            self.device.delay(5)
            return True
        return False
        
    def start(self):
        self.logger.debug("Start Some activities")
        self.logger.debug("Launch Contacts")
        #self.tel.start_app("Contacts")
        self.tel.enter_contacts()
        self.device.delay(3)
        self.logger.debug("Launch Message")
        self.message.start_app("Messaging")
        self.device.delay(3)
        self.logger.debug("Launch Dialer")         
        #self.tel.start_app("Call")
        self.tel.enter_dialer()
        self.device.delay(3)
        self.logger.debug("Launch Camera")           
        self.camera.start_app("Camera")
        self.device.delay(3)
        self.logger.debug("Launch Browser")        
        #self.browser.start_app("Browser")
        self.browser.enter()
    def make_call(self,number):
        if self.tel.enter_dialer():
            try:
                if self.tel.call_from_dialer(number):
                    self.suc_times += 1
                    self.logger.info("Trace Success Make Call")
                    return True
                else:
                    self.save_fail_img()
                    return False
            except Exception,e:
                self.save_fail_img()
#                 common.common.log_traceback(traceback.format_exc())
                return False