taotoolkit 2.0.9__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.9 → taotoolkit-2.1.0}/PKG-INFO +1 -1
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/pyproject.toml +1 -1
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/__init__.py +1 -1
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_cmdTool.py +164 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_tuning.py +271 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit.egg-info/PKG-INFO +1 -1
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/README.md +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/setup.cfg +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/asrVrf.py +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_camDvt.py +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_common.py +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_device.py +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_flash.py +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit/tao_vrfTool.py +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit.egg-info/SOURCES.txt +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit.egg-info/dependency_links.txt +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit.egg-info/requires.txt +0 -0
- {taotoolkit-2.0.9 → taotoolkit-2.1.0}/taotoolkit.egg-info/top_level.txt +0 -0
|
@@ -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,
|
|
@@ -578,6 +585,161 @@ def CLI_video2jpg(argsList):
|
|
|
578
585
|
oCmd(cmd, sleep_s=1.0, showCmd=True, logLevel="info")
|
|
579
586
|
|
|
580
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
|
+
|
|
581
743
|
_COMMAND_REGISTRY = {}
|
|
582
744
|
|
|
583
745
|
|
|
@@ -591,6 +753,7 @@ def printHelp():
|
|
|
591
753
|
print("vc :cut video")
|
|
592
754
|
print("v2j -h :convert video to jpg")
|
|
593
755
|
print("logcat -h :抓取andriod日志")
|
|
756
|
+
print("renameJpgVrf -h :按frameid匹配整理jpg/vrf文件")
|
|
594
757
|
|
|
595
758
|
|
|
596
759
|
CLI_timer = register_command("timer", registry=_COMMAND_REGISTRY)(CLI_timer)
|
|
@@ -601,6 +764,7 @@ CLI_eisCalc = register_command("eis", registry=_COMMAND_REGISTRY)(CLI_eisCalc)
|
|
|
601
764
|
CLI_videoCut = register_command("vc", registry=_COMMAND_REGISTRY)(CLI_videoCut)
|
|
602
765
|
CLI_video2jpg = register_command("v2j", registry=_COMMAND_REGISTRY)(CLI_video2jpg)
|
|
603
766
|
CLI_logcat = register_command("logcat", registry=_COMMAND_REGISTRY)(CLI_logcat)
|
|
767
|
+
CLI_renameJpgVrf = register_command("renameJpgVrf", registry=_COMMAND_REGISTRY)(CLI_renameJpgVrf)
|
|
604
768
|
|
|
605
769
|
|
|
606
770
|
def cmdToolMain(args):
|
|
@@ -1517,6 +1517,275 @@ def CLI_osd(_args):
|
|
|
1517
1517
|
dev.adbCmd("touch /data/local/tmp/isp.txt", True, 0)
|
|
1518
1518
|
|
|
1519
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
|
+
|
|
1520
1789
|
_COMMAND_REGISTRY = {}
|
|
1521
1790
|
|
|
1522
1791
|
|
|
@@ -1531,6 +1800,7 @@ def printHelp():
|
|
|
1531
1800
|
print("tuningr -h :remove readonly info")
|
|
1532
1801
|
print("ipc {off} :connect camera with ip address")
|
|
1533
1802
|
print("osd :install osd app")
|
|
1803
|
+
print("filecam -h :push vrf/tuning by scene and capture jpg")
|
|
1534
1804
|
|
|
1535
1805
|
|
|
1536
1806
|
CLI_pushVrf = register_command("psvrf", registry=_COMMAND_REGISTRY)(CLI_pushVrf)
|
|
@@ -1542,6 +1812,7 @@ CLI_c2tuning = register_command("c2tuning", registry=_COMMAND_REGISTRY)(CLI_c2tu
|
|
|
1542
1812
|
CLI_tuningRemoveInfo = register_command("tuningr", registry=_COMMAND_REGISTRY)(CLI_tuningRemoveInfo)
|
|
1543
1813
|
CLI_netCon = register_command("ipc", registry=_COMMAND_REGISTRY)(CLI_netCon)
|
|
1544
1814
|
CLI_osd = register_command("osd", registry=_COMMAND_REGISTRY)(CLI_osd)
|
|
1815
|
+
CLI_fileCam = register_command("filecam", registry=_COMMAND_REGISTRY)(CLI_fileCam)
|
|
1545
1816
|
|
|
1546
1817
|
|
|
1547
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
|
|
File without changes
|
|
File without changes
|