Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
Change the method of obtaining hardware information to jtop.
  • Loading branch information
edward-ardu authored and ArduCAM committed Feb 14, 2023
1 parent 51912c1 commit 592a95f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions Jetson/Jetvariety/example/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,18 @@ class ArducamUtils(object):
DEVICE_ID = 0x0030

def __init__(self, device_num):
import subprocess
command = ['bash', '-c', 'source scripts/jetson_variables.sh && env']

proc = subprocess.Popen(command, stdout = subprocess.PIPE)
environment_vars = {}
for line in proc.stdout:
(key, _, value) = line.partition(b"=")
environment_vars[key] = value

proc.communicate()

from jtop import jtop
with jtop() as jetson:
if jetson.ok():
for name_category, category in jetson.board.items():
if name_category == "hardware":
environment_vars = category['Module']
print("Hardware is: {}".format(environment_vars))
# Jetson Model
if b"Xavier NX" in environment_vars[b"JETSON_TYPE"].strip():
if "Xavier NX" in environment_vars:
ArducamUtils.pixfmt_map = ArducamUtils.pixfmt_map_xavier_nx
elif "Orin NX" in environment_vars:
ArducamUtils.pixfmt_map = ArducamUtils.pixfmt_map_xavier_nx

self.vd = open('/dev/video{}'.format(device_num), 'w')
self.refresh()

Expand Down Expand Up @@ -252,4 +249,4 @@ def get_framesizes(self, pixel_format = v4l2.V4L2_PIX_FMT_Y16):
return framesizes

def __getattr__(self, key):
return self.config.get(key)
return self.config.get(key)

0 comments on commit 592a95f

Please sign in to comment.