gui working
This commit is contained in:
+2
-1
@@ -3,4 +3,5 @@
|
|||||||
/dist_obfuscated/
|
/dist_obfuscated/
|
||||||
/release/
|
/release/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
orisys.egg-info/
|
orisys.egg-info/
|
||||||
|
/.cursor/
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
# Building Orisys Sensor Demo Executable and Installer
|
||||||
|
|
||||||
|
This guide explains how to package `camera_gui.py` into a standalone executable (.exe) and create an installer.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
1. **Python 3.8+** installed
|
||||||
|
2. **All dependencies** installed:
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install PyQt5 pyqtgraph PyInstaller
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **For creating installer (.exe installer)**:
|
||||||
|
- Download and install [Inno Setup](https://jrsoftware.org/isdl.php) (free, open-source)
|
||||||
|
|
||||||
|
## Method 1: Using PyInstaller (Simple)
|
||||||
|
|
||||||
|
### Option A: Using the spec file (Recommended)
|
||||||
|
|
||||||
|
1. Build the executable:
|
||||||
|
```bash
|
||||||
|
pyinstaller camera_gui.spec
|
||||||
|
```
|
||||||
|
|
||||||
|
2. The executable will be in the `dist` folder: `dist\camera_gui.exe`
|
||||||
|
|
||||||
|
### Option B: Using the build script
|
||||||
|
|
||||||
|
1. Run the build script:
|
||||||
|
```bash
|
||||||
|
python build_exe.py
|
||||||
|
```
|
||||||
|
|
||||||
|
2. The executable will be in the `dist` folder: `dist\camera_gui.exe`
|
||||||
|
|
||||||
|
### Option C: Manual PyInstaller command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pyinstaller --name=camera_gui --onefile --windowed --icon=orisys_logo_notext.png --add-data="orisys_logo_notext.png;." camera_gui.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Method 2: Creating an Installer (.exe installer)
|
||||||
|
|
||||||
|
### Using Inno Setup
|
||||||
|
|
||||||
|
1. **Build the executable first** using Method 1 above
|
||||||
|
|
||||||
|
2. **Open Inno Setup Compiler**
|
||||||
|
|
||||||
|
3. **Open the script file**: `build_installer.iss`
|
||||||
|
|
||||||
|
4. **Compile the installer**:
|
||||||
|
- Click "Build" → "Compile"
|
||||||
|
- Or press F9
|
||||||
|
|
||||||
|
5. **The installer will be created** in the `installer` folder: `installer\OrisysSensorDemo_Setup.exe`
|
||||||
|
|
||||||
|
### Customizing the Installer
|
||||||
|
|
||||||
|
Edit `build_installer.iss` to customize:
|
||||||
|
- App name and version
|
||||||
|
- Installation directory
|
||||||
|
- Start menu shortcuts
|
||||||
|
- Desktop icons
|
||||||
|
- License file
|
||||||
|
- Additional files to include
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
1. **"Module not found" errors**:
|
||||||
|
- Add missing modules to `hiddenimports` in `camera_gui.spec`
|
||||||
|
- Or use `--hidden-import=module_name` in PyInstaller command
|
||||||
|
|
||||||
|
2. **Large executable size**:
|
||||||
|
- This is normal - PyInstaller bundles Python interpreter and all dependencies
|
||||||
|
- Consider using `--onedir` instead of `--onefile` for faster startup
|
||||||
|
|
||||||
|
3. **Missing DLL files**:
|
||||||
|
- Ensure Visual C++ Redistributable is installed on target machines
|
||||||
|
- Include required DLLs using `--add-binary` option
|
||||||
|
|
||||||
|
4. **OpenCV/CUDA issues**:
|
||||||
|
- If using CUDA, ensure CUDA DLLs are available
|
||||||
|
- May need to add CUDA paths to `pathex` in spec file
|
||||||
|
|
||||||
|
### Testing the Executable
|
||||||
|
|
||||||
|
1. Test on a clean Windows machine (without Python installed)
|
||||||
|
2. Ensure all required DLLs are included
|
||||||
|
3. Test camera functionality
|
||||||
|
4. Test file saving functionality
|
||||||
|
|
||||||
|
## File Structure
|
||||||
|
|
||||||
|
After building, you should have:
|
||||||
|
|
||||||
|
```
|
||||||
|
dist/
|
||||||
|
└── camera_gui.exe # Standalone executable
|
||||||
|
|
||||||
|
installer/
|
||||||
|
└── OrisysSensorDemo_Setup.exe # Installer (after compiling with Inno Setup)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Distribution
|
||||||
|
|
||||||
|
- **Standalone executable**: Just distribute `dist\camera_gui.exe`
|
||||||
|
- **Installer**: Distribute `installer\OrisysSensorDemo_Setup.exe` for easier installation
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- The executable is large (~100-200MB) because it includes Python interpreter and all dependencies
|
||||||
|
- First launch may be slower as files are extracted
|
||||||
|
- Antivirus software may flag PyInstaller executables - this is a false positive
|
||||||
|
- Consider code signing for production releases
|
||||||
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
@echo off
|
||||||
|
REM Build script for Windows
|
||||||
|
REM Creates executable and optionally installer
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo Building Orisys Sensor Demo
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Check if Python is available
|
||||||
|
python --version >nul 2>&1
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo ERROR: Python is not installed or not in PATH
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Install/upgrade PyInstaller if needed
|
||||||
|
echo Installing/upgrading PyInstaller...
|
||||||
|
pip install --upgrade PyInstaller
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Building executable...
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Build using spec file
|
||||||
|
pyinstaller camera_gui.spec
|
||||||
|
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo.
|
||||||
|
echo ERROR: Build failed!
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ========================================
|
||||||
|
echo Build successful!
|
||||||
|
echo Executable: dist\camera_gui.exe
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Ask if user wants to create installer
|
||||||
|
set /p CREATE_INSTALLER="Create installer? (y/n): "
|
||||||
|
if /i "%CREATE_INSTALLER%"=="y" (
|
||||||
|
echo.
|
||||||
|
echo Creating installer...
|
||||||
|
echo Please ensure Inno Setup Compiler is installed.
|
||||||
|
echo Opening Inno Setup script...
|
||||||
|
|
||||||
|
REM Try to find Inno Setup Compiler
|
||||||
|
if exist "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" (
|
||||||
|
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" build_installer.iss
|
||||||
|
) else if exist "C:\Program Files\Inno Setup 6\ISCC.exe" (
|
||||||
|
"C:\Program Files\Inno Setup 6\ISCC.exe" build_installer.iss
|
||||||
|
) else (
|
||||||
|
echo Inno Setup Compiler not found in default locations.
|
||||||
|
echo Please compile build_installer.iss manually using Inno Setup Compiler.
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Done!
|
||||||
|
pause
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
"""
|
||||||
|
Build script for creating camera_gui.exe using PyInstaller
|
||||||
|
"""
|
||||||
|
import PyInstaller.__main__
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Add PyQt5 and pyqtgraph to requirements if not present
|
||||||
|
requirements = [
|
||||||
|
'PyInstaller>=5.0',
|
||||||
|
'PyQt5>=5.15.0',
|
||||||
|
'pyqtgraph>=0.12.0',
|
||||||
|
]
|
||||||
|
|
||||||
|
def build_exe():
|
||||||
|
"""Build the executable"""
|
||||||
|
|
||||||
|
# PyInstaller arguments
|
||||||
|
args = [
|
||||||
|
'camera_gui.py',
|
||||||
|
'--name=camera_gui',
|
||||||
|
'--onefile', # Create a single executable file
|
||||||
|
'--windowed', # No console window (GUI app)
|
||||||
|
'--icon=orisys_logo_notext.png', # Use logo as icon
|
||||||
|
'--add-data=orisys_logo_notext.png;.', # Include logo file
|
||||||
|
'--hidden-import=PyQt5.QtCore',
|
||||||
|
'--hidden-import=PyQt5.QtGui',
|
||||||
|
'--hidden-import=PyQt5.QtWidgets',
|
||||||
|
'--hidden-import=pyqtgraph',
|
||||||
|
'--hidden-import=orisys',
|
||||||
|
'--hidden-import=cv2',
|
||||||
|
'--hidden-import=numpy',
|
||||||
|
'--collect-all=pyqtgraph', # Collect all pyqtgraph data
|
||||||
|
'--collect-all=PyQt5', # Collect all PyQt5 data
|
||||||
|
'--collect-all=cv2', # Collect all OpenCV data
|
||||||
|
]
|
||||||
|
|
||||||
|
# Add orisys package if it's a local package
|
||||||
|
if os.path.exists('src/orisys'):
|
||||||
|
args.append('--paths=src')
|
||||||
|
|
||||||
|
print("Building executable...")
|
||||||
|
print("Command: PyInstaller " + " ".join(args))
|
||||||
|
|
||||||
|
PyInstaller.__main__.run(args)
|
||||||
|
|
||||||
|
print("\nBuild complete! Executable is in the 'dist' folder.")
|
||||||
|
print("You can now create an installer using Inno Setup or NSIS.")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
build_exe()
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
; Inno Setup Script for camera_gui installer
|
||||||
|
; Compile this script using Inno Setup Compiler
|
||||||
|
; Download from: https://jrsoftware.org/isdl.php
|
||||||
|
|
||||||
|
[Setup]
|
||||||
|
AppName=Orisys Sensor Demo
|
||||||
|
AppVersion=1.0.0
|
||||||
|
AppPublisher=Orisys
|
||||||
|
AppPublisherURL=https://orisys.com
|
||||||
|
DefaultDirName={autopf}\Orisys\SensorDemo
|
||||||
|
DefaultGroupName=Orisys Sensor Demo
|
||||||
|
AllowNoIcons=yes
|
||||||
|
LicenseFile=
|
||||||
|
OutputDir=installer
|
||||||
|
OutputBaseFilename=OrisysSensorDemo_Setup
|
||||||
|
Compression=lzma
|
||||||
|
SolidCompression=yes
|
||||||
|
WizardStyle=modern
|
||||||
|
PrivilegesRequired=admin
|
||||||
|
ArchitecturesInstallIn64BitMode=x64
|
||||||
|
|
||||||
|
[Languages]
|
||||||
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
|
Name: "chinese"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
|
||||||
|
|
||||||
|
[Tasks]
|
||||||
|
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||||
|
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
Source: "dist\camera_gui.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "orisys_logo_notext.png"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
; Add any other required files here
|
||||||
|
; Source: "config\*"; DestDir: "{app}\config"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
Name: "{group}\Orisys Sensor Demo"; Filename: "{app}\camera_gui.exe"; IconFilename: "{app}\orisys_logo_notext.png"
|
||||||
|
Name: "{group}\{cm:UninstallProgram,Orisys Sensor Demo}"; Filename: "{uninstallexe}"
|
||||||
|
Name: "{autodesktop}\Orisys Sensor Demo"; Filename: "{app}\camera_gui.exe"; IconFilename: "{app}\orisys_logo_notext.png"; Tasks: desktopicon
|
||||||
|
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Orisys Sensor Demo"; Filename: "{app}\camera_gui.exe"; IconFilename: "{app}\orisys_logo_notext.png"; Tasks: quicklaunchicon
|
||||||
|
|
||||||
|
[Run]
|
||||||
|
Filename: "{app}\camera_gui.exe"; Description: "{cm:LaunchProgram,Orisys Sensor Demo}"; Flags: nowait postinstall skipifsilent
|
||||||
|
|
||||||
|
[Code]
|
||||||
|
function InitializeSetup(): Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
// Check if Visual C++ Redistributable is installed (if needed)
|
||||||
|
// Add checks here if required
|
||||||
|
end;
|
||||||
|
|
||||||
+1147
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
PyInstaller spec file for camera_gui
|
||||||
|
Run: pyinstaller camera_gui.spec
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
|
||||||
|
|
||||||
|
block_cipher = None
|
||||||
|
|
||||||
|
# Collect data files
|
||||||
|
pyqtgraph_datas = collect_data_files('pyqtgraph')
|
||||||
|
pyqt5_datas = collect_data_files('PyQt5')
|
||||||
|
cv2_datas = collect_data_files('cv2')
|
||||||
|
|
||||||
|
# Collect hidden imports
|
||||||
|
hiddenimports = [
|
||||||
|
'PyQt5.QtCore',
|
||||||
|
'PyQt5.QtGui',
|
||||||
|
'PyQt5.QtWidgets',
|
||||||
|
'pyqtgraph',
|
||||||
|
'pyqtgraph.graphicsItems',
|
||||||
|
'pyqtgraph.widgets',
|
||||||
|
'orisys',
|
||||||
|
'cv2',
|
||||||
|
'numpy',
|
||||||
|
'scipy',
|
||||||
|
]
|
||||||
|
|
||||||
|
# Add orisys submodules if available
|
||||||
|
try:
|
||||||
|
orisys_submodules = collect_submodules('orisys')
|
||||||
|
hiddenimports.extend(orisys_submodules)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
['camera_gui.py'],
|
||||||
|
pathex=[],
|
||||||
|
binaries=[],
|
||||||
|
datas=[
|
||||||
|
('orisys_logo_notext.png', '.'),
|
||||||
|
*pyqtgraph_datas,
|
||||||
|
*pyqt5_datas,
|
||||||
|
*cv2_datas,
|
||||||
|
],
|
||||||
|
hiddenimports=hiddenimports,
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=[],
|
||||||
|
win_no_prefer_redirects=False,
|
||||||
|
win_private_assemblies=False,
|
||||||
|
cipher=block_cipher,
|
||||||
|
noarchive=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.zipfiles,
|
||||||
|
a.datas,
|
||||||
|
[],
|
||||||
|
name='camera_gui',
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
upx_exclude=[],
|
||||||
|
runtime_tmpdir=None,
|
||||||
|
console=False, # No console window
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
icon='orisys_logo_notext.png',
|
||||||
|
)
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -4,3 +4,6 @@ opencv_python>=4.10.0.84
|
|||||||
opencv-contrib-python
|
opencv-contrib-python
|
||||||
scipy>=1.10.1
|
scipy>=1.10.1
|
||||||
setuptools>=45.2.0
|
setuptools>=45.2.0
|
||||||
|
PyQt5>=5.15.0
|
||||||
|
pyqtgraph>=0.12.0
|
||||||
|
PyInstaller>=5.0
|
||||||
|
|||||||
+4
-2
@@ -242,8 +242,10 @@ class nHHD(object):
|
|||||||
self.Sn = numpy.sum(numpy.absolute(self.d))
|
self.Sn = numpy.sum(numpy.absolute(self.d))
|
||||||
# print("Sn is:", self.Sn)
|
# print("Sn is:", self.Sn)
|
||||||
|
|
||||||
self.Stx = abs(numpy.sum(self.h[:, :, 0]))
|
# self.Stx = abs(numpy.sum(self.h[:, :, 0]))
|
||||||
self.Sty = abs(numpy.sum(self.h[:, :, 1]))
|
# self.Sty = abs(numpy.sum(self.h[:, :, 1]))
|
||||||
|
self.Stx = numpy.sum(self.h[:, :, 0])
|
||||||
|
self.Sty = numpy.sum(self.h[:, :, 1])
|
||||||
# print("Stx is:", self.Stx)
|
# print("Stx is:", self.Stx)
|
||||||
# print("Sty is:", self.Sty)
|
# print("Sty is:", self.Sty)
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,9 @@ class Sensor:
|
|||||||
results.append(self.depth if self.depth is not None else np.array([]))
|
results.append(self.depth if self.depth is not None else np.array([]))
|
||||||
return tuple(results) if results else ()
|
return tuple(results) if results else ()
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.tracker.reset()
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
"""
|
"""
|
||||||
Release video capture resources.
|
Release video capture resources.
|
||||||
|
|||||||
Reference in New Issue
Block a user