taotoolkit 2.0.8__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/PKG-INFO +1 -1
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/pyproject.toml +1 -1
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/__init__.py +1 -3
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_cmdTool.py +171 -1
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_common.py +7 -10
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_device.py +2 -2
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_tuning.py +368 -50
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit.egg-info/PKG-INFO +1 -1
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/README.md +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/setup.cfg +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/asrVrf.py +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_camDvt.py +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_flash.py +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit/tao_vrfTool.py +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit.egg-info/SOURCES.txt +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit.egg-info/dependency_links.txt +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit.egg-info/requires.txt +0 -0
- {taotoolkit-2.0.8 → taotoolkit-2.1.0}/taotoolkit.egg-info/top_level.txt +0 -0
|
@@ -16,7 +16,6 @@ from .tao_common import (
|
|
|
16
16
|
rCmdRealtime,
|
|
17
17
|
exit,
|
|
18
18
|
eExit,
|
|
19
|
-
iExit,
|
|
20
19
|
createFolder,
|
|
21
20
|
fileExist,
|
|
22
21
|
findFilesBySuffixKeyword,
|
|
@@ -43,7 +42,7 @@ from .tao_camDvt import camDvtMain as camDvtMain, printHelp as camDvtHelp, CamDv
|
|
|
43
42
|
|
|
44
43
|
from .asrVrf import Vrf
|
|
45
44
|
|
|
46
|
-
__version__ = "2.0
|
|
45
|
+
__version__ = "2.1.0"
|
|
47
46
|
|
|
48
47
|
__all__ = [
|
|
49
48
|
"debugCtrl",
|
|
@@ -63,7 +62,6 @@ __all__ = [
|
|
|
63
62
|
"rCmdRealtime",
|
|
64
63
|
"exit",
|
|
65
64
|
"eExit",
|
|
66
|
-
"iExit",
|
|
67
65
|
"createFolder",
|
|
68
66
|
"fileExist",
|
|
69
67
|
"findFilesBySuffixKeyword",
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
6
|
import os
|
|
7
|
+
import re
|
|
8
|
+
import shutil
|
|
7
9
|
import sys
|
|
8
10
|
import subprocess
|
|
9
11
|
import argparse
|
|
@@ -15,13 +17,18 @@ from datetime import datetime
|
|
|
15
17
|
from PIL import Image, ImageOps
|
|
16
18
|
|
|
17
19
|
from .tao_common import (
|
|
20
|
+
createFolder,
|
|
18
21
|
debugCtrl,
|
|
19
22
|
eExit,
|
|
23
|
+
findFilesWithSuffix,
|
|
24
|
+
get_file_index,
|
|
20
25
|
logd,
|
|
21
26
|
loge,
|
|
22
27
|
logi,
|
|
28
|
+
logw,
|
|
23
29
|
oCmd,
|
|
24
30
|
rCmd,
|
|
31
|
+
renameFile,
|
|
25
32
|
sleep,
|
|
26
33
|
normalize_args,
|
|
27
34
|
register_command,
|
|
@@ -126,6 +133,7 @@ def logcatParseArgs(argsList):
|
|
|
126
133
|
"-k", "--keywords", metavar="KEYWORD", nargs="*", default=[], help="过滤关键词(空格分隔,不指定则输出全部)"
|
|
127
134
|
)
|
|
128
135
|
parser.add_argument("-d", "--device", metavar="SERIAL", default=None, help="指定设备序列号(多设备时使用)")
|
|
136
|
+
parser.add_argument("-c", "--clear", action="store_true", help="抓取前先清空日志缓冲区(adb logcat -c)")
|
|
129
137
|
parser.add_argument("--no-file", action="store_true", help="只输出到终端,不保存文件")
|
|
130
138
|
return parser.parse_args(argsList)
|
|
131
139
|
|
|
@@ -166,11 +174,16 @@ def line_matches(line, keywords):
|
|
|
166
174
|
def runLogcat(args):
|
|
167
175
|
check_adb()
|
|
168
176
|
|
|
177
|
+
if args.clear:
|
|
178
|
+
clear_cmd = ["adb"] + (["-s", args.device] if args.device else []) + ["logcat", "-c"]
|
|
179
|
+
subprocess.run(clear_cmd, capture_output=True, text=True, timeout=10)
|
|
180
|
+
logi(f"{EMOJI['ok']} 已清空 logcat 缓冲区")
|
|
181
|
+
|
|
169
182
|
# 确定日志文件名
|
|
170
183
|
log_path = None
|
|
171
184
|
if not args.no_file:
|
|
172
185
|
if args.file:
|
|
173
|
-
log_path = args.file
|
|
186
|
+
log_path = f"{args.file}.log"
|
|
174
187
|
else:
|
|
175
188
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
176
189
|
log_path = f"logcat_{timestamp}.log"
|
|
@@ -572,6 +585,161 @@ def CLI_video2jpg(argsList):
|
|
|
572
585
|
oCmd(cmd, sleep_s=1.0, showCmd=True, logLevel="info")
|
|
573
586
|
|
|
574
587
|
|
|
588
|
+
######### renameJpgVrf #########
|
|
589
|
+
# 从 func/getLarkJpgVrf.py 集成: 按 frameid 匹配整理 jpg/vrf 文件
|
|
590
|
+
def listTopFiles(path, suffixes):
|
|
591
|
+
"""findFilesWithSuffix 是递归查找, 整理时只处理输入目录第一层的文件(避免重复处理输出目录)"""
|
|
592
|
+
base = os.path.abspath(path)
|
|
593
|
+
return [f for f in findFilesWithSuffix(path, suffixes) if os.path.dirname(os.path.abspath(f)) == base]
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def createSceneFolder(path, end, start=0):
|
|
597
|
+
for i in range(start, end + start):
|
|
598
|
+
scenePath = os.path.join(path, 'vrf', "scene" + str(i))
|
|
599
|
+
logd(f"makedirs {scenePath}")
|
|
600
|
+
createFolder(scenePath)
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
def getMatchedJpgNum(path, startNum=0):
|
|
604
|
+
vrfFiles = listTopFiles(path, ('.vrf',))
|
|
605
|
+
vrfFiles.sort(key=lambda x: int(os.path.basename(x).split('_')[0])) # 以第一个_前面的timestamp排序
|
|
606
|
+
|
|
607
|
+
jpegFiles = listTopFiles(path, ('.jpeg', '.jpg'))
|
|
608
|
+
jpegFiles.sort(key=lambda x: int(os.path.basename(x).split('_')[0]))
|
|
609
|
+
|
|
610
|
+
jpegNum = 0
|
|
611
|
+
vaildJpgFrame = []
|
|
612
|
+
for jpgPath in jpegFiles:
|
|
613
|
+
jpgName = os.path.basename(jpgPath)
|
|
614
|
+
frameid = get_file_index('frameid_', '_', jpgName)
|
|
615
|
+
timestamp = get_file_index('', '_frameid', jpgName)
|
|
616
|
+
tmpStr = "frameid_" + str(frameid)
|
|
617
|
+
if any(tmpStr in os.path.basename(item) for item in vrfFiles):
|
|
618
|
+
jpegNum += 1
|
|
619
|
+
vaildJpgFrame.append([jpgPath, frameid, timestamp])
|
|
620
|
+
else:
|
|
621
|
+
logw(f"{jpgName} get same frame id {frameid} VRF failed")
|
|
622
|
+
createSceneFolder(path, jpegNum, startNum)
|
|
623
|
+
|
|
624
|
+
return vrfFiles, vaildJpgFrame
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def moveVrfJpg(path, outJpgPath, outVrfPath, startNum, jpgtag, vaildJpgFrame, vrfFiles):
|
|
628
|
+
facing = 'rear_primary_sensor_'
|
|
629
|
+
jpgID = startNum
|
|
630
|
+
for jpgPath, frameid, timestamp in vaildJpgFrame:
|
|
631
|
+
targetJpgPath = os.path.join(path, outJpgPath, str(jpgID) + jpgtag + '.jpeg')
|
|
632
|
+
logi(f"copy {jpgPath} -> {targetJpgPath}")
|
|
633
|
+
shutil.copy2(jpgPath, targetJpgPath)
|
|
634
|
+
vrfid = 0
|
|
635
|
+
vrfidShort = 0
|
|
636
|
+
for vrfPath in vrfFiles:
|
|
637
|
+
vrfName = os.path.basename(vrfPath)
|
|
638
|
+
vrfFrameid = get_file_index('frameid_', '_', vrfName)
|
|
639
|
+
vrfTimestamp = get_file_index('', '_frameid', vrfName)
|
|
640
|
+
if abs(vrfFrameid - frameid) <= 8 and abs(vrfTimestamp - timestamp) <= 1000000:
|
|
641
|
+
sceneFolder = "scene" + str(jpgID)
|
|
642
|
+
if 'short' in vrfName:
|
|
643
|
+
newVrfName = facing + r'hdr_' + str(vrfidShort) + '.vrf'
|
|
644
|
+
vrfidShort += 1
|
|
645
|
+
else:
|
|
646
|
+
newVrfName = facing + str(vrfid) + r'.vrf'
|
|
647
|
+
vrfid += 1
|
|
648
|
+
targetVrfPath = os.path.join(path, outVrfPath, sceneFolder, newVrfName)
|
|
649
|
+
logi(f"copy {vrfPath} -> {targetVrfPath}")
|
|
650
|
+
shutil.copy2(vrfPath, targetVrfPath)
|
|
651
|
+
|
|
652
|
+
jpgID += 1
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def shortFrameExist(scenePath):
|
|
656
|
+
vrfFiles = findFilesWithSuffix(scenePath, ('.vrf',))
|
|
657
|
+
# 检查是否存在短帧文件
|
|
658
|
+
if any('short' in os.path.basename(f) for f in vrfFiles) and len(vrfFiles) > 1:
|
|
659
|
+
logw(f"{scenePath} 存在short帧, HDR场景")
|
|
660
|
+
return True
|
|
661
|
+
return False
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
def renameShortFrame(scenePath):
|
|
665
|
+
vrfFiles = findFilesWithSuffix(scenePath, ('.vrf',))
|
|
666
|
+
# 按照 rear_primary_sensor_ 后面的数字排序
|
|
667
|
+
vrfFiles.sort(key=lambda x: int(os.path.basename(x).replace('rear_primary_sensor_', '').replace('.vrf', '')))
|
|
668
|
+
oldPath = vrfFiles[-1]
|
|
669
|
+
newPath = os.path.join(scenePath, 'rear_primary_sensor_hdr_0.vrf')
|
|
670
|
+
renameFile(oldPath, newPath)
|
|
671
|
+
logi(f"rename {oldPath} -> {newPath}")
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
def procHdrFrame(scenePath):
|
|
675
|
+
vrfFolders = [f for f in os.listdir(scenePath) if os.path.isdir(os.path.join(scenePath, f))]
|
|
676
|
+
vrfFolders.sort(key=lambda x: int(x.replace('scene', ''))) # 按照scene后面的数字排序
|
|
677
|
+
for folder in vrfFolders:
|
|
678
|
+
vrfSceneFolder = os.path.join(scenePath, folder)
|
|
679
|
+
if shortFrameExist(vrfSceneFolder):
|
|
680
|
+
renameShortFrame(vrfSceneFolder)
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
def handleAsrJpgVrf(inJpgVrfPath, startNum=0, jpgtag='_lark'):
|
|
684
|
+
outJpgPath = 'jpg'
|
|
685
|
+
outVrfPath = 'vrf'
|
|
686
|
+
|
|
687
|
+
createFolder(os.path.join(inJpgVrfPath, outJpgPath))
|
|
688
|
+
|
|
689
|
+
vrfFiles, vaildJpgList = getMatchedJpgNum(inJpgVrfPath, startNum)
|
|
690
|
+
moveVrfJpg(inJpgVrfPath, outJpgPath, outVrfPath, startNum, jpgtag, vaildJpgList, vrfFiles)
|
|
691
|
+
# procHdrFrame(os.path.join(inJpgVrfPath, outVrfPath))
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
def moveJpg(path, outJpgPath, startNum, jpgtag, jpegFiles):
|
|
695
|
+
jpgID = startNum
|
|
696
|
+
for jpgPath in jpegFiles:
|
|
697
|
+
targetJpgPath = os.path.join(path, outJpgPath, str(jpgID) + jpgtag + '.jpeg')
|
|
698
|
+
logi(f"copy {jpgPath} -> {targetJpgPath}")
|
|
699
|
+
shutil.copy2(jpgPath, targetJpgPath)
|
|
700
|
+
jpgID += 1
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
def handleRefJpg(refJpgPath, startNum=0, jpgtag='_pure70'):
|
|
704
|
+
outJpgPath = 'jpg'
|
|
705
|
+
|
|
706
|
+
createFolder(os.path.join(refJpgPath, outJpgPath))
|
|
707
|
+
|
|
708
|
+
jpegFiles = listTopFiles(refJpgPath, ('.jpeg', '.jpg'))
|
|
709
|
+
try:
|
|
710
|
+
# "IMG_20260309_135139.jpg" 提取时间戳排序
|
|
711
|
+
jpegFiles.sort(key=lambda x: re.split(r'[_.]', os.path.basename(x))[1] + re.split(r'[_.]', os.path.basename(x))[2])
|
|
712
|
+
except IndexError:
|
|
713
|
+
logw("文件命名未按照规则IMG_20260309_135139.jpg, 无法提取时间戳排序, 改为按文件名排序")
|
|
714
|
+
jpegFiles.sort()
|
|
715
|
+
|
|
716
|
+
moveJpg(refJpgPath, outJpgPath, startNum, jpgtag, jpegFiles)
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
def CLI_renameJpgVrf(argsList):
|
|
720
|
+
parser = argparse.ArgumentParser(prog="renameJpgVrf", description="按frameid匹配整理JPG/VRF文件")
|
|
721
|
+
parser.add_argument("-s", "--startnum", type=int, default=0, help="起始序号, 默认0")
|
|
722
|
+
parser.add_argument("-p", "--imagepath", type=str, required=True, help="jpg/vrf所在目录")
|
|
723
|
+
parser.add_argument("-t", "--jpgtag", type=str, default=None, help="输出jpg文件名tag, 默认_larkPro(vrf)或_pure70")
|
|
724
|
+
parser.add_argument("--vrf", action="store_true", help="按ASR jpg+vrf匹配整理; 不指定则仅按参考jpg重命名")
|
|
725
|
+
args = parser.parse_args(argsList)
|
|
726
|
+
|
|
727
|
+
if not os.path.exists(args.imagepath):
|
|
728
|
+
eExit(f"image path {args.imagepath} not exist")
|
|
729
|
+
|
|
730
|
+
jpgtag = args.jpgtag
|
|
731
|
+
if jpgtag is None:
|
|
732
|
+
jpgtag = '_larkPro' if args.vrf else '_pure70'
|
|
733
|
+
|
|
734
|
+
if args.vrf:
|
|
735
|
+
handleAsrJpgVrf(args.imagepath, args.startnum, jpgtag)
|
|
736
|
+
else:
|
|
737
|
+
handleRefJpg(args.imagepath, args.startnum, jpgtag)
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
######### renameJpgVrf end #########
|
|
741
|
+
|
|
742
|
+
|
|
575
743
|
_COMMAND_REGISTRY = {}
|
|
576
744
|
|
|
577
745
|
|
|
@@ -585,6 +753,7 @@ def printHelp():
|
|
|
585
753
|
print("vc :cut video")
|
|
586
754
|
print("v2j -h :convert video to jpg")
|
|
587
755
|
print("logcat -h :抓取andriod日志")
|
|
756
|
+
print("renameJpgVrf -h :按frameid匹配整理jpg/vrf文件")
|
|
588
757
|
|
|
589
758
|
|
|
590
759
|
CLI_timer = register_command("timer", registry=_COMMAND_REGISTRY)(CLI_timer)
|
|
@@ -595,6 +764,7 @@ CLI_eisCalc = register_command("eis", registry=_COMMAND_REGISTRY)(CLI_eisCalc)
|
|
|
595
764
|
CLI_videoCut = register_command("vc", registry=_COMMAND_REGISTRY)(CLI_videoCut)
|
|
596
765
|
CLI_video2jpg = register_command("v2j", registry=_COMMAND_REGISTRY)(CLI_video2jpg)
|
|
597
766
|
CLI_logcat = register_command("logcat", registry=_COMMAND_REGISTRY)(CLI_logcat)
|
|
767
|
+
CLI_renameJpgVrf = register_command("renameJpgVrf", registry=_COMMAND_REGISTRY)(CLI_renameJpgVrf)
|
|
598
768
|
|
|
599
769
|
|
|
600
770
|
def cmdToolMain(args):
|
|
@@ -132,18 +132,13 @@ logCallHigh = _create_log_call_func("HIGH", default_callStack=2)
|
|
|
132
132
|
logCallErr = _create_log_call_func("ERROR", default_callStack=2)
|
|
133
133
|
|
|
134
134
|
|
|
135
|
-
def exit() ->
|
|
135
|
+
def exit() -> NoReturn:
|
|
136
136
|
sys.exit(1)
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
def eExit(msg: str) -> NoReturn:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def iExit(msg: str) -> NoReturn:
|
|
145
|
-
logi(msg)
|
|
146
|
-
sys.exit(0)
|
|
140
|
+
logCallErr(msg)
|
|
141
|
+
exit()
|
|
147
142
|
|
|
148
143
|
|
|
149
144
|
# ── 命令耗时埋点 ─────────────────────────────────────────
|
|
@@ -356,14 +351,16 @@ def refreshWait(msg, times, sleep_s, func, *args):
|
|
|
356
351
|
print()
|
|
357
352
|
return
|
|
358
353
|
print()
|
|
359
|
-
|
|
354
|
+
logCallErr(f"wait for {msg} timeout")
|
|
355
|
+
exit()
|
|
360
356
|
|
|
361
357
|
|
|
362
358
|
def checkMsg(msg: str, *keywords: str) -> None:
|
|
363
359
|
if msg:
|
|
364
360
|
for kw in keywords:
|
|
365
361
|
if kw in msg.lower():
|
|
366
|
-
|
|
362
|
+
logCallErr(msg)
|
|
363
|
+
exit()
|
|
367
364
|
|
|
368
365
|
|
|
369
366
|
def parseArgs(argument_string):
|
|
@@ -870,8 +870,8 @@ class DevOp:
|
|
|
870
870
|
|
|
871
871
|
# ── 文件传输 ─────────────────────────────────────────
|
|
872
872
|
|
|
873
|
-
def pushFile(self, local, target):
|
|
874
|
-
out, err = self._adb("push", local, target)
|
|
873
|
+
def pushFile(self, local, target, timeout=10):
|
|
874
|
+
out, err = self._adb("push", local, target, timeout=timeout)
|
|
875
875
|
logi(out)
|
|
876
876
|
checkMsg(err, "failed", "device may need remount")
|
|
877
877
|
if "Read-only" in out:
|
|
@@ -21,6 +21,7 @@ from .tao_common import (
|
|
|
21
21
|
ErrCode,
|
|
22
22
|
createFolder,
|
|
23
23
|
eExit,
|
|
24
|
+
exit,
|
|
24
25
|
fileExceptionNotFound,
|
|
25
26
|
fileExceptionillegal,
|
|
26
27
|
fileExist,
|
|
@@ -853,51 +854,75 @@ class asrCamOp(DevOp):
|
|
|
853
854
|
self.facing = info.split(",")[3].split("ISP_Preview_")[1]
|
|
854
855
|
return ret
|
|
855
856
|
|
|
856
|
-
def pushVrf(self, path, id="rear_primary", renameVrf=False, ignoreTag=None, matchCase=True):
|
|
857
|
+
def pushVrf(self, path, id="rear_primary", renameVrf=False, ignoreTag=None, matchCase=True, incremental=False):
|
|
857
858
|
# id: rear_primary, front, rear_secondary
|
|
859
|
+
# incremental=True: 用 adb push --sync, 设备上已存在且未修改的 vrf 跳过传输
|
|
858
860
|
out = ""
|
|
859
861
|
if not os.path.exists(path):
|
|
860
862
|
loge(f"{path} not exist")
|
|
861
863
|
return
|
|
862
|
-
|
|
864
|
+
remoteDir = "/vendor/etc/camera"
|
|
865
|
+
# 非增量推送时先清空设备上的 vrf, 保证只剩本次推送的文件
|
|
866
|
+
if not (incremental and os.path.isdir(path)):
|
|
867
|
+
self._adb_shell(f"rm -f {remoteDir}/*.vrf")
|
|
863
868
|
if self.soc == "dove":
|
|
864
869
|
vrfEndName = "_sensor.vrf"
|
|
865
|
-
out, _ =
|
|
870
|
+
out, _ = self._adb("push", path, f"{remoteDir}/{id}{vrfEndName}", timeout=600)
|
|
866
871
|
elif self.soc in ["lark", "larkl", "larkpro"]:
|
|
867
872
|
if os.path.isfile(path):
|
|
868
873
|
vrfEndName = "_sensor_0.vrf"
|
|
869
|
-
out, _ =
|
|
870
|
-
f"adb -s {self.serial} push {path} vendor/etc/camera/{id}{vrfEndName}", showCmd=True, logLevel="info"
|
|
871
|
-
)
|
|
874
|
+
out, _ = self._adb("push", path, f"{remoteDir}/{id}{vrfEndName}", timeout=600)
|
|
872
875
|
elif os.path.isdir(path):
|
|
873
|
-
index = 0
|
|
874
|
-
shortIndex = 0
|
|
875
876
|
vrfFiles = findFilesWithSuffix(path, ".vrf")
|
|
876
877
|
if ignoreTag is not None:
|
|
877
878
|
for tag in ignoreTag:
|
|
878
879
|
vrfFiles = removeAnyContainStr(tag, vrfFiles, matchCase)
|
|
879
|
-
|
|
880
|
+
def vrfSortKey(f):
|
|
881
|
+
name = os.path.split(f)[1]
|
|
882
|
+
m = re.search(r"(\d+)\.vrf$", name)
|
|
883
|
+
num = int(m.group(1)) if m else 0
|
|
884
|
+
# hdr/short 帧单独一组, 排在普通帧之后, 各自从 0 编号
|
|
885
|
+
return ("hdr" in name or "short" in name, num)
|
|
886
|
+
|
|
887
|
+
vrfFiles.sort(key=vrfSortKey)
|
|
888
|
+
logi(f"push vrf to {remoteDir} ...")
|
|
889
|
+
for f in vrfFiles:
|
|
890
|
+
print(f)
|
|
891
|
+
# 先算出 本地文件 -> 设备文件名, 再一次性推送, 避免每个文件建一条 adb 连接
|
|
892
|
+
pairs = []
|
|
893
|
+
index = 0
|
|
894
|
+
shortIndex = 0
|
|
880
895
|
for vrf in vrfFiles:
|
|
881
|
-
if "short" in vrf:
|
|
896
|
+
if "short" in vrf or "hdr" in vrf:
|
|
882
897
|
target = f"{id}_sensor_hdr_{shortIndex}.vrf"
|
|
883
898
|
shortIndex += 1
|
|
884
899
|
else:
|
|
885
900
|
target = f"{id}_sensor_{index}.vrf"
|
|
886
901
|
index += 1
|
|
887
|
-
if renameVrf
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
902
|
+
pairs.append((vrf, target if renameVrf else os.path.split(vrf)[1]))
|
|
903
|
+
if not pairs:
|
|
904
|
+
loge(f"{path} 中没有 .vrf 文件")
|
|
905
|
+
return
|
|
906
|
+
|
|
907
|
+
if incremental:
|
|
908
|
+
# 只删本次不会再生成的 vrf, 未改动的文件交给 --sync 跳过
|
|
909
|
+
exist = self.shell(f"ls {remoteDir}/*.vrf 2>/dev/null").split()
|
|
910
|
+
keep = {target for _, target in pairs}
|
|
911
|
+
stale = [f for f in exist if os.path.split(f)[1] not in keep]
|
|
912
|
+
if stale:
|
|
913
|
+
self._adb_shell("rm -f " + " ".join(stale))
|
|
914
|
+
|
|
915
|
+
pushArgs = ["push"] + (["--sync"] if incremental else [])
|
|
916
|
+
pushArgs += [src for src, _ in pairs] + [f"{remoteDir}/"]
|
|
917
|
+
out, _ = self._adb(*pushArgs, timeout=600)
|
|
918
|
+
# 需要改名时在设备端同分区 mv(瞬间完成), 避免为每个文件再多推一次
|
|
919
|
+
renames = [
|
|
920
|
+
(os.path.split(src)[1], target)
|
|
921
|
+
for src, target in pairs
|
|
922
|
+
if os.path.split(src)[1] != target
|
|
923
|
+
]
|
|
924
|
+
if renames:
|
|
925
|
+
self._adb_shell(" && ".join(f"mv {remoteDir}/{s} {remoteDir}/{t}" for s, t in renames))
|
|
901
926
|
|
|
902
927
|
if "Read-only" in out:
|
|
903
928
|
eExit("device is Read-only, may need remount")
|
|
@@ -905,15 +930,44 @@ class asrCamOp(DevOp):
|
|
|
905
930
|
sleep(2)
|
|
906
931
|
self.tuningGetModuleGroup()
|
|
907
932
|
|
|
933
|
+
@staticmethod
|
|
934
|
+
def _tuningTargetName(fullName):
|
|
935
|
+
name = os.path.split(fullName)[1]
|
|
936
|
+
return name.split("asr_")[1] if "asr_" in fullName else name
|
|
937
|
+
|
|
908
938
|
def pushTuningFile(self, fullName):
|
|
909
939
|
if not os.path.exists(fullName):
|
|
910
940
|
loge(f"{fullName} not exist")
|
|
911
941
|
return
|
|
912
|
-
|
|
913
|
-
|
|
942
|
+
targetFile = self._tuningTargetName(fullName)
|
|
943
|
+
self.pushFile(fullName, f"/vendor/etc/camera/tuning_files/{targetFile}")
|
|
944
|
+
|
|
945
|
+
def pushTuningFiles(self, files):
|
|
946
|
+
# 一次 adb 调用推多个 .data: 小文件的耗时几乎全在 adb 连接/进程开销上
|
|
947
|
+
files = [f for f in files if os.path.isfile(f)]
|
|
948
|
+
remoteDir = "/vendor/etc/camera/tuning_files"
|
|
949
|
+
if not files:
|
|
950
|
+
loge("没有可push的tuning文件")
|
|
951
|
+
return
|
|
914
952
|
else:
|
|
915
|
-
|
|
916
|
-
|
|
953
|
+
logi(f"push tuning data to {remoteDir}...")
|
|
954
|
+
for f in files:
|
|
955
|
+
print(f)
|
|
956
|
+
|
|
957
|
+
self._adb_shell(f"mkdir -p {remoteDir}")
|
|
958
|
+
pairs = [(f, self._tuningTargetName(f)) for f in files]
|
|
959
|
+
out, _ = self._adb("push", *files, f"{remoteDir}/", timeout=600)
|
|
960
|
+
logi(out.strip().splitlines()[-1] if out.strip() else "")
|
|
961
|
+
# 去掉 asr_ 前缀的文件在设备端同分区 mv 改名, 不再单独传一次
|
|
962
|
+
renames = [
|
|
963
|
+
(os.path.split(src)[1], target)
|
|
964
|
+
for src, target in pairs
|
|
965
|
+
if os.path.split(src)[1] != target
|
|
966
|
+
]
|
|
967
|
+
if renames:
|
|
968
|
+
self._adb_shell(" && ".join(f"mv {remoteDir}/{s} {remoteDir}/{t}" for s, t in renames))
|
|
969
|
+
if "Read-only" in out:
|
|
970
|
+
eExit("device is Read-only, may need remount")
|
|
917
971
|
|
|
918
972
|
def saveTuningFile(self, outPath, file, paramlist, delInfo):
|
|
919
973
|
module = "m" + paramlist[0] + "_g" + paramlist[2]
|
|
@@ -1231,19 +1285,6 @@ def CLI_tuningRemoveInfo(argsList):
|
|
|
1231
1285
|
loge(f"{inFile} is not a valid file or directory")
|
|
1232
1286
|
|
|
1233
1287
|
|
|
1234
|
-
# def CLI_pushVrf(args):
|
|
1235
|
-
# argsDict = {}
|
|
1236
|
-
# if args:
|
|
1237
|
-
# argsDict = parseArgs(" ".join(args))
|
|
1238
|
-
# idx = argsDict.get("i", "0")
|
|
1239
|
-
# rename = int(argsDict.get("r", 0))
|
|
1240
|
-
# dev = asrCamOp()
|
|
1241
|
-
# if os.path.exists(args[1]):
|
|
1242
|
-
# dev.pushVrf(args[1], idx, rename)
|
|
1243
|
-
# else:
|
|
1244
|
-
# loge(f"cmd error, psvrf name.vrf/path [i=0,1,2]cameraId [r=0,1]renameVrf")
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
1288
|
def CLI_pushVrf(argsList):
|
|
1248
1289
|
parser = argparse.ArgumentParser(prog="pushvrf", description="push vrf到设备")
|
|
1249
1290
|
parser.add_argument("posPath", nargs="?", default=None, help="vrf文件名或路径, 可直接输入(psvrf xxx.vrf)")
|
|
@@ -1262,19 +1303,24 @@ def CLI_pushVrf(argsList):
|
|
|
1262
1303
|
)
|
|
1263
1304
|
parser.add_argument("--matchcase", action="store_true", dest="matchcase", help="是否区分tag大小写")
|
|
1264
1305
|
parser.set_defaults(matchcase=False)
|
|
1306
|
+
parser.add_argument("--sync", action="store_true", dest="sync", help="增量推送: 设备上已存在且未修改的vrf跳过传输")
|
|
1307
|
+
parser.set_defaults(sync=False)
|
|
1265
1308
|
args = parser.parse_args(argsList)
|
|
1266
1309
|
if args.path is None:
|
|
1267
1310
|
args.path = args.posPath
|
|
1268
1311
|
if args.path is None:
|
|
1269
1312
|
parser.error("至少需要指定vrf文件名或路径")
|
|
1270
1313
|
|
|
1271
|
-
logi(
|
|
1314
|
+
logi(
|
|
1315
|
+
f"psvrf {args.path} indxe={args.index}, rename={args.rename}, ignoreTag={args.tag}, "
|
|
1316
|
+
f"matchcase={args.matchcase}, sync={args.sync}"
|
|
1317
|
+
)
|
|
1272
1318
|
|
|
1273
|
-
dev = asrCamOp()
|
|
1274
1319
|
if os.path.exists(args.path):
|
|
1275
|
-
dev
|
|
1320
|
+
dev = asrCamOp()
|
|
1321
|
+
dev.pushVrf(args.path, args.index, args.rename, args.tag, args.matchcase, args.sync)
|
|
1276
1322
|
else:
|
|
1277
|
-
loge(f"
|
|
1323
|
+
loge(f"{args.path} not exist")
|
|
1278
1324
|
|
|
1279
1325
|
|
|
1280
1326
|
def CLI_capVrf(argsList):
|
|
@@ -1363,10 +1409,11 @@ def CLI_pushTuning(argsList):
|
|
|
1363
1409
|
if os.path.isfile(inFile):
|
|
1364
1410
|
asrCam.pushTuningFile(inFile)
|
|
1365
1411
|
elif os.path.isdir(inFile):
|
|
1366
|
-
for f in os.listdir(inFile)
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1412
|
+
dataFiles = sorted(os.path.join(inFile, f) for f in os.listdir(inFile) if f.endswith(".data"))
|
|
1413
|
+
if dataFiles:
|
|
1414
|
+
asrCam.pushTuningFiles(dataFiles)
|
|
1415
|
+
else:
|
|
1416
|
+
loge(f"{inFile} 中没有 .data 文件")
|
|
1370
1417
|
else:
|
|
1371
1418
|
loge(f"{inFile} is not a valid file or directory")
|
|
1372
1419
|
|
|
@@ -1386,7 +1433,7 @@ def CLI_tuning2c(argsList):
|
|
|
1386
1433
|
sensorName = args.prefix
|
|
1387
1434
|
if args.prefix is None and os.path.isdir(inFile):
|
|
1388
1435
|
suffix = "_isp_preview.h"
|
|
1389
|
-
for file in Path(inFile).
|
|
1436
|
+
for file in Path(inFile).glob(f"*{suffix}"):
|
|
1390
1437
|
# file.name 是完整文件名,去掉后缀部分就是前面的字符串
|
|
1391
1438
|
sensorName = file.name[:-len(suffix)]
|
|
1392
1439
|
|
|
@@ -1470,6 +1517,275 @@ def CLI_osd(_args):
|
|
|
1470
1517
|
dev.adbCmd("touch /data/local/tmp/isp.txt", True, 0)
|
|
1471
1518
|
|
|
1472
1519
|
|
|
1520
|
+
def CSV_Write(xlsxName, sheetName, frameInfo):
|
|
1521
|
+
from openpyxl import Workbook, load_workbook
|
|
1522
|
+
|
|
1523
|
+
# 创建一个工作簿对象
|
|
1524
|
+
try:
|
|
1525
|
+
if os.path.exists(xlsxName):
|
|
1526
|
+
wb = load_workbook(filename=xlsxName)
|
|
1527
|
+
else:
|
|
1528
|
+
wb = Workbook()
|
|
1529
|
+
except PermissionError:
|
|
1530
|
+
eExit(f"打开 {xlsxName} 失败,请确认文件是否关闭")
|
|
1531
|
+
sheet_names = wb.sheetnames
|
|
1532
|
+
if "Sheet" in sheet_names:
|
|
1533
|
+
del wb["Sheet"]
|
|
1534
|
+
|
|
1535
|
+
ws = wb.create_sheet(title=sheetName)
|
|
1536
|
+
wb.active = ws
|
|
1537
|
+
|
|
1538
|
+
sheetHead = ['scene', 'r', 'g', 'b', 'cct', 'tint']
|
|
1539
|
+
ws.append(sheetHead)
|
|
1540
|
+
|
|
1541
|
+
for row in frameInfo:
|
|
1542
|
+
ws.append(row)
|
|
1543
|
+
|
|
1544
|
+
wb.save(xlsxName)
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
def genCaseInfo(vrfPath, startScene, endScene):
|
|
1548
|
+
endScene = endScene + 1
|
|
1549
|
+
totalScene = endScene - startScene - 1
|
|
1550
|
+
infoFile = "caseInfo.log"
|
|
1551
|
+
with open(os.path.join(vrfPath, infoFile), "w") as f:
|
|
1552
|
+
for currentCase in range(startScene, endScene):
|
|
1553
|
+
logh(f"procFileCamess {currentCase}/{totalScene}")
|
|
1554
|
+
if hdrFrameExist(os.path.join(vrfPath, 'scene' + str(currentCase))):
|
|
1555
|
+
writeStr = f"scene {currentCase} HDR\n"
|
|
1556
|
+
else:
|
|
1557
|
+
writeStr = f"scene {currentCase} -- SDR\n"
|
|
1558
|
+
f.write(writeStr)
|
|
1559
|
+
logi(writeStr)
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
def enableTuning(tuningPath, dev):
|
|
1563
|
+
if not os.path.exists(tuningPath):
|
|
1564
|
+
eExit(f"tuning file {tuningPath} not exist")
|
|
1565
|
+
|
|
1566
|
+
if os.path.isdir(tuningPath):
|
|
1567
|
+
dataFiles = sorted(os.path.join(tuningPath, f) for f in os.listdir(tuningPath) if f.endswith(".data"))
|
|
1568
|
+
if dataFiles:
|
|
1569
|
+
dev.pushTuningFiles(dataFiles)
|
|
1570
|
+
else:
|
|
1571
|
+
loge(f"{tuningPath} 中没有 .data 文件")
|
|
1572
|
+
|
|
1573
|
+
rCmd('adb shell setprop persist.vendor.camera.enable.settingfile 1')
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
def hdrFrameExist(scenePath):
|
|
1577
|
+
vrfFiles = findFilesWithSuffix(scenePath, ".vrf")
|
|
1578
|
+
for i in vrfFiles:
|
|
1579
|
+
if 'hdr' in i:
|
|
1580
|
+
return True
|
|
1581
|
+
logi(f"{scenePath} 非HDR场景")
|
|
1582
|
+
return False
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
def getAWBGainFromVrf(vrfFile):
|
|
1586
|
+
from .asrVrf import Vrf
|
|
1587
|
+
|
|
1588
|
+
vrf = Vrf()
|
|
1589
|
+
vrf.Read(vrfFile)
|
|
1590
|
+
logi(f"get AWB gain from {vrfFile} R:{vrf.AWBGainR} G:{vrf.AWBGainG} B:{vrf.AWBGainB}")
|
|
1591
|
+
return vrf.AWBGainR << 5, vrf.AWBGainG << 5, vrf.AWBGainB << 5
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
def setManualWB(dev, rgbGain):
|
|
1595
|
+
rGain, gGain, bGain = rgbGain
|
|
1596
|
+
dev.writeIsp("CWbFirmwareFilter", "m_nMode", 0, 0, 1, showCmd=False)
|
|
1597
|
+
dev.writeIsp("CWbFirmwareFilter", "m_pManualGain", 0, 0, rGain, showCmd=False)
|
|
1598
|
+
dev.writeIsp("CWbFirmwareFilter", "m_pManualGain", 0, 1, gGain, showCmd=False)
|
|
1599
|
+
dev.writeIsp("CWbFirmwareFilter", "m_pManualGain", 0, 2, bGain, showCmd=False)
|
|
1600
|
+
|
|
1601
|
+
|
|
1602
|
+
def writeFrameInfoToTxt(path, tag, frameInfoList):
|
|
1603
|
+
filename = os.path.join(path, f"frameInfo{tag}.txt")
|
|
1604
|
+
with open(filename, 'a') as file:
|
|
1605
|
+
file.write(' '.join(str(x) for x in frameInfoList) + '\n')
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
def getFrameInfo(dev, frameInfoCnt: int, currentCase: str, frameInfo=None):
|
|
1609
|
+
if frameInfo is not None:
|
|
1610
|
+
try:
|
|
1611
|
+
r = dev.readIsp("CWbFirmwareFilter", "m_sWBGainBase", 0, 0)
|
|
1612
|
+
g = dev.readIsp("CWbFirmwareFilter", "m_sWBGainBase", 0, 1)
|
|
1613
|
+
b = dev.readIsp("CWbFirmwareFilter", "m_sWBGainBase", 0, 2)
|
|
1614
|
+
cct = dev.readIsp("CWbFirmwareFilter", "m_nCCTBase", 0, 0)
|
|
1615
|
+
tint = dev.readIsp("CWbFirmwareFilter", "m_nTintBase", 0, 0)
|
|
1616
|
+
frameInfo[frameInfoCnt] = [currentCase, r, g, b, cct, tint]
|
|
1617
|
+
except Exception as e:
|
|
1618
|
+
loge(f"get Frame Info error:{e}")
|
|
1619
|
+
frameInfo[frameInfoCnt] = [currentCase, 0, 0, 0, 0, 0]
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
def fileCamSingle(dev, vrfPath, jpgPath, currentCase, endScene, totalScene, frameInfoCnt=0,
|
|
1623
|
+
useVrfWbGain=False, tag='', hdr4frame=True, frameInfo=None):
|
|
1624
|
+
logh(f"procFileCamess {currentCase}/{endScene} , total {totalScene}")
|
|
1625
|
+
|
|
1626
|
+
if dev.soc == "larkpro":
|
|
1627
|
+
if useVrfWbGain:
|
|
1628
|
+
rgbGain = getAWBGainFromVrf(os.path.join(vrfPath, 'scene' + str(currentCase), 'rear_primary_sensor_0.vrf'))
|
|
1629
|
+
|
|
1630
|
+
targetPath = "/vendor/etc/camera/"
|
|
1631
|
+
dev.pushVrf(os.path.join(vrfPath, 'scene' + str(currentCase)), targetPath)
|
|
1632
|
+
if hdr4frame:
|
|
1633
|
+
dev.adbCmd(f"rm {targetPath}/*_4*.vrf")
|
|
1634
|
+
dev.adbCmd(f"rm {targetPath}/*_5*.vrf")
|
|
1635
|
+
|
|
1636
|
+
sleep(1)
|
|
1637
|
+
dev.writeIsp("CBinningV3FirmwareFilter", "m_nMaxSupportBinningRatio", 0, 0, 2048) # larkpro 最小binning 避免带宽问题
|
|
1638
|
+
|
|
1639
|
+
# 临时删除HDR帧,跑SDR
|
|
1640
|
+
dev.pushVrf(os.path.join(vrfPath, 'scene' + str(currentCase)), renameVrf=False, ignoreTag=['hdr', ])
|
|
1641
|
+
|
|
1642
|
+
# 如果不存在短帧,将HDR门限拉高,避免实拍帧数不满足未进入HDR,file camera进入HDR模式,导致拍照失败
|
|
1643
|
+
isHdr = hdrFrameExist(os.path.join(vrfPath, 'scene' + str(currentCase)))
|
|
1644
|
+
|
|
1645
|
+
m_nHDRCapSatRefBin = dev.readIsp("CAECFilter", "m_nHDRCapSatRefBin", 0, 0)
|
|
1646
|
+
if not isHdr:
|
|
1647
|
+
logh(f"scene {currentCase} short frame not exist, disable HDR")
|
|
1648
|
+
dev.writeIsp("CAECFilter", "m_nHDRCapSatRefBin", 0, 0, 255) # 强制关闭HDR
|
|
1649
|
+
for i in range(12):
|
|
1650
|
+
dev.writeIsp("CAECFilter", "m_pAutoHDRCapSatPerThr", 0, i, 100.0)
|
|
1651
|
+
else:
|
|
1652
|
+
logh(f"scene {currentCase} short frame exist, enable HDR")
|
|
1653
|
+
dev.writeIsp("CAECFilter", "m_nHDRCapSatRefBin", 0, 0, 0) # 强制触发HDR
|
|
1654
|
+
sleep(4)
|
|
1655
|
+
if sysVersion == "Linux":
|
|
1656
|
+
logw("Linux环境不支持tuning_assistant,无法设置WB Gain,跳过")
|
|
1657
|
+
else:
|
|
1658
|
+
if useVrfWbGain:
|
|
1659
|
+
logh(f"set manual WB from VRF {rgbGain}")
|
|
1660
|
+
setManualWB(dev, rgbGain)
|
|
1661
|
+
sleep(6)
|
|
1662
|
+
currentSceneHdr = int(dev.readIsp("CAECFilter", "m_bAutoHDRFlag", 0, 0))
|
|
1663
|
+
hdrTag = {0: 'SDR', 1: 'HDR'}
|
|
1664
|
+
jpgName = os.path.join(jpgPath, str(currentCase) + tag + '_' + hdrTag[currentSceneHdr])
|
|
1665
|
+
ret = dev.capJPG(jpgName, wait=8)
|
|
1666
|
+
|
|
1667
|
+
if not isHdr:
|
|
1668
|
+
dev.writeIsp("CAECFilter", "m_nHDRCapSatRefBin", 0, 0, m_nHDRCapSatRefBin)
|
|
1669
|
+
|
|
1670
|
+
elif dev.soc == "lark" or dev.soc == "larkl":
|
|
1671
|
+
if useVrfWbGain:
|
|
1672
|
+
rgbGain = getAWBGainFromVrf(os.path.join(vrfPath, 'scene' + str(currentCase), 'rear_primary_sensor_0.vrf'))
|
|
1673
|
+
|
|
1674
|
+
targetPath = "/vendor/etc/camera/"
|
|
1675
|
+
dev.pushVrf(os.path.join(vrfPath, 'scene' + str(currentCase)), targetPath)
|
|
1676
|
+
|
|
1677
|
+
sleep(4)
|
|
1678
|
+
|
|
1679
|
+
if sysVersion == "Linux":
|
|
1680
|
+
logw("Linux环境不支持tuning_assistant,无法设置WB Gain,跳过")
|
|
1681
|
+
else:
|
|
1682
|
+
if useVrfWbGain:
|
|
1683
|
+
logh(f"set manual WB from VRF {rgbGain}")
|
|
1684
|
+
setManualWB(dev, rgbGain)
|
|
1685
|
+
sleep(6)
|
|
1686
|
+
|
|
1687
|
+
jpgName = os.path.join(jpgPath, str(currentCase) + tag)
|
|
1688
|
+
ret = dev.capJPG(jpgName, wait=8)
|
|
1689
|
+
|
|
1690
|
+
if frameInfo is not None:
|
|
1691
|
+
getFrameInfo(dev, frameInfoCnt, currentCase, frameInfo)
|
|
1692
|
+
writeFrameInfoToTxt(jpgPath, tag, frameInfo[frameInfoCnt])
|
|
1693
|
+
|
|
1694
|
+
if not ret:
|
|
1695
|
+
loge("拍照失败,请检查camera是否报错,camera 多帧;HDR,闪光灯模式是否与case匹配")
|
|
1696
|
+
return ret
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
def fileCamAll(vrfPath, jpgPath, tuningPath, startScene, endScene, useVrfWbGain=False,
|
|
1700
|
+
tag='', hdr4frame=True, recordFrameInfo=False):
|
|
1701
|
+
dev = asrCamOp(needRoot=True)
|
|
1702
|
+
enableTuning(tuningPath, dev)
|
|
1703
|
+
|
|
1704
|
+
endloop = endScene + 1
|
|
1705
|
+
totalScene = endloop - startScene
|
|
1706
|
+
if recordFrameInfo:
|
|
1707
|
+
frameInfo = [[] for i in range(totalScene)]
|
|
1708
|
+
else:
|
|
1709
|
+
frameInfo = None
|
|
1710
|
+
frameInfoCnt = 0
|
|
1711
|
+
|
|
1712
|
+
for currentCase in range(startScene, endloop):
|
|
1713
|
+
if not fileCamSingle(dev, vrfPath, jpgPath, currentCase, endScene, totalScene, frameInfoCnt,
|
|
1714
|
+
useVrfWbGain, tag, hdr4frame, frameInfo):
|
|
1715
|
+
dev.getConnectedDevices()
|
|
1716
|
+
dev.killCamera() # capture failed, retry
|
|
1717
|
+
fileCamSingle(dev, vrfPath, jpgPath, currentCase, endScene, totalScene, frameInfoCnt,
|
|
1718
|
+
useVrfWbGain, tag, hdr4frame, frameInfo)
|
|
1719
|
+
frameInfoCnt += 1
|
|
1720
|
+
return frameInfo
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
def procFileCam(tuningPathBase, vrfPath, jpgPath, caseID, recordCaseInfo, recordFrameInfo,
|
|
1724
|
+
startScene, endScene, tuningPath, useVrfWbGain, jpgTag, hdr4frame):
|
|
1725
|
+
if not os.path.exists(tuningPathBase):
|
|
1726
|
+
eExit(f"tuning path {tuningPathBase} not exist")
|
|
1727
|
+
if not os.path.exists(vrfPath):
|
|
1728
|
+
eExit(f"vrf path {vrfPath} not exist")
|
|
1729
|
+
if not os.path.exists(jpgPath):
|
|
1730
|
+
os.makedirs(jpgPath)
|
|
1731
|
+
|
|
1732
|
+
if caseID == '-1':
|
|
1733
|
+
if recordCaseInfo:
|
|
1734
|
+
genCaseInfo(vrfPath, startScene, endScene)
|
|
1735
|
+
frameInfo = fileCamAll(vrfPath, jpgPath, tuningPath, startScene, endScene, useVrfWbGain,
|
|
1736
|
+
jpgTag, hdr4frame, recordFrameInfo)
|
|
1737
|
+
if recordFrameInfo:
|
|
1738
|
+
CSV_Write(os.path.join(jpgPath, "frameInfo.xlsx"), jpgTag, frameInfo)
|
|
1739
|
+
else:
|
|
1740
|
+
dev = asrCamOp(needRoot=True)
|
|
1741
|
+
enableTuning(tuningPath, dev)
|
|
1742
|
+
fileCamSingle(dev, vrfPath, jpgPath, caseID, caseID, 1, 0, useVrfWbGain, jpgTag, hdr4frame)
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
def CLI_fileCam(argsList):
|
|
1746
|
+
"""按 case 推 VRF / tuning 并抓 jpg"""
|
|
1747
|
+
parser = argparse.ArgumentParser(prog="filecam", description="按case抓图/生成case信息")
|
|
1748
|
+
parser.add_argument("-i", "--caseID", default="-1", help="只处理指定case, 指定后忽略 startScene/endScene")
|
|
1749
|
+
parser.add_argument("--tuningPathBase", default=r'.\tuning', help="tuning 根目录")
|
|
1750
|
+
parser.add_argument("--vrfPath", default=r'.\vrf', help=r"vrf 所在目录, 结构为 .\vrf\scene0\rear_primary_sensor_0.vrf")
|
|
1751
|
+
parser.add_argument("--jpgPath", default=r'.\jpg', help="jpg 输出目录")
|
|
1752
|
+
parser.add_argument("--tuningFolder", default="tuning_data_20261130", help="tuning data 所在文件夹名")
|
|
1753
|
+
parser.add_argument("--tagPre", default="_a17_", help="jpg 标签前缀")
|
|
1754
|
+
parser.add_argument("--tag1", default="20261130_r1", help="jpg 标签")
|
|
1755
|
+
parser.add_argument("--startScene", type=int, default=0)
|
|
1756
|
+
parser.add_argument("--endScene", type=int, default=None, help="默认按 vrfPath 下 scene 目录数量计算")
|
|
1757
|
+
parser.add_argument("--useVrfWbGain", action="store_true", help="是否使用VRF的WB Gain, Windows支持")
|
|
1758
|
+
parser.add_argument("--recordFrameInfo", action="store_true", help="是否将frame Info记录到csv文件")
|
|
1759
|
+
parser.add_argument("--recordCaseInfo", action="store_true", help="是否生成case信息")
|
|
1760
|
+
parser.add_argument("--hdr4frame", action="store_true", help="是否只使用4帧 normal")
|
|
1761
|
+
args = parser.parse_args(argsList)
|
|
1762
|
+
|
|
1763
|
+
tuningPath = os.path.join(args.tuningPathBase, args.tuningFolder)
|
|
1764
|
+
if not os.path.isdir(tuningPath):
|
|
1765
|
+
eExit(f"tuning folder {tuningPath} not exist")
|
|
1766
|
+
if not os.path.isdir(args.vrfPath):
|
|
1767
|
+
eExit(f"vrf path {args.vrfPath} not exist")
|
|
1768
|
+
|
|
1769
|
+
caseID = str(args.caseID)
|
|
1770
|
+
if caseID == "-1":
|
|
1771
|
+
startScene = args.startScene
|
|
1772
|
+
if args.endScene is not None:
|
|
1773
|
+
endScene = args.endScene
|
|
1774
|
+
else:
|
|
1775
|
+
endScene = sum(1 for name in os.listdir(args.vrfPath)
|
|
1776
|
+
if os.path.isdir(os.path.join(args.vrfPath, name)) and "scene" in name.lower()
|
|
1777
|
+
) - 1
|
|
1778
|
+
input("请确认多帧模式切换为low, hdr auto, flash off")
|
|
1779
|
+
else:
|
|
1780
|
+
# 指定 caseID 时只跑这一个 case, 不再使用 startScene/endScene
|
|
1781
|
+
startScene = endScene = 0
|
|
1782
|
+
|
|
1783
|
+
jpgTag = args.tagPre + args.tag1
|
|
1784
|
+
procFileCam(args.tuningPathBase, args.vrfPath, args.jpgPath, caseID, args.recordCaseInfo,
|
|
1785
|
+
args.recordFrameInfo, startScene, endScene, tuningPath, args.useVrfWbGain,
|
|
1786
|
+
jpgTag, args.hdr4frame)
|
|
1787
|
+
|
|
1788
|
+
|
|
1473
1789
|
_COMMAND_REGISTRY = {}
|
|
1474
1790
|
|
|
1475
1791
|
|
|
@@ -1484,6 +1800,7 @@ def printHelp():
|
|
|
1484
1800
|
print("tuningr -h :remove readonly info")
|
|
1485
1801
|
print("ipc {off} :connect camera with ip address")
|
|
1486
1802
|
print("osd :install osd app")
|
|
1803
|
+
print("filecam -h :push vrf/tuning by scene and capture jpg")
|
|
1487
1804
|
|
|
1488
1805
|
|
|
1489
1806
|
CLI_pushVrf = register_command("psvrf", registry=_COMMAND_REGISTRY)(CLI_pushVrf)
|
|
@@ -1495,6 +1812,7 @@ CLI_c2tuning = register_command("c2tuning", registry=_COMMAND_REGISTRY)(CLI_c2tu
|
|
|
1495
1812
|
CLI_tuningRemoveInfo = register_command("tuningr", registry=_COMMAND_REGISTRY)(CLI_tuningRemoveInfo)
|
|
1496
1813
|
CLI_netCon = register_command("ipc", registry=_COMMAND_REGISTRY)(CLI_netCon)
|
|
1497
1814
|
CLI_osd = register_command("osd", registry=_COMMAND_REGISTRY)(CLI_osd)
|
|
1815
|
+
CLI_fileCam = register_command("filecam", registry=_COMMAND_REGISTRY)(CLI_fileCam)
|
|
1498
1816
|
|
|
1499
1817
|
|
|
1500
1818
|
def tuningMain(args):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|