I am trying to run calibrate.py in pycharm. In the pycharm terminal I type "python calibrate.py --help" and get errors. I am expecting to get a list of available arguments that can be used. From the error messages, I have tried installing and getting the required files from GitHub. I think I may be doing something wrong or missing other files. Is there a installation document for the full installation requirements of calibrate.py.
Unable to run calibrate.py
- Edited
Thanks for the response. After many hours I finally got the "python calibrate.py --help" to work showing the arguments. Below is how I did it. *EDIT: THIS ONLY FIXED running the --help. I CANNOT run the calibrate.py for a calibration*
Download and Install the latest version of python using windows. Check all the boxes.
https://www.python.org/downloads/
Using the command prompt:
upgrade pip
python -m pip install --upgrade pip
Select the path where you want your virtual environment and make a directory. Can be any location
C:\python> "directory I selected"
md CamCal
go to that directory you made
cd CamCal
C:\python\CamCal> "will look like this"
create a python virtual environment. the second venv can be any folder name of your choice
python -m venv venv
C:\python\CamCal\venv "creates folder here"
activate the virtual environment
goto scripts in the folder you made and type activate. you will see folder name ex. (venv) in the front of the command prompt line
C:\python\CamCal\venv\Scripts "go here"
C:\python\CamCal\venv\Scripts>activate "type activate"
(venv) C:\python\CamCal\venv\Scripts> "will see this"
change dir the CamCal folder
(venv) C:\python\CamCal\venv\Scripts>
cd..
(venv) C:\python\CamCal\venv>
cd..
(venv) C:\python\CamCal>
get files from github
git clone https://github.com/luxonis/depthai.git
cd depthai
(venv) C:\python\CamCal\depthai>
Install the requirements. I dont know if this is needed it throws errors. It will uninstall the depthai install if ran after depthai is installed.
python install_requirements.py
install these in the depthai folder
python -m pip install depthai
pip install opencv-python
pip install opencv-contrib-python
python -m pip install scipy
this is needed to work
git submodule update --init --recursive
to run the calibrate help for finding out the calibrate arguments that can be used
python calibrate.py --help
- Edited
I did fix the --help following the above steps. These steps did not fix the calibrate.py to run a calibration. So, I am starting over and only installing the required prerequisites found below. I expecting these prerequisites to install everything I need to run calibrate.py. Can you Help?
Prerequisites to run calibrate.py:
https://docs.luxonis.com/hardware/platform/depth/calibration/#Depth%20Calibration-Prerequisites
git clone https://github.com/luxonis/depthai.git
cd depthai
git submodule update --init --recursive
python3 install_requirements.py
Below shows exactly what I did. This shows the errors from the prerequisites install and errors running calibrate.py
(venv) C:\python\CamCal>python --version
Python 3.13.1
(venv) C:\python\CamCal>pip --version
pip 25.0 from C:\python\CamCal\venv\Lib\site-packages\pip (python 3.13)
(venv) C:\python\CamCal>git clone https://github.com/luxonis/depthai.git
Cloning into 'depthai'...
remote: Enumerating objects: 21982, done.
remote: Counting objects: 100% (68/68), done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 21982 (delta 25), reused 19 (delta 5), pack-reused 21914 (from 3)
Receiving objects: 100% (21982/21982), 248.53 MiB | 14.01 MiB/s, done.
Resolving deltas: 100% (14533/14533), done.
Updating files: 100% (501/501), done.
(venv) C:\python\CamCal>cd depthai
(venv) C:\python\CamCal\depthai>git submodule update --init --recursive
Submodule 'depthai_calibration' (https://github.com/luxonis/depthai-calibration) registered for path 'depthai_calibration'
Submodule 'resources/depthai_boards' (https://github.com/luxonis/depthai-boards) registered for path 'resources/depthai_boards'
Cloning into 'C:/python/CamCal/depthai/depthai_calibration'...
Cloning into 'C:/python/CamCal/depthai/resources/depthai_boards'...
Submodule path 'depthai_calibration': checked out '524952bc0de2f1b9d9bb19327f6fdfa1ace7a8a2'
Submodule path 'resources/depthai_boards': checked out 'cce87acb84dcc77cc2ef4ba504adbad77a236b6d'
(venv) C:\python\CamCal\depthai>python install_requirements.py
pip 25.0 from C:\python\CamCal\venv\Lib\site-packages\pip (python 3.13)
Requirement already satisfied: pip in c:\python\camcal\venv\lib\site-packages (25.0)
WARNING: Skipping opencv-python as it is not installed.
WARNING: Skipping opencv-contrib-python as it is not installed.
WARNING: Skipping depthai as it is not installed.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/wheels/, https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/
Collecting requests==2.26.0 (from -r requirements.txt (line 1))
Using cached https://www.piwheels.org/simple/requests/requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting numpy<2.0.0,>=1.21.4 (from -r requirements.txt (line 3))
Using cached numpy-1.26.4.tar.gz (15.8 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
+ C:\python\CamCal\venv\Scripts\python.exe C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5\vendored-meson\meson\meson.py setup C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5 C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5\.mesonpy-3x_bmisp -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5\.mesonpy-3x_bmisp\meson-python-native-file.ini
The Meson build system
Version: 1.2.99
Source dir: C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5
Build dir: C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5\.mesonpy-3x_bmisp
Build type: native build
Project name: NumPy
Project version: 1.26.4
WARNING: Failed to activate VS environment: Could not find C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']]
The following exception(s) were encountered:
Running `icl ""` gave "[WinError 2] The system cannot find the file specified"
Running `cl /?` gave "[WinError 2] The system cannot find the file specified"
Running `cc --version` gave "[WinError 2] The system cannot find the file specified"
Running `gcc --version` gave "[WinError 2] The system cannot find the file specified"
Running `clang --version` gave "[WinError 2] The system cannot find the file specified"
Running `clang-cl /?` gave "[WinError 2] The system cannot find the file specified"
Running `pgcc --version` gave "[WinError 2] The system cannot find the file specified"
A full log can be found at C:\Users\shawn\AppData\Local\Temp\pip-install-wqmx4q7u\numpy_e8e8e712b64e4d4680459048c98327b5\.mesonpy-3x_bmisp\meson-logs\meson-log.txt
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Traceback (most recent call last):
File "C:\python\CamCal\depthai\install_requirements.py", line 44, in <module>
subprocess.check_call(pip_package_install + ["-r", "requirements.txt"], cwd=script_directory)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\shawn\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 419, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\python\\CamCal\\venv\\Scripts\\python.exe', '-m', 'pip', 'install', '-U', '--prefer-binary', '-r', 'requirements.txt']' returned non-zero exit status 1.
(venv) C:\python\CamCal\depthai>python install_requirements.py
(venv) C:\python\CamCal\depthai>python calibrate.py --help
Traceback (most recent call last):
File "C:\python\CamCal\depthai\calibrate.py", line 12, in <module>
from scipy.spatial.transform import Rotation
ModuleNotFoundError: No module named 'scipy'
(venv) C:\python\CamCal\depthai>python calibrate.py -db -s 4.1256 -ms 3.0942 -nx 40 -ny 22 -brd OAK-FFC-3P-CAM_C-OV9282
Traceback (most recent call last):
File "C:\python\CamCal\depthai\calibrate.py", line 12, in <module>
from scipy.spatial.transform import Rotation
ModuleNotFoundError: No module named 'scipy'
(venv) C:\python\CamCal\depthai>
Thank you for the help earlier. Now I can run the program and capture the calibration images. I am unable to send the calibration to the EEPROM on the OAK-FFC-3P. I am expecting the calibration to load to the EEPROM. Here is my error.
<------------Calibrating CAM_C-OV9282 ------------>
INTRINSIC CALIBRATION
Reprojection error of CAM_C-OV9282: 0.42736309789526045
Reprojection error threshold -> 1.1111111111111112
CAM_C-OV9282 Reprojection Error: 0.427363
C:\python\CamCal\depthai\calibrate.py:1029: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
calibration_handler.setDistortionCoefficients(stringToCam[camera], cam_info['dist_coeff'])
Flashing Calibration data into
EEPROM VERSION being flashed is -> 7
EEPROM VERSION being flashed is -> 7
Device closed in exception..
Error flashing calibration to USER area, error: EEPROM_FIELD_TOO_LONG
Traceback (most recent call last):
File "C:\python\CamCal\depthai\calibrate.py", line 1094, in calibrate
self.device.flashCalibration2(calibration_handler)
RuntimeError: Error flashing calibration to USER area, error: EEPROM_FIELD_TOO_LONG
(venv) C:\python\CamCal\depthai>
- Edited
Thank you for helping me. I did not realize the EEPROM_FIELD_TOO_LONG means the name was to long. I changed the name of the module board name from OAK-FFC-3P-CAM_C-OV9282.json to C9282.json and the name of the board and camera to C9282 inside the C9282.json file. Now I see the green popup screen that says Calibration successful. See below for file changes.
Changed From: OAK-FFC-3P-CAM_C-OV9282.json
{
"board_config": {
"name": "OAK-FFC-3P-CAM_C-OV9282",
"revision": "R3M0E3",
"cameras": {
"CAM_C": {
"name": "CAM_C-OV9282",
"hfov": 80,
"type": "mono"
}
}
}
}
Changed To: C9282.json
{
"board_config": {
"name": "C9282",
"revision": "R3M0E3",
"cameras": {
"CAM_C": {
"name": "C9282",
"hfov": 80,
"type": "mono"
}
}
}
}