影棚与地贴的关联 和 走新建模系统 通过数据库来连接
This commit is contained in:
1 parent
e69bb31be2
commit
ae779d7d00
7 files changed
+62
-34
No files matched your search
@@ -83,7 +83,6 @@ ps_floor_sticker = {
|
|||||||
"29" : floor_sticker_distances['v1'],
|
"29" : floor_sticker_distances['v1'],
|
||||||
"44" : floor_sticker_distances['v2'],
|
"44" : floor_sticker_distances['v2'],
|
||||||
"54" : floor_sticker_distances['v2'],
|
"54" : floor_sticker_distances['v2'],
|
||||||
"63" : floor_sticker_distances['v2'],
|
|
||||||
"77" : floor_sticker_distances['v2'],
|
"77" : floor_sticker_distances['v2'],
|
||||||
"79" : floor_sticker_distances['v2'],
|
"79" : floor_sticker_distances['v2'],
|
||||||
"80" : floor_sticker_distances['v2'],
|
"80" : floor_sticker_distances['v2'],
|
||||||
|
|||||||
+2
-2
@@ -249,9 +249,9 @@ def down_from_oss(oss_client, workdir, pid, per=100):
|
|||||||
|
|
||||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 图片下载完成, 共费时{diff_time(start_time)}')
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 图片下载完成, 共费时{diff_time(start_time)}')
|
||||||
|
|
||||||
def get_defineDistances(distances):
|
def get_defineDistances(psid):
|
||||||
res = ''
|
res = ''
|
||||||
distances = distances.split(';')
|
distances = libs_db.get_floor_sticker_distances(psid).split(';')
|
||||||
for d in distances:
|
for d in distances:
|
||||||
p1, p2, distance = d.split(' ')
|
p1, p2, distance = d.split(' ')
|
||||||
res = res + f' -defineDistance {p1} {p2} {distance}'
|
res = res + f' -defineDistance {p1} {p2} {distance}'
|
||||||
|
|||||||
+54
-26
@@ -2,16 +2,20 @@
|
|||||||
import pymysql, socket, time
|
import pymysql, socket, time
|
||||||
import config
|
import config
|
||||||
|
|
||||||
# 获取新的任务
|
#公共连接库
|
||||||
def get_task(task_type):
|
def pymysqlAlias():
|
||||||
try:
|
return pymysql.connect(
|
||||||
with pymysql.connect(
|
|
||||||
host=config.mysql_local['host'],
|
host=config.mysql_local['host'],
|
||||||
port=config.mysql_local['port'],
|
port=config.mysql_local['port'],
|
||||||
user=config.mysql_local['user'],
|
user=config.mysql_local['user'],
|
||||||
password=config.mysql_local['password'],
|
password=config.mysql_local['password'],
|
||||||
db=config.mysql_local['db'],
|
db=config.mysql_local['db'],
|
||||||
charset=config.mysql_local['charset'],) as conn:
|
charset=config.mysql_local['charset'],)
|
||||||
|
|
||||||
|
# 获取新的任务
|
||||||
|
def get_task(task_type):
|
||||||
|
try:
|
||||||
|
with pymysqlAlias() as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
sql = f'select task_key from tasks where task_type = "{task_type}" and status = 0 order by priority desc, id asc limit 1'
|
sql = f'select task_key from tasks where task_type = "{task_type}" and status = 0 order by priority desc, id asc limit 1'
|
||||||
@@ -29,13 +33,7 @@ def get_task(task_type):
|
|||||||
# 新增新的任务
|
# 新增新的任务
|
||||||
def add_task(data):
|
def add_task(data):
|
||||||
try:
|
try:
|
||||||
with pymysql.connect(
|
with pymysqlAlias() as conn:
|
||||||
host=config.mysql_local['host'],
|
|
||||||
port=config.mysql_local['port'],
|
|
||||||
user=config.mysql_local['user'],
|
|
||||||
password=config.mysql_local['password'],
|
|
||||||
db=config.mysql_local['db'],
|
|
||||||
charset=config.mysql_local['charset'],) as conn:
|
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
#判断是否是昆山教学的,是的话优先级设置为默认
|
#判断是否是昆山教学的,是的话优先级设置为默认
|
||||||
@@ -55,13 +53,7 @@ def add_task(data):
|
|||||||
# 开始任务
|
# 开始任务
|
||||||
def start_task(data):
|
def start_task(data):
|
||||||
try:
|
try:
|
||||||
with pymysql.connect(
|
with pymysqlAlias() as conn:
|
||||||
host=config.mysql_local['host'],
|
|
||||||
port=config.mysql_local['port'],
|
|
||||||
user=config.mysql_local['user'],
|
|
||||||
password=config.mysql_local['password'],
|
|
||||||
db=config.mysql_local['db'],
|
|
||||||
charset=config.mysql_local['charset'],) as conn:
|
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
@@ -75,13 +67,7 @@ def start_task(data):
|
|||||||
# 完成任务
|
# 完成任务
|
||||||
def finish_task(data):
|
def finish_task(data):
|
||||||
try:
|
try:
|
||||||
with pymysql.connect(
|
with pymysqlAlias() as conn:
|
||||||
host=config.mysql_local['host'],
|
|
||||||
port=config.mysql_local['port'],
|
|
||||||
user=config.mysql_local['user'],
|
|
||||||
password=config.mysql_local['password'],
|
|
||||||
db=config.mysql_local['db'],
|
|
||||||
charset=config.mysql_local['charset'],) as conn:
|
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
@@ -91,3 +77,45 @@ def finish_task(data):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行finish_task({data})异常: {str(e)}")
|
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行finish_task({data})异常: {str(e)}")
|
||||||
|
|
||||||
|
# 根据影棚ID 获取影棚的配置,如果没有指定的配置,则返回默认配置
|
||||||
|
def get_floor_sticker_distances(psid,is_default = False):
|
||||||
|
try:
|
||||||
|
with pymysqlAlias() as conn:
|
||||||
|
cursor = conn.cursor()
|
||||||
|
sql = f'select a.studio_id,value from floor_sticker_link_studio as a left join floor_sticker_distances as b on a.floor_name = b.name where a.studio_id in (0,{psid})'
|
||||||
|
# print(f'sql: {sql}')
|
||||||
|
cursor.execute(sql)
|
||||||
|
result = cursor.fetchall()
|
||||||
|
if is_default:
|
||||||
|
return result[0]["value"]
|
||||||
|
|
||||||
|
if len(result) == 1:
|
||||||
|
return result[0]["value"]
|
||||||
|
|
||||||
|
if len(result) == 2:
|
||||||
|
for item in result:
|
||||||
|
if item["studio_id"] == psid:
|
||||||
|
return item["value"]
|
||||||
|
return "error-配置异常,该影棚有多个地贴配置"
|
||||||
|
except Exception as e:
|
||||||
|
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行get_floor_sticker_distances()异常: {str(e)}")
|
||||||
|
return "error"
|
||||||
|
|
||||||
|
#判断是否要走新的建模系统
|
||||||
|
def is_new_make_psid(psid):
|
||||||
|
try:
|
||||||
|
with pymysqlAlias() as conn:
|
||||||
|
cursor = conn.cursor()
|
||||||
|
sql = f'select count(*) from new_make_psid where studio_id = {psid}'
|
||||||
|
print(f'sql: {sql}')
|
||||||
|
cursor.execute(sql)
|
||||||
|
result = cursor.fetchone()
|
||||||
|
if result[0] > 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
except Exception as e:
|
||||||
|
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行is_new_make_psid()异常: {str(e)}")
|
||||||
|
return "error"
|
||||||
|
|
||||||
+2
-2
@@ -66,7 +66,7 @@ def detect_markers(psid, pid):
|
|||||||
-addFolder "{os.path.join(config.workdir, pid, "photo1")}" {config.r["setTextureFalse"]} -align -addFolder "{os.path.join(config.workdir, pid, "photo2")}" \
|
-addFolder "{os.path.join(config.workdir, pid, "photo1")}" {config.r["setTextureFalse"]} -align -addFolder "{os.path.join(config.workdir, pid, "photo2")}" \
|
||||||
{add_photo3} -align -selectAllImages \
|
{add_photo3} -align -selectAllImages \
|
||||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
||||||
{libs.get_defineDistances(config.ps_floor_sticker.get(psid, config.ps_floor_sticker["default"]))} -align -align -update {config.r2["setRegion"]} \
|
{libs.get_defineDistances(psid)} -align -align -update {config.r2["setRegion"]} \
|
||||||
-exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
-exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
||||||
-exportControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" "D:\\make2\\config\\exportControlPoints.config.xml" \
|
-exportControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" "D:\\make2\\config\\exportControlPoints.config.xml" \
|
||||||
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||||
@@ -99,7 +99,7 @@ def cal_reconstruction_region(psid, pid):
|
|||||||
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
||||||
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
||||||
-addFolder "{os.path.join(config.workdir, pid, "photo2")}" -align {add_photo3} \
|
-addFolder "{os.path.join(config.workdir, pid, "photo2")}" -align {add_photo3} \
|
||||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" {libs.get_defineDistances(config.ps_floor_sticker.get(psid, config.ps_floor_sticker["default"]))} -align -align \
|
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" {libs.get_defineDistances(psid)} -align -align \
|
||||||
-update {config.r2["setRegion"]} \
|
-update {config.r2["setRegion"]} \
|
||||||
-exportControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" "D:\\make2\\config\\exportControlPoints.config.xml" \
|
-exportControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" "D:\\make2\\config\\exportControlPoints.config.xml" \
|
||||||
-selectAllImages -exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
-selectAllImages -exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import config, libs, libs_db,common
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
common.copy_remote_directory("172.31.1.11","D:\\7831","E:\\")
|
#common.copy_remote_directory("172.31.1.11","D:\\7831","E:\\")
|
||||||
# config.oss_bucket.delete_object(f'test/test_delete')
|
# config.oss_bucket.delete_object(f'test/test_delete')
|
||||||
# #删除oss 上的文件夹里的内容
|
# #删除oss 上的文件夹里的内容
|
||||||
# object_list = oss2.ObjectIterator(config.oss_bucket, prefix='test/test_delete/')
|
# object_list = oss2.ObjectIterator(config.oss_bucket, prefix='test/test_delete/')
|
||||||
# result = config.oss_bucket.batch_delete_objects([obj.key for obj in object_list])
|
# result = config.oss_bucket.batch_delete_objects([obj.key for obj in object_list])
|
||||||
|
print(libs_db.is_new_make_psid(1))
|
||||||
@@ -48,7 +48,7 @@ def find_and_maximize_window(window_title):
|
|||||||
|
|
||||||
def get_defineDistances(pid, left, top, right, bottom):
|
def get_defineDistances(pid, left, top, right, bottom):
|
||||||
psid = libs.getPSid(pid)
|
psid = libs.getPSid(pid)
|
||||||
distances = config.ps_floor_sticker.get(psid, config.ps_floor_sticker['default'])
|
distances = libs_db.get_floor_sticker_distances(psid) #config.ps_floor_sticker.get(psid, config.ps_floor_sticker['default'])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
y = 748
|
y = 748
|
||||||
for index, d in enumerate(distances.split(';')):
|
for index, d in enumerate(distances.split(';')):
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ def main(pid, lock=False):
|
|||||||
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" {config.r["setTextureFalse"]} \
|
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" {config.r["setTextureFalse"]} \
|
||||||
-addFolder "{os.path.join(config.workdir, pid, "photo2")}" -selectAllImages \
|
-addFolder "{os.path.join(config.workdir, pid, "photo2")}" -selectAllImages \
|
||||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
||||||
{libs.get_defineDistances(config.ps_floor_sticker.get(psid, config.ps_floor_sticker["default"]))} -update -align -align {config.r2["setRegion"]} \
|
{libs.get_defineDistances(psid)} -update -align -align {config.r2["setRegion"]} \
|
||||||
{exportxmp} \
|
{exportxmp} \
|
||||||
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
||||||
|
|||||||
Reference in new issue
Block a user