What I’m wondering is that I’m using import jetson.inference in a python code I created on my desktop. Does it recognize my wheelchair when I run the webcam? It didn’t recognize it when I turned on the webcam and I want to make it recognize the wheelchair.!!
Do I have to use docker to be recognized?
Hi @7qodqod, can you post your modified code here? Does it recognize the wheelchair when running the original detectnet.py on your camera, or just your test image?
If your model works on test images but not your camera, typically that means you need to collect/annotate more real-world data from your camera and then re-train the model.
import time
import Jetson.GPIO as GPIO
import jetson.inference
import jetson.utils
# LED가 연결된 GPIO 핀 설정
RED_PIN = 10
CARRED_PIN = 18
GRE_PIN = 23
YEL_PIN = 20
BUZZER_PIN = 12
GPIO.setmode(GPIO.BCM)
GPIO.setup(RED_PIN, GPIO.OUT)
GPIO.setup(CARRED_PIN, GPIO.OUT)
GPIO.setup(GRE_PIN, GPIO.OUT)
GPIO.setup(YEL_PIN, GPIO.OUT)
GPIO.setup(BUZZER_PIN, GPIO.OUT)
# 객체 인식 모델 로드
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
camera = jetson.utils.videoSource("/dev/video0")
display = jetson.utils.videoOutput()
# 부저 초기화
buzzer = GPIO.PWM(BUZZER_PIN, 1000) # PWM 객체 생성, 주파수 1000 설정
def buzzer_on(duration):
buzzer.start(50) # 듀티 사이클 50%로 부저 시작
time.sleep(duration) # 주어진 시간만큼 대기
buzzer.stop() # 부저 멈춤
def buzzer_off():
buzzer.stop() # 부저 멈춤
# 메인 루프 시작
def main():
while True:
try:
# 카메라에서 이미지 가져오기
img = camera.Capture()
detections = net.Detect(img)
display.Render(img)
display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))
# 객체 인식 결과 처리
GPIO.output(GRE_PIN, GPIO.LOW)
GPIO.output(RED_PIN, GPIO.LOW) # 빨간색 LED 끄기
GPIO.output(CARRED_PIN, GPIO.LOW) # 빨간색 LED 끄기
buzzer_off() # 부저 끄기
person_detected = False # 사람이 인식되었는지 여부를 저장하는 변수
for detection in detections:
if detection.ClassID == 1: # 인식된 객체가 사람일 경우
GPIO.output(GRE_PIN, GPIO.HIGH) # LED 켜기
GPIO.output(RED_PIN, GPIO.LOW) # 빨간색 LED 끄기
GPIO.output(CARRED_PIN, GPIO.HIGH) # 차량용 빨간색 LED 켜기
buzzer_on(3) # 부저 켜기
print("사람 감지됨")
# 초록불 유지 시간 설정 (10초)
green_light_duration = 10
start_time = time.monotonic()
while time.monotonic() - start_time < green_light_duration:
# 카메라에서 이미지 가져오기
img = camera.Capture()
detections = net.Detect(img)
display.Render(img)
display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))
GPIO.output(GRE_PIN, GPIO.HIGH) # LED 유지
GPIO.output(CARRED_PIN, GPIO.HIGH) # 차량용 빨간색 LED 유지
buzzer_off() # 부저 멈추기
GPIO.output(GRE_PIN, GPIO.LOW) # LED 끄기
GPIO.output(CARRED_PIN, GPIO.LOW)
person_detected = True
if person_detected: # 사람이 인식되었을 때
GPIO.output(YEL_PIN, GPIO.LOW) # 노란색 LED 끄기
else: # 사람이 인식되지 않았을 때
GPIO.output(RED_PIN, GPIO.HIGH) # 빨간색 LED 켜기
# 노란색 LED 깜빡이기
GPIO.output(YEL_PIN, GPIO.HIGH) # LED 켜기
time.sleep(0.5) # 0.5초 대기
GPIO.output(YEL_PIN, GPIO.LOW) # LED 끄기
# 이미지 메모리 반환
jetson.utils.cudaDeviceSynchronize()
except:
print("Error capturing image from camera")
if __name__ == "__main__":
main()
detectnet --model=models/fruit/ssd-mobilenet.onnx --labels=models/fruit/labels.txt
–input-blob=input_0 --output-cvg=scores --output-bbox=boxes
“$IMAGES/fruit_*.jpg” $IMAGES/test/fruit_%i.jpg
and it was recognized.
Hi @7qodqod, in your code you’re loading the built-in ssd-mobilenet-v2 model that was trained on 90-class COCO dataset. Instead try loading your customized model like this:
net = jetson.inference.detectNet(model='models/fruit/ssd-mobilenet.onnx',
labels='models/fruit/labels.txt',
input_blob='input_0',
output_cvg='scores',
output_bbox='boxes',
threshold=0.5)
*if you’re running an older version of jetson-inference you may need to update your repo in order to use that API
I hope this message finds you well. I am writing to inform you about an issue I encountered while attempting to execute a particular code. Specifically, when running the code, I observed that the LED connected to the circuitry remained consistently set to the HIGH state without any change.
I would greatly appreciate your guidance and expertise in resolving this matter. Please let me know if you require any additional information or if there are any specific steps I should take to troubleshoot the issue effectively.
Thank you for your attention to this matter, and I look forward to your kind assistance.
@mayour_bukhari it would seem that you were able to get it working? If you have any follow-up questions specifically about GPIO that are unrelated to detectNet, I would recommend posting those in a new topic so the hardware experts can take a look.