Skip to content

Commit 3c68da8

Browse files
author
SzabolcsGergely
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents c429bdf + 367505e commit 3c68da8

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

examples/calibration_reader.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
print("LEFT Camera resized intrinsics...")
2727
print(M_left)
2828

29+
D_left = np.array(calibData.getDistortionCoefficients(dai.CameraBoardSocket.LEFT))
30+
print("LEFT Distortion Coefficients...")
31+
[print(name+": "+value) for (name, value) in zip(["k1","k2","p1","p2","k3","k4","k5","k6","s1","s2","s3","s4","τx","τy"],[str(data) for data in D_left])]
32+
33+
M_right = np.array(calibData.getCameraIntrinsics(dai.CameraBoardSocket.RIGHT, 1280, 720))
34+
print("RIGHT Camera resized intrinsics...")
35+
print(M_right)
36+
37+
D_right = np.array(calibData.getDistortionCoefficients(dai.CameraBoardSocket.RIGHT))
38+
print("RIGHT Distortion Coefficients...")
39+
[print(name+": "+value) for (name, value) in zip(["k1","k2","p1","p2","k3","k4","k5","k6","s1","s2","s3","s4","τx","τy"],[str(data) for data in D_right])]
40+
2941
print(f"RGB FOV {calibData.getFov(dai.CameraBoardSocket.RGB)}, Mono FOV {calibData.getFov(dai.CameraBoardSocket.LEFT)}")
3042

3143
R1 = np.array(calibData.getStereoLeftRectificationRotation())

examples/install_requirements.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys, os, subprocess
44
import argparse
55
import re
6+
import platform
67

78
convert_default = "empty"
89
parser = argparse.ArgumentParser()
@@ -38,7 +39,21 @@ def hasWhitespace(string):
3839
import find_version
3940

4041
# 3rdparty dependencies to install
41-
DEPENDENCIES = ['numpy', 'opencv-python', 'pyyaml', 'requests']
42+
DEPENDENCIES = ['pyyaml', 'requests']
43+
requireOpenCv = True
44+
thisPlatform = platform.machine()
45+
if thisPlatform == "aarch64":
46+
# try to import opencv, numpy in a subprocess, since it might fail with illegal instruction
47+
# if it was previously installed w/ pip without setting OPENBLAS_CORE_TYPE=ARMV8 env variable
48+
try:
49+
subprocess.check_call([sys.executable, "-c", "import numpy, cv2;"])
50+
requireOpenCv = False
51+
except subprocess.CalledProcessError as ex:
52+
requireOpenCv = True
53+
54+
if requireOpenCv:
55+
DEPENDENCIES.extend(['numpy','opencv-python'])
56+
4257

4358
# Constants
4459
ARTIFACTORY_URL = 'https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local'
@@ -61,12 +76,13 @@ def hasWhitespace(string):
6176
if sys.version_info[0] != 3:
6277
raise RuntimeError("Examples require Python 3 to run (detected: Python {})".format(sys.version_info[0]))
6378

64-
if platform.machine() == "arm64" and platform.system() == "Darwin":
79+
if thisPlatform == "arm64" and platform.system() == "Darwin":
6580
err_str = "There are no prebuilt wheels for M1 processors. Please open the following link for a solution - https://discuss.luxonis.com/d/69-running-depthai-on-apple-m1-based-macs"
6681
raise RuntimeError(err_str)
6782

68-
is_pi = platform.machine().startswith("arm") or platform.machine().startswith("aarch")
69-
if is_pi and sys.version_info[1] == 9:
83+
is_pi = thisPlatform.startswith("arm")
84+
prebuiltWheelsPythonVersion = [7,9]
85+
if requireOpenCv and is_pi and sys.version_info[1] not in prebuiltWheelsPythonVersion:
7086
print("[WARNING] There are no prebuilt wheels for Python 3.{} for OpenCV, building process on this device may be long and unstable".format(sys.version_info[1]))
7187

7288
if not in_venv:
@@ -158,3 +174,14 @@ def hasWhitespace(string):
158174
prettyPrint(cmd)
159175
else:
160176
subprocess.check_call(cmd)
177+
178+
if requireOpenCv and thisPlatform == "aarch64":
179+
from os import environ
180+
OPENBLAS_CORE_TYPE = environ.get('OPENBLAS_CORE_TYPE')
181+
if OPENBLAS_CORE_TYPE != 'ARMV8':
182+
WARNING='\033[1;5;31m'
183+
RED='\033[91m'
184+
LINE_CL='\033[0m'
185+
SUGGESTION='echo "export OPENBLAS_CORETYPE=AMRV8" >> ~/.bashrc && source ~/.bashrc'
186+
print(f'{WARNING}WARNING:{LINE_CL} Need to set OPENBLAS_CORE_TYPE environment variable, otherwise opencv will fail with illegal instruction.')
187+
print(f'Run: {RED}{SUGGESTION}{LINE_CL}')

0 commit comments

Comments
 (0)