Ejemplo n.º 1
0
 def testQueryState_ok(self):
     CommomUtils.Connect()
     HR = HttpRequest.HttpRequest()
     data = HR.open("camera._queryState")
     self.assertIsNotNone(data['state'], '获取state失败!')
     self.assertTrue(data['state'] == 'done', 'state不等于done!')
     self.assertTrue(data.has_key('results'), '没有results关键字!')
     results = data['results']
     self.assertIsNotNone(results, '获取results失败!')
     preview = results['preview']
     self.assertIsNotNone(preview['width'], '获取width失败!')
     self.assertIsNotNone(preview['url'], 'preview获取失败!')
     self.assertIsNotNone(results['version'], '获取version失败')
Ejemplo n.º 2
0
    def testGetStoragePath_ok(self):
        CommomUtils.Connect()
        HR = HttpRequest.HttpRequest()
        param = StartPreviewParam.StartPreview(stimime='h264',
                                               stiframe='30',
                                               stiwidth='1920',
                                               stibitrate='1000',
                                               stiheight='960',
                                               stimode='pano',
                                               orimime='h265',
                                               oriframe='30',
                                               oriwidth='1920',
                                               oribitrate='15000',
                                               oriheight='1440',
                                               saveori='false').getJsonData()
        preivewdata = HR.open('camera._startPreview', parameters=param)
        print(preivewdata)

        data = HR.open("camera._getStoragePath")
        print(data)
        self.assertIsNotNone(data['state'], '获取state失败!')
        self.assertTrue(data['state'] == 'done', 'state不等于done!')
        self.assertTrue(data.has_key('results'), '没有results关键字!')
        self.assertIsNotNone(data['results']['path'], '获取path失败!')
Ejemplo n.º 3
0
 def setUp(self):
     CommomUtils.Connect()
def doConnectToCamera():
    CommomUtils.Connect()
def Heart(sleeptime=2):
    while True:
        logging.info('Heart')
        CommomUtils.Connect()
        sleep(sleeptime)
def takePicAction(interval):
    #print('TakePic')
    logging.warning('TakePic')
    sleep(2)
    # 发送TakePicture请求
    global HR
    if (not HR):
        HR = HttpRequest.HttpRequest()

    datalist = []
    sub_data = ('data', {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": 'true'
        },
        "stiching": {
            "mime": "jpeg",
            "width": 7680,
            "height": 3840,
            "mode": "pano"
        }
    })

    data8k3d = ('8k3d', {
        "origin": {
            "saveOrigin": 'true',
            "height": 3000,
            "mime": "jpeg",
            "width": 4000
        },
        "delay": 0,
        "stiching": {
            "mode": "3d_top_left",
            "height": 7680,
            "mime": "jpeg",
            "width": 7680
        }
    })
    data_burst = ('burst', {
        "stabilization": 'false',
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "bitrate": 'null',
            "height": 3000,
            "framerate": 'null',
            "saveOrigin": 'true'
        },
        "delay": 0,
        "burst": {
            "count": 10,
            "enable": 'true'
        }
    })

    data_8kOF = ('8kof', {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": 'true'
        },
        "stabilization": 'false',
        "delay": 0,
        "stiching": {
            "algorithm": "opticalFlow",
            "bitrate": "null",
            "framerate": "null",
            "mime": "jpeg",
            "height": 3840,
            "mode": "pano",
            "width": 7680
        }
    })

    data_8k_3d_OF = ('8k3dof', {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": 'true'
        },
        "stabilization": 'false',
        "delay": 0,
        "stiching": {
            "algorithm": "opticalFlow",
            "bitrate": "null",
            "framerate": "null",
            "mime": "jpeg",
            "height": 7680,
            "mode": "3d_top_left",
            "width": 7680
        }
    })

    data_raw = ('raw', {
        "origin": {
            "framerate": 'null',
            "bitrate": 'null',
            "mime": "raw",
            "height": 3000,
            "saveOrigin": 'true',
            "width": 4000
        },
        "stabilization": 'false',
        "delay": 0
    })
    data_hdr = ('hdr', {
        "origin": {
            "framerate": 'null',
            "bitrate": 'null',
            "mime": "jpeg",
            "height": 3000,
            "saveOrigin": 'true',
            "width": 4000
        },
        "stabilization": 'false',
        "delay": 0,
        "hdr": {
            "min_ev": -32,
            "count": 3,
            "enable": 'true',
            "max_ev": 32
        }
    })

    datalist.append(sub_data)
    datalist.append(data8k3d)
    # datalist.append(data_raw)
    # datalist.append(data_hdr)
    # datalist.append(data_burst)
    # datalist.append(data_8kOF)
    # datalist.append(data_8k_3d_OF)

    origin_no_sti = {
        "origin": {
            "bitrate": None,
            "width": 4000,
            "height": 3000,
            "mime": "jpeg",
            "saveOrigin": 'true',
            "framerate": None
        }
    }
    ranreq = random.choice(datalist)
    if (ranreq[0] == 'hdr'):
        doSetExposureRandom(special='hdr')
    elif (ranreq[0] == 'burst'):
        doSetExposureRandom(special='burst')
    # else:
    #     pass
    #doSetExposureRandom()
    data = HR.open("camera._takePicture", parameters=ranreq[1])
    #data = HR.open("camera._takePicture", parameters=data_burst)
    logging.info(data)

    if (not data['state'] == 'done'):
        if (data['error']['description'] == 'camera not connected'):
            CommomUtils.Connect()
            logging.info('reconnect ..!')

        else:
            errstr = 'nowtime is' + ctime() + '\ndata is:' + str(data)
            #SendEmail.send(errstr)
    sleep(interval)
