影棚与地贴的关联 和 走新建模系统 通过数据库来连接
This commit is contained in:
1 parent
e69bb31be2
commit
ae779d7d00
7 files changed
+63
-35
No files matched your search
@@ -83,7 +83,6 @@ ps_floor_sticker = {
|
||||
"29" : floor_sticker_distances['v1'],
|
||||
"44" : floor_sticker_distances['v2'],
|
||||
"54" : floor_sticker_distances['v2'],
|
||||
"63" : floor_sticker_distances['v2'],
|
||||
"77" : floor_sticker_distances['v2'],
|
||||
"79" : 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)}')
|
||||
|
||||
def get_defineDistances(distances):
|
||||
def get_defineDistances(psid):
|
||||
res = ''
|
||||
distances = distances.split(';')
|
||||
distances = libs_db.get_floor_sticker_distances(psid).split(';')
|
||||
for d in distances:
|
||||
p1, p2, distance = d.split(' ')
|
||||
res = res + f' -defineDistance {p1} {p2} {distance}'
|
||||
|
||||
+55
-27
@@ -2,16 +2,20 @@
|
||||
import pymysql, socket, time
|
||||
import config
|
||||
|
||||
# 获取新的任务
|
||||
def get_task(task_type):
|
||||
try:
|
||||
with pymysql.connect(
|
||||
#公共连接库
|
||||
def pymysqlAlias():
|
||||
return pymysql.connect(
|
||||
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:
|
||||
charset=config.mysql_local['charset'],)
|
||||
|
||||
# 获取新的任务
|
||||
def get_task(task_type):
|
||||
try:
|
||||
with pymysqlAlias() as conn:
|
||||
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'
|
||||
@@ -29,13 +33,7 @@ def get_task(task_type):
|
||||
# 新增新的任务
|
||||
def add_task(data):
|
||||
try:
|
||||
with pymysql.connect(
|
||||
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:
|
||||
with pymysqlAlias() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
#判断是否是昆山教学的,是的话优先级设置为默认
|
||||
@@ -55,13 +53,7 @@ def add_task(data):
|
||||
# 开始任务
|
||||
def start_task(data):
|
||||
try:
|
||||
with pymysql.connect(
|
||||
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:
|
||||
with pymysqlAlias() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
hostname = socket.gethostname()
|
||||
@@ -75,13 +67,7 @@ def start_task(data):
|
||||
# 完成任务
|
||||
def finish_task(data):
|
||||
try:
|
||||
with pymysql.connect(
|
||||
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:
|
||||
with pymysqlAlias() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
hostname = socket.gethostname()
|
||||
@@ -90,4 +76,46 @@ def finish_task(data):
|
||||
cursor.execute(sql)
|
||||
conn.commit()
|
||||
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")}" \
|
||||
{add_photo3} -align -selectAllImages \
|
||||
-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" \
|
||||
-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")}" \
|
||||
@@ -99,7 +99,7 @@ def cal_reconstruction_region(psid, pid):
|
||||
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
||||
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
||||
-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"]} \
|
||||
-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" \
|
||||
|
||||
@@ -11,8 +11,9 @@ import config, libs, libs_db,common
|
||||
|
||||
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')
|
||||
# #删除oss 上的文件夹里的内容
|
||||
# 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])
|
||||
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):
|
||||
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)
|
||||
y = 748
|
||||
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"]} \
|
||||
-addFolder "{os.path.join(config.workdir, pid, "photo2")}" -selectAllImages \
|
||||
-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} \
|
||||
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
||||
|
||||
Reference in new issue
Block a user