|
|
|
@ -57,93 +57,93 @@ class GaoPaiYi():
|
|
|
|
|
return {'code': -1, 'msg': e}
|
|
|
|
|
|
|
|
|
|
# win 版本
|
|
|
|
|
def getPic(self):
|
|
|
|
|
try:
|
|
|
|
|
p = threading.Thread(target=self.openCamera)
|
|
|
|
|
p.start()
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
# 摄像头拍照
|
|
|
|
|
url = 'http://127.0.0.1:6543/video=grabimage'
|
|
|
|
|
# url = 'https://restapi.getui.com/v2/h8m8bkLRUG6C313Xw8sNV8/auth'
|
|
|
|
|
param = {
|
|
|
|
|
"filepath": f"{self.path}\\{str(uuid.uuid1())}.jpg",
|
|
|
|
|
"rotate": "90", #// 图像旋转角度,90的整数倍,默认:"0"
|
|
|
|
|
"deskew": "0", #// 纠偏(主头有效),参数:0:不纠偏;1:纠偏
|
|
|
|
|
"deskewval":"0", #// 纠偏像素值:正常给0,正数时多裁,负数时少裁
|
|
|
|
|
"camidx": "0", #// 摄像头索引,参数:0:主头;1:副头
|
|
|
|
|
"ColorMode": "0", #// 色彩模式,图片保存本地时调用。0:彩色 1:灰色 2:黑白 3:白纸印章 4:去背景色(普通文件) 5:去背景色(身份证)
|
|
|
|
|
"quality": "0", #// 图片质量,图片保存本地调用
|
|
|
|
|
|
|
|
|
|
# 。0:默认质量;1:高质量;2:较高质量;3:中质量;4:较低质量;5:低质量
|
|
|
|
|
"bAutoAdjust":"1", #// 是否自动摆正: 0:不摆正 1:摆正
|
|
|
|
|
"bIsPrint1to1":"", #// 是否1:1打印
|
|
|
|
|
"watermark": {
|
|
|
|
|
"pos": "", #// 水印在图像中的位置,0:左上;1:右上;2:左下;3:右下;4:中间
|
|
|
|
|
"content": "", #// 水印内容,必须utf-8编码,当水印内容为空,将当前时间作为水印
|
|
|
|
|
"transparency": "", #// 透明度,0~255,0:完全透明;255:不透明
|
|
|
|
|
"fontsize": "", #// 字体大小,默认:32
|
|
|
|
|
"font": "", #// 字体
|
|
|
|
|
"color": "" # // 水印颜色,colorname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
header ={'Content-Type':'application/json;charset=utf-8'}
|
|
|
|
|
res = requests.post(url = url,data=json.dumps(param),headers=header)
|
|
|
|
|
print(json.loads(res.text).get('filepath'))
|
|
|
|
|
if json.loads(res.text)['code'] == "0":
|
|
|
|
|
res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['filepath'].split("\\")[-1]}
|
|
|
|
|
else:
|
|
|
|
|
res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['code']}
|
|
|
|
|
print(res_data)
|
|
|
|
|
# 关闭摄像头
|
|
|
|
|
url = 'http://127.0.0.1:6543/video=close'
|
|
|
|
|
param = {"camidx":"0"}
|
|
|
|
|
header = {'Content-Type': 'application/json;charset=utf-8'}
|
|
|
|
|
res = requests.post(url=url, data=json.dumps(param), headers=header,timeout=10)
|
|
|
|
|
print('关闭摄像头:::::::',json.loads(res.text)['code'])
|
|
|
|
|
stop_thread(thread=p)
|
|
|
|
|
|
|
|
|
|
return res_data
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno))
|
|
|
|
|
return {'code':-1,'msg':e}
|
|
|
|
|
# # linux 版本
|
|
|
|
|
# def getPic(self):
|
|
|
|
|
# try:
|
|
|
|
|
# # if path:
|
|
|
|
|
# # self.path = path
|
|
|
|
|
# #print('----------预览视频-------------------------')
|
|
|
|
|
# # 打開視頻
|
|
|
|
|
# url = "http://localhost:6543/StartPreview?dev_idx=0&res_id=0&pixfmt=pixfmt"
|
|
|
|
|
# res = requests.get(url = url)
|
|
|
|
|
# # print(json.loads(res.text))
|
|
|
|
|
# #print(json.loads(res.text)['data'])
|
|
|
|
|
# # print(json.loads(res.text)['code']=='0')
|
|
|
|
|
# if json.loads(res.text)['returnCode']!=0:
|
|
|
|
|
# return {'code':-1,'msg':"打开视频失败"}
|
|
|
|
|
# p = threading.Thread(target=self.openCamera)
|
|
|
|
|
# p.start()
|
|
|
|
|
# time.sleep(2)
|
|
|
|
|
# # 摄像头拍照
|
|
|
|
|
# url = 'http://127.0.0.1:6543/video=grabimage'
|
|
|
|
|
# # url = 'https://restapi.getui.com/v2/h8m8bkLRUG6C313Xw8sNV8/auth'
|
|
|
|
|
# param = {
|
|
|
|
|
# "filepath": f"{self.path}\\{str(uuid.uuid1())}.jpg",
|
|
|
|
|
# "rotate": "90", #// 图像旋转角度,90的整数倍,默认:"0"
|
|
|
|
|
# "deskew": "0", #// 纠偏(主头有效),参数:0:不纠偏;1:纠偏
|
|
|
|
|
# "deskewval":"0", #// 纠偏像素值:正常给0,正数时多裁,负数时少裁
|
|
|
|
|
# "camidx": "0", #// 摄像头索引,参数:0:主头;1:副头
|
|
|
|
|
# "ColorMode": "0", #// 色彩模式,图片保存本地时调用。0:彩色 1:灰色 2:黑白 3:白纸印章 4:去背景色(普通文件) 5:去背景色(身份证)
|
|
|
|
|
# "quality": "0", #// 图片质量,图片保存本地调用
|
|
|
|
|
|
|
|
|
|
# #print('----------拍照-------------------------',__file__)
|
|
|
|
|
# # 打開視頻
|
|
|
|
|
# url = "http://localhost:6543/getPic?savepath="+self.path+"&quality=80"
|
|
|
|
|
# res = requests.get(url = url)
|
|
|
|
|
|
|
|
|
|
# #print(json.loads(res.text)['data']["path"])
|
|
|
|
|
# #print(json.loads(res.text)['returnCode']==0) /home/yanyi/Project/MainManage/img/2022-9-9 15-36-35.jpg
|
|
|
|
|
# if json.loads(res.text)['returnCode']==0:
|
|
|
|
|
# res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['data']["path"].split("/")[-1]}
|
|
|
|
|
# # 。0:默认质量;1:高质量;2:较高质量;3:中质量;4:较低质量;5:低质量
|
|
|
|
|
# "bAutoAdjust":"1", #// 是否自动摆正: 0:不摆正 1:摆正
|
|
|
|
|
# "bIsPrint1to1":"", #// 是否1:1打印
|
|
|
|
|
# "watermark": {
|
|
|
|
|
# "pos": "", #// 水印在图像中的位置,0:左上;1:右上;2:左下;3:右下;4:中间
|
|
|
|
|
# "content": "", #// 水印内容,必须utf-8编码,当水印内容为空,将当前时间作为水印
|
|
|
|
|
# "transparency": "", #// 透明度,0~255,0:完全透明;255:不透明
|
|
|
|
|
# "fontsize": "", #// 字体大小,默认:32
|
|
|
|
|
# "font": "", #// 字体
|
|
|
|
|
# "color": "" # // 水印颜色,colorname
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# header ={'Content-Type':'application/json;charset=utf-8'}
|
|
|
|
|
# res = requests.post(url = url,data=json.dumps(param),headers=header)
|
|
|
|
|
# print(json.loads(res.text).get('filepath'))
|
|
|
|
|
# if json.loads(res.text)['code'] == "0":
|
|
|
|
|
# res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['filepath'].split("\\")[-1]}
|
|
|
|
|
# else:
|
|
|
|
|
# res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['returnCode']}
|
|
|
|
|
|
|
|
|
|
# #print('----------关闭视频-------------------------')
|
|
|
|
|
# url = "http://localhost:6543/StopPreview?dev_idx=0"
|
|
|
|
|
# res = requests.get(url = url)
|
|
|
|
|
# res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['code']}
|
|
|
|
|
# print(res_data)
|
|
|
|
|
# # 关闭摄像头
|
|
|
|
|
# url = 'http://127.0.0.1:6543/video=close'
|
|
|
|
|
# param = {"camidx":"0"}
|
|
|
|
|
# header = {'Content-Type': 'application/json;charset=utf-8'}
|
|
|
|
|
# res = requests.post(url=url, data=json.dumps(param), headers=header,timeout=10)
|
|
|
|
|
# print('关闭摄像头:::::::',json.loads(res.text)['code'])
|
|
|
|
|
# stop_thread(thread=p)
|
|
|
|
|
|
|
|
|
|
# return res_data
|
|
|
|
|
|
|
|
|
|
# except Exception as e :
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
# print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno))
|
|
|
|
|
# return {'code':-1,'msg':e}
|
|
|
|
|
# # linux 版本
|
|
|
|
|
def getPic(self):
|
|
|
|
|
try:
|
|
|
|
|
# if path:
|
|
|
|
|
# self.path = path
|
|
|
|
|
#print('----------预览视频-------------------------')
|
|
|
|
|
# 打開視頻
|
|
|
|
|
url = "http://localhost:6543/StartPreview?dev_idx=0&res_id=0&pixfmt=pixfmt"
|
|
|
|
|
res = requests.get(url = url)
|
|
|
|
|
# print(json.loads(res.text))
|
|
|
|
|
#print(json.loads(res.text)['data'])
|
|
|
|
|
# print(json.loads(res.text)['code']=='0')
|
|
|
|
|
if json.loads(res.text)['returnCode']!=0:
|
|
|
|
|
return {'code':-1,'msg':"打开视频失败"}
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
|
|
#print('----------拍照-------------------------',__file__)
|
|
|
|
|
# 打開視頻
|
|
|
|
|
url = "http://localhost:6543/getPic?savepath="+self.path+"&quality=80"
|
|
|
|
|
res = requests.get(url = url)
|
|
|
|
|
|
|
|
|
|
#print(json.loads(res.text)['data']["path"])
|
|
|
|
|
#print(json.loads(res.text)['returnCode']==0) /home/yanyi/Project/MainManage/img/2022-9-9 15-36-35.jpg
|
|
|
|
|
if json.loads(res.text)['returnCode']==0:
|
|
|
|
|
res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['data']["path"].split("/")[-1]}
|
|
|
|
|
else:
|
|
|
|
|
res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['returnCode']}
|
|
|
|
|
|
|
|
|
|
#print('----------关闭视频-------------------------')
|
|
|
|
|
url = "http://localhost:6543/StopPreview?dev_idx=0"
|
|
|
|
|
res = requests.get(url = url)
|
|
|
|
|
|
|
|
|
|
return res_data
|
|
|
|
|
|
|
|
|
|
except Exception as e :
|
|
|
|
|
print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno))
|
|
|
|
|
return {'code':-1,'msg':e}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ =="__main__":
|
|
|
|
|