def takePicAction():
    print('TakePic')
    sleep(2)
    # 发送TakePicture请求
    HR = HttpRequest.HttpRequest()
    # HR.getFingerPrint()
    datalist = []
    sub_data = {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": 'true'
        },
        "stiching": {
            "mime": "jpeg",
            "width": 7680,
            "height": 3840,
            "mode": "pano"
        }
    }

    data8k3d = {
        "origin": {
            "saveOrigin": 'true',
            "height": 3000,
            "mime": "jpeg",
            "width": 4000
        },
        "delay": 0,
        "stiching": {
            "mode": "3d_top_left",
            "height": 7680,
            "mime": "jpeg",
            "width": 7680
        }
    }
    data_burst = {
        "stabilization": 'false',
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "bitrate": 'null',
            "height": 3000,
            "framerate": 'null',
            "saveOrigin": 'true'
        },
        "delay": 0,
        "burst": {
            "count": 10,
            "enable": 'true'
        }
    }

    data_8kOF = {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": 'true'
        },
        "stabilization": 'false',
        "delay": 0,
        "stiching": {
            "algorithm": "opticalFlow",
            "bitrate": "null",
            "framerate": "null",
            "mime": "jpeg",
            "height": 3840,
            "mode": "pano",
            "width": 7680
        }
    }

    data_8k_3d_OF = {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": 'true'
        },
        "stabilization": 'false',
        "delay": 0,
        "stiching": {
            "algorithm": "opticalFlow",
            "bitrate": "null",
            "framerate": "null",
            "mime": "jpeg",
            "height": 7680,
            "mode": "3d_top_left",
            "width": 7680
        }
    }

    data_raw = {
        "origin": {
            "framerate": 'null',
            "bitrate": 'null',
            "mime": "raw",
            "height": 3000,
            "saveOrigin": 'true',
            "width": 4000
        },
        "stabilization": 'false',
        "delay": 0
    }
    data_hdr = {
        "origin": {
            "framerate": 'null',
            "bitrate": 'null',
            "mime": "jpeg",
            "height": 3000,
            "saveOrigin": 'true',
            "width": 4000
        },
        "stabilization": 'false',
        "delay": 0,
        "hdr": {
            "min_ev": -32,
            "count": 3,
            "enable": 'true',
            "max_ev": 32
        }
    }
    cube = {
        "origin": {
            "mime": "jpeg",
            "width": 4000,
            "height": 3000,
            "saveOrigin": "true"
        },
        "stiching": {
            "map": "cube",
            "mode": "pano",
            "mime": "jpeg",
            "width": 2880,
            "height": 1920,
            "algorithm": "opticalFlow"
        }
    }

    datalist.append(sub_data)
    datalist.append(data8k3d)
    datalist.append(data_raw)
    datalist.append(data_hdr)
    datalist.append(data_burst)

    datalist.append(data_8kOF)
    datalist.append(data_8k_3d_OF)
    datalist.append(cube)

    origin_no_sti = {
        "origin": {
            "bitrate": None,
            "width": 4000,
            "height": 3000,
            "mime": "jpeg",
            "saveOrigin": 'true',
            "framerate": None
        }
    }
    data = HR.open("camera._takePicture", parameters=random.choice(datalist))
    #data = HR.open("camera._takePicture", parameters=data_burst)
    print(data)
    CommomUtils.writeLogToFile(str(data))

    if (not data['state'] == 'done'):
        if (data['error']['description'] == 'camera not connected'):
            CommomUtils.Connect()
            print('reconnect ..!')
        else:
            errstr = 'nowtime is' + ctime() + '\ndata is:' + str(data)
            SendEmail.send(errstr)
    sleep(40)
def Heart(sleeptime=3):
    while True:
        CommomUtils.writeLogToFile('Heart')
        print('Heart')
        CommomUtils.Connect()
        sleep(sleeptime)
t5 = threading.Thread(target=sendPicAndRecord)
t6 = threading.Thread(target=sendHeart)
tRecord = threading.Thread(target=sendRecord)


def runThreadAs(thread1, thread2):
    #thread1 sends heart-package
    thread1.setDaemon(True)
    thread1.start()
    thread2.start()
    thread2.join()


if __name__ == '__main__':

    CommomUtils.Connect()
    mode = 1
    if (mode == 1):
        try:
            runThreadAs(tHeart, t2Pic)
        except Exception as e:
            CommomUtils.writeLogToFile(e)
    elif (mode == 2):
        try:
            runThreadAs(tHeart, t3Record)
        except Exception as e:
            CommomUtils.writeLogToFile(e)
    # elif (mode == 4):
    #      runThreadAs(t6, t5)
    # elif(mode==5):
    #     runThreadAs(t6, tRecord)
Ejemplo n.º 10
0
def Heart():
    while True:
        print('Heart')
        CommomUtils.Connect()
        sleep(3)
Ejemplo n.º 11
0
 def testDisconneact_ok(self):
     CommomUtils.Connect()
     HR=HttpRequest.HttpRequest()
     data=HR.open("camera._disconnect")
     self.assertIsNotNone(data['state'],'state等于空!')
     self.assertTrue(data['state']=='done','state不等于done!')