初始化
parent
8a0097fb2f
commit
348ef50468
@ -0,0 +1,14 @@
|
|||||||
|
/venv/
|
||||||
|
# 忽略 build 目录
|
||||||
|
/build/
|
||||||
|
|
||||||
|
# 忽略 dist 目录
|
||||||
|
/dist/
|
||||||
|
|
||||||
|
# 忽略 image 目录
|
||||||
|
/image/
|
||||||
|
|
||||||
|
# 忽略 Mv3dRgbdLog 文件或目录
|
||||||
|
/Mv3dRgbdLog/
|
||||||
|
|
||||||
|
/.idea/
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
['main.py'],
|
||||||
|
pathex=[],
|
||||||
|
binaries=[],
|
||||||
|
datas=[('dlls', '_internal\\\\dlls')],
|
||||||
|
hiddenimports=['cv2.cv2', 'numpy.core._methods', 'numpy.lib.format', 'scipy.__config__', 'scipy._distributor_init', 'scipy.sparse.csgraph._validation', 'scipy.special._ellip_harm_2', 'scipy._cyutility', 'scipy._lib._ccallback', 'scipy.linalg.cython_blas', 'scipy.linalg.cython_lapack', 'scipy.optimize._highs._highs_constants', 'scipy.optimize._highs._highs_wrapper', 'sklearn.utils._weight_vector', 'sklearn.utils._weight_vector_fast', 'sklearn.tree._utils'],
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=['tkinter', 'PyQt5'],
|
||||||
|
noarchive=False,
|
||||||
|
optimize=0,
|
||||||
|
)
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
[],
|
||||||
|
exclude_binaries=True,
|
||||||
|
name='Hik3DApp',
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
console=True,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
icon=['app.png'],
|
||||||
|
)
|
||||||
|
coll = COLLECT(
|
||||||
|
exe,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
upx_exclude=[],
|
||||||
|
name='Hik3DApp',
|
||||||
|
)
|
||||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,144 @@
|
|||||||
|
# -- coding: utf-8 --
|
||||||
|
import threading
|
||||||
|
import msvcrt
|
||||||
|
import ctypes
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
import struct
|
||||||
|
from ctypes import *
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from Mv3dRgbdImport.Mv3dRgbdDefine import *
|
||||||
|
from Mv3dRgbdImport.Mv3dRgbdApi import *
|
||||||
|
from Mv3dRgbdImport.Mv3dRgbdDefine import DeviceType_Ethernet, DeviceType_USB, DeviceType_Ethernet_Vir, DeviceType_USB_Vir, MV3D_RGBD_FLOAT_EXPOSURETIME, \
|
||||||
|
ParamType_Float, ParamType_Int, ParamType_Enum, CoordinateType_Depth, MV3D_RGBD_FLOAT_Z_UNIT, MV3D_RGBD_OK, \
|
||||||
|
FileType_BMP,FileType_TIFF,ImageType_Depth, ImageType_RGB8_Planar, ImageType_YUV420SP_NV12 ,ImageType_YUV420SP_NV21 , ImageType_YUV422, ImageType_Mono8
|
||||||
|
|
||||||
|
import config as configMap
|
||||||
|
|
||||||
|
# 全局变量
|
||||||
|
SN_MAP = {} # {sn: camera_instance}
|
||||||
|
|
||||||
|
|
||||||
|
def initialize_devices():
|
||||||
|
nDeviceNum = ctypes.c_uint(0)
|
||||||
|
ret = Mv3dRgbd.MV3D_RGBD_GetDeviceNumber(
|
||||||
|
DeviceType_Ethernet | DeviceType_USB | DeviceType_Ethernet_Vir | DeviceType_USB_Vir,
|
||||||
|
byref(nDeviceNum)
|
||||||
|
)
|
||||||
|
if ret != MV3D_RGBD_OK or nDeviceNum.value == 0:
|
||||||
|
print("Failed to get device number or no devices found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
stDeviceList = MV3D_RGBD_DEVICE_INFO_LIST()
|
||||||
|
Mv3dRgbd.MV3D_RGBD_GetDeviceList(
|
||||||
|
DeviceType_Ethernet | DeviceType_USB | DeviceType_Ethernet_Vir | DeviceType_USB_Vir,
|
||||||
|
pointer(stDeviceList.DeviceInfo[0]), 20, byref(nDeviceNum)
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(nDeviceNum.value):
|
||||||
|
serial_number = ''.join(chr(c) for c in stDeviceList.DeviceInfo[i].chSerialNumber).rstrip('\x00')
|
||||||
|
print(f"Found device [{i}]: Serial Number: {serial_number}")
|
||||||
|
|
||||||
|
camera = Mv3dRgbd()
|
||||||
|
|
||||||
|
# 打开设备
|
||||||
|
ret = camera.MV3D_RGBD_OpenDevice(pointer(stDeviceList.DeviceInfo[i]))
|
||||||
|
if ret != MV3D_RGBD_OK:
|
||||||
|
print(f"Failed to open device with SN: {serial_number}. Error code: {ret:#x}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 存入全局 map
|
||||||
|
SN_MAP[serial_number] = camera
|
||||||
|
print(f"Successfully added device {serial_number} to SN_MAP")
|
||||||
|
|
||||||
|
|
||||||
|
def pic(sn):
|
||||||
|
camera = SN_MAP.get(sn)
|
||||||
|
|
||||||
|
if not camera:
|
||||||
|
print(f"No camera found for SN: {sn}")
|
||||||
|
return
|
||||||
|
|
||||||
|
config = configMap.CAMERA_CONFIG_MAP.get(sn)
|
||||||
|
if not config:
|
||||||
|
print(f"No config found for SN: {sn}")
|
||||||
|
return
|
||||||
|
|
||||||
|
time_on = config.get("time_on", 0) # 延时开始(毫秒)
|
||||||
|
time_off = config.get("time_off", 0) # 拍照总时长(毫秒)
|
||||||
|
time_hop = config.get("time_hop", 0) # 每次拍照间隔(毫秒)
|
||||||
|
|
||||||
|
end_time = time.time() + (time_off / 1000.0)
|
||||||
|
print(f"Delaying start by {time_on}ms...")
|
||||||
|
time.sleep(time_on / 1000.0) # 转成秒
|
||||||
|
|
||||||
|
|
||||||
|
frame_count = 0
|
||||||
|
|
||||||
|
saved_tiff_files = [] # 用于存储保存的 TIFF 文件路径
|
||||||
|
print(f"Start continuous capturing for {time_off}ms...")
|
||||||
|
|
||||||
|
# 开始取流
|
||||||
|
ret = camera.MV3D_RGBD_Start()
|
||||||
|
if ret != MV3D_RGBD_OK:
|
||||||
|
print(f"Failed to start grabbing. Error code: {ret:#x}")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
while time.time() < end_time:
|
||||||
|
stFrameData = MV3D_RGBD_FRAME_DATA()
|
||||||
|
|
||||||
|
# 获取帧数据
|
||||||
|
ret = camera.MV3D_RGBD_FetchFrame(pointer(stFrameData), 5000)
|
||||||
|
if ret == MV3D_RGBD_OK:
|
||||||
|
frame_count += 1
|
||||||
|
|
||||||
|
for i in range(stFrameData.nImageCount):
|
||||||
|
image_info = stFrameData.stImageData[i]
|
||||||
|
|
||||||
|
# 保存深度图
|
||||||
|
if image_info.enImageType == ImageType_Depth:
|
||||||
|
file_name = configMap.save_path("depth","-Depth")
|
||||||
|
ret_save = camera.MV3D_RGBD_SaveImage(pointer(image_info), FileType_TIFF, file_name)
|
||||||
|
print("Saved depth image." if ret_save == MV3D_RGBD_OK else "Failed to save depth image.")
|
||||||
|
if ret_save == MV3D_RGBD_OK:
|
||||||
|
saved_tiff_files.append(file_name) # 记录保存的 TIFF 文件路径
|
||||||
|
# print(f"Saved depth image: {file_name}")
|
||||||
|
else:
|
||||||
|
print("Failed to save depth image.")
|
||||||
|
|
||||||
|
# 保存彩色图
|
||||||
|
elif image_info.enImageType in (
|
||||||
|
ImageType_RGB8_Planar, ImageType_YUV420SP_NV12,
|
||||||
|
ImageType_YUV420SP_NV21, ImageType_YUV422
|
||||||
|
):
|
||||||
|
file_name = configMap.save_path("color","-_Color")
|
||||||
|
ret_save = camera.MV3D_RGBD_SaveImage(pointer(image_info), FileType_BMP, file_name)
|
||||||
|
print("Saved color image." if ret_save == MV3D_RGBD_OK else "Failed to save color image.")
|
||||||
|
|
||||||
|
# 保存灰度图
|
||||||
|
elif image_info.enImageType == ImageType_Mono8:
|
||||||
|
file_name = configMap.save_path("Mono","-_Mono")
|
||||||
|
ret_save = camera.MV3D_RGBD_SaveImage(pointer(image_info), FileType_BMP, file_name)
|
||||||
|
print("Saved mono image." if ret_save == MV3D_RGBD_OK else "Failed to save mono image.")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"Unknown image type: {image_info.enImageType}")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Failed to fetch frame.")
|
||||||
|
|
||||||
|
time.sleep(time_hop / 1000.0) # 控制采集频率
|
||||||
|
|
||||||
|
finally:
|
||||||
|
# 停止取流
|
||||||
|
camera.MV3D_RGBD_Stop()
|
||||||
|
print("Continuous capture completed.")
|
||||||
|
return saved_tiff_files
|
||||||
|
|
||||||
|
|
||||||
|
initialize_devices()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
pic("00DA6823936")
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
|||||||
|
pyinstaller ^
|
||||||
|
--name=Hik3DApp ^
|
||||||
|
--icon=app.png ^
|
||||||
|
--add-data "dlls;_internal\\dlls" ^
|
||||||
|
--hidden-import=cv2.cv2 ^
|
||||||
|
--hidden-import=numpy.core._methods ^
|
||||||
|
--hidden-import=numpy.lib.format ^
|
||||||
|
--hidden-import=scipy.__config__ ^
|
||||||
|
--hidden-import=scipy._distributor_init ^
|
||||||
|
--hidden-import=scipy.sparse.csgraph._validation ^
|
||||||
|
--hidden-import=scipy.special._ellip_harm_2 ^
|
||||||
|
--hidden-import=scipy._cyutility ^
|
||||||
|
--hidden-import=scipy._lib._ccallback ^
|
||||||
|
--hidden-import=scipy.linalg.cython_blas ^
|
||||||
|
--hidden-import=scipy.linalg.cython_lapack ^
|
||||||
|
--hidden-import=scipy.optimize._highs._highs_constants ^
|
||||||
|
--hidden-import=scipy.optimize._highs._highs_wrapper ^
|
||||||
|
--hidden-import=sklearn.utils._weight_vector ^
|
||||||
|
--hidden-import=sklearn.utils._weight_vector_fast ^
|
||||||
|
--hidden-import=sklearn.tree._utils ^
|
||||||
|
--exclude-module=tkinter ^
|
||||||
|
--exclude-module=PyQt5 ^
|
||||||
|
--clean ^
|
||||||
|
main.py
|
||||||
|
|
||||||
|
xcopy /E /I /Y config dist\Hik3DApp\config
|
||||||
|
|
||||||
|
xcopy /E /I /Y dlls dist\Hik3DApp\_internal\dlls
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"sn": "00DA6823936",
|
||||||
|
"direction": "1",
|
||||||
|
"x_angle": 55,
|
||||||
|
"y_angle": 84,
|
||||||
|
"save_pcd": true,
|
||||||
|
"resolution": 8,
|
||||||
|
"max_z": 2000,
|
||||||
|
"reverse_order": false,
|
||||||
|
"time_on": 300,
|
||||||
|
"time_off": 3500,
|
||||||
|
"time_hop": 500
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"floorHeight": 1,
|
||||||
|
"max_pt": [
|
||||||
|
59.17729568481445,
|
||||||
|
-177.37328052520752,
|
||||||
|
823.2836303710938
|
||||||
|
],
|
||||||
|
"min_pt": [
|
||||||
|
0,
|
||||||
|
-1263.9830322265625,
|
||||||
|
200.47930908203125
|
||||||
|
],
|
||||||
|
"rotation": [
|
||||||
|
-0.0070345401763916016,
|
||||||
|
-0.9998821020126343,
|
||||||
|
0.013652533292770386,
|
||||||
|
0.4579751193523407,
|
||||||
|
-0.015358328819274902,
|
||||||
|
-0.8888324499130249,
|
||||||
|
0.88893723487854,
|
||||||
|
-2.9802322387695312e-08,
|
||||||
|
0.45802903175354004
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"floorHeight": 1,
|
||||||
|
"max_pt": [
|
||||||
|
103.20252990722656,
|
||||||
|
-169.6024932861328,
|
||||||
|
182.84439086914062
|
||||||
|
],
|
||||||
|
"min_pt": [
|
||||||
|
16.854652404785156,
|
||||||
|
-1234.1793212890625,
|
||||||
|
153.4544677734375
|
||||||
|
],
|
||||||
|
"rotation": [
|
||||||
|
-0.006754159927368164,
|
||||||
|
-0.9998819828033447,
|
||||||
|
0.013793319463729858,
|
||||||
|
0.43973052501678467,
|
||||||
|
-0.015358209609985352,
|
||||||
|
-0.8979983329772949,
|
||||||
|
0.8981043100357056,
|
||||||
|
0,
|
||||||
|
0.4397825002670288
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"floorHeight": 1,
|
||||||
|
"max_pt": [
|
||||||
|
59.17729568481445,
|
||||||
|
-177.37328052520752,
|
||||||
|
823.2836303710938
|
||||||
|
],
|
||||||
|
"min_pt": [
|
||||||
|
0,
|
||||||
|
-1263.9830322265625,
|
||||||
|
200.47930908203125
|
||||||
|
],
|
||||||
|
"rotation": [
|
||||||
|
-0.0070345401763916016,
|
||||||
|
-0.9998821020126343,
|
||||||
|
0.013652533292770386,
|
||||||
|
0.4579751193523407,
|
||||||
|
-0.015358328819274902,
|
||||||
|
-0.8888324499130249,
|
||||||
|
0.88893723487854,
|
||||||
|
-2.9802322387695312e-08,
|
||||||
|
0.45802903175354004
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<noInheritable/>
|
||||||
|
<assemblyIdentity
|
||||||
|
type="win32"
|
||||||
|
name="Microsoft.VC90.CRT"
|
||||||
|
version="9.0.21022.8"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="1fc8b3b9a1e18e3b"
|
||||||
|
/>
|
||||||
|
<file name="msvcr90.dll" /> <file name="msvcp90.dll" /> <file name="msvcm90.dll" />
|
||||||
|
</assembly>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<noInheritable></noInheritable>
|
||||||
|
<assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
|
||||||
|
<file name="msvcr90d.dll" hashalg="SHA1" hash="2f9024bb8cf6c3b30247a3242235f737d0e4ba34"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>Mmb6ThWjkCLJ1kFcb6VeXbKgZSQ=</dsig:DigestValue></asmv2:hash></file> <file name="msvcp90d.dll" hashalg="SHA1" hash="ababde913f262382ef841b0d35bbe08e9977e12a"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>QwAibePQKRW3vDa/c/P+zMttGvk=</dsig:DigestValue></asmv2:hash></file> <file name="msvcm90d.dll" hashalg="SHA1" hash="fea14f26c01a6993bfdbea1eb9f3522d81fd46de"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>K7zTyjEv60CJbG2B1wTDE6+zlmk=</dsig:DigestValue></asmv2:hash></file>
|
||||||
|
</assembly>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue