Skip to content

Commit

Permalink
Enable command line arguments parsing for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
VanDavv committed Jan 24, 2022
1 parent 08756f7 commit f741e1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 5 additions & 1 deletion apps/uvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import depthai as dai
import time

from depthai_helpers.arg_manager import parseArgs

args = parseArgs()

if platform.machine() == 'aarch64':
print("This app is temporarily disabled on AARCH64 systems due to an issue with stream preview. We are working on resolving this issue")
raise SystemExit(0)
Expand All @@ -29,7 +33,7 @@
cam_rgb.video.link(uvc.input)

# Pipeline defined, now the device is connected to
with dai.Device(pipeline) as device:
with dai.Device(pipeline, usb2Mode=args.usbSpeed == "usb2") as device:
print("\nDevice started, please keep this process running")
print("and open an UVC viewer. Example on Linux:")
print(" guvcview -d /dev/video0")
Expand Down
15 changes: 6 additions & 9 deletions depthai_helpers/arg_manager.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import os
import argparse
from pathlib import Path
import cv2
import depthai as dai
try:
import argcomplete
except ImportError:
raise ImportError('\033[1;5;31m argcomplete module not found, run: python3 install_requirements.py \033[0m')
from depthai_sdk.previews import Previews


def checkRange(minVal, maxVal):
Expand Down Expand Up @@ -55,12 +48,16 @@ def orientationCast(arg):

openvinoVersions = list(map(lambda name: name.replace("VERSION_", ""), filter(lambda name: name.startswith("VERSION_"), vars(dai.OpenVINO.Version))))
_streamChoices = ("nnInput", "color", "left", "right", "depth", "depthRaw", "disparity", "disparityColor", "rectifiedLeft", "rectifiedRight")
colorMaps = list(map(lambda name: name[len("COLORMAP_"):], filter(lambda name: name.startswith("COLORMAP_"), vars(cv2))))
try:
import cv2
colorMaps = list(map(lambda name: name[len("COLORMAP_"):], filter(lambda name: name.startswith("COLORMAP_"), vars(cv2))))
except:
colorMaps = None
projectRoot = Path(__file__).parent.parent

def parseArgs():
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-cam', '--camera', choices=[Previews.left.name, Previews.right.name, Previews.color.name], default=Previews.color.name, help="Use one of DepthAI cameras for inference (conflicts with -vid)")
parser.add_argument('-cam', '--camera', choices=["left", "right", "color"], default="color", help="Use one of DepthAI cameras for inference (conflicts with -vid)")
parser.add_argument('-vid', '--video', type=str, help="Path to video file (or YouTube link) to be used for inference (conflicts with -cam)")
parser.add_argument('-dd', '--disableDepth', action="store_true", help="Disable depth information")
parser.add_argument('-dnn', '--disableNeuralNetwork', action="store_true", help="Disable neural network inference")
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
requests==2.26.0
pyrebase4==4.5
argcomplete==1.12.1
--extra-index-url https://www.piwheels.org/simple
opencv-python==4.5.4.58 ; platform_machine != "aarch64" and platform_machine != "armv6l" and platform_machine != "armv7l" and python_version == "3.10"
opencv-python==4.5.1.48 ; platform_machine != "aarch64" and platform_machine != "armv6l" and platform_machine != "armv7l" and python_version != "3.10"
Expand Down

0 comments on commit f741e1b

Please sign in to comment.