Why I Can't Use Pin GPIO When I Run SSD Mobilenetv2 in Docker/run.sh

Board : Jetson Nano B01

I Completed to try this program

Then I tried to modify the program by adding an output in the form of a light that would light up when it detects an object via the GPIO pin on the Jetson board. With the following programs:

import Jetson.GPIO as GPIO
import jetson_inference
import jetson_utils

# Konfigurasi GPIO
lamp_pin = 12
GPIO.setup(lamp_pin, GPIO.OUT)
lamp_state = False

net = jetson_inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
camera = jetson_utils.videoSource("/dev/video0")
display = jetson_utils.videoOutput()

person_count = 0

while True:
    img = camera.Capture()
    detection = net.Detect(img)

    # Menghitung jumlah objek person
    person_count = 0
    for obj in detection:
        if obj.ClassID == 1:  # ID kelas "person"
            person_count += 1

    print("Jumlah objek person yang dideteksi: {}".format(person_count))

    # Menyalakan lampu jika ada objek person yang dideteksi
    if person_count > 0 and not lamp_state:
        GPIO.output(lamp_pin, GPIO.HIGH)
        lamp_state = True
        print("Lampu dinyalakan")
    elif person_count == 0 and lamp_state:
        GPIO.output(lamp_pin, GPIO.LOW)
        lamp_state = False
        print("Lampu dimatikan")

    display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))

After I entered Docker/run.sh and ran the python3 my-detection.py command, the following error occurred:

Traceback (most recent call last):
  File "my-detection.py", line 1, in <module>
    import Jetson.GPIO as GPIO
ModuleNotFoundError: No module named 'Jetson.GPIO'

Give me help to solve this problem


Have you installed it within the container?
If not, you can find the tutorial below:


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.