jetson nanoでusb接続したカメラより物体検知
USBカメラ接続
ラズパイのカメラもあるけど接続がUSBの方が簡単そうだったのでUSBにした
USB接続し、認識されていること確認
$ lsusb Bus 002 Device 002: ID xxxx:xxxx Realtek Semiconductor Corp. Bus 002 Device 001: ID xxxx:xxxx Linux Foundation 3.0 root hub Bus 001 Device 005: ID xxxx:xxxx Elecom Co., Ltd Bus 001 Device 004: ID xxxx:xxxx Logitech, Inc. Unifying Receiver Bus 001 Device 003: ID xxxx:xxxx Bus 001 Device 002: ID xxxx:xxxx Realtek Semiconductor Corp. Bus 001 Device 001: ID xxxx:xxxx Linux Foundation 2.0 root hub $ $ ls /dev/video* /dev/video0 $
実装
import jetson.inference import jetson.utils net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5) camera = jetson.utils.gstCamera(1280, 720, "/dev/video0") display = jetson.utils.glDisplay() while display.IsOpen(): img, width, height = camera.CaptureRGBA() detections = net.Detect(img, width, height) print detections if len(detections) > 0: print("detect count= {0}".format(len(detections))) for detection in detections: print ("ClassID:{0}, Confidence:{1}" \ + ", Left:{2}, Top:{3}, Right:{4}, Bottom:{5}" \ + ", Width:{6}, Height:{7}, Area:{8}, Center:{9}" \ ).format(detection.ClassID , detection.Confidence , detection.Left , detection.Top , detection.Right , detection.Bottom , detection.Width , detection.Height , detection.Area , detection.Center ) display.RenderOnce(img, width, height) display.SetTitle("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))
実験(汚部屋御免)
jetson nanoでカメラ画像より物体検知
うーん、動画うまく取る方法がわからん( ;∀;)