From d2861d674386f287b6dcd9ae41d6192e1c6bcc7f Mon Sep 17 00:00:00 2001 From: Ravichandran Date: Wed, 15 Jun 2022 17:04:16 -0400 Subject: [PATCH] Fixing issues in dnn example Signed-off-by: Ravichandran --- bindings/python/examples/dnn/CMakeLists.txt | 4 ++-- bindings/python/examples/dnn/dnn.py | 23 ++++++++++++++------- bindings/python/examples/dnn/readme.md | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/bindings/python/examples/dnn/CMakeLists.txt b/bindings/python/examples/dnn/CMakeLists.txt index 9543c6533..933274ab2 100644 --- a/bindings/python/examples/dnn/CMakeLists.txt +++ b/bindings/python/examples/dnn/CMakeLists.txt @@ -4,11 +4,11 @@ project(aditof-python-dnn) # Download MobileNetSSD_deploy prototxt and caffemodel set(PROTOTEXT_FILE "MobileNetSSD_deploy.prototxt") -set(PROTOTEXT_URL "https://raw.githubusercontent.com/chuanqi305/MobileNet-SSD/f5d072ccc7e3dcddaa830e9805da4bf1000b2836/MobileNetSSD_deploy.prototxt") +set(PROTOTEXT_URL "https://raw.githubusercontent.com/djmv/MobilNet_SSD_opencv/master/MobileNetSSD_deploy.prototxt") set(PROTOTEXT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${PROTOTEXT_FILE}") set(MODEL_FILE "MobileNetSSD_deploy.caffemodel") -set(MODEL_URL "https://drive.google.com/uc?export=download&id=0B3gersZ2cHIxRm5PMWRoTkdHdHc") +set(MODEL_URL "https://github.com/djmv/MobilNet_SSD_opencv/blob/master/MobileNetSSD_deploy.caffemodel?raw=true") set(MODEL_PATH "${CMAKE_CURRENT_BINARY_DIR}/${MODEL_FILE}") diff --git a/bindings/python/examples/dnn/dnn.py b/bindings/python/examples/dnn/dnn.py index a93259473..8529e8a60 100644 --- a/bindings/python/examples/dnn/dnn.py +++ b/bindings/python/examples/dnn/dnn.py @@ -93,19 +93,25 @@ class ModesEnum(Enum): if not status: print("system.getAvailableModes() failed with status: ", status) + status = cameras[0].setMode(modes[ModesEnum.MODE_NEAR.value]) + if not status: + print("cameras[0].setMode() failed with status: ", status) + + cameras[0].setControl("loadModuleData", "call") + types = [] status = cameras[0].getAvailableFrameTypes(types) if not status: print("system.getAvailableFrameTypes() failed with status: ", status) - - status = cameras[0].setFrameType(types[0]) + + status = cameras[0].setFrameType(types[2]) # types[2] is 'mp_pcm' type. if not status: print("cameras[0].setFrameType() failed with status:", status) - - status = cameras[0].setMode(modes[ModesEnum.MODE_NEAR.value]) + + status = cameras[0].start() if not status: - print("cameras[0].setMode() failed with status: ", status) - + print("cameras[0].start() failed with status:", status) + camDetails = tof.CameraDetails() status = cameras[0].getDetails(camDetails) if not status: @@ -115,8 +121,8 @@ class ModesEnum(Enum): smallSignalThreshold = 100 cameras[0].setControl("noise_reduction_threshold", str(smallSignalThreshold)) - camera_range = camDetails.maxDepth - bitCount = camDetails.bitCount + camera_range = 5000 + bitCount = 9 frame = tof.Frame() max_value_of_IR_pixel = 2 ** bitCount - 1 @@ -153,6 +159,7 @@ class ModesEnum(Enum): # Start the computations for object detection using DNN blob = cv.dnn.blobFromImage(result, inScaleFactor, (inWidth, inHeight), (meanVal, meanVal, meanVal), swapRB) + net.setInput(blob) detections = net.forward() diff --git a/bindings/python/examples/dnn/readme.md b/bindings/python/examples/dnn/readme.md index 5a8241417..2b3cf0de9 100644 --- a/bindings/python/examples/dnn/readme.md +++ b/bindings/python/examples/dnn/readme.md @@ -3,7 +3,7 @@ ### Overview This example demonstrates object detection on a combination between the depth frame and the IR frame using the SSD Mobilenet object detection example from OpenCV and the Aditof SDK. It also shows how to compute and display the IR frame. -It works with model taken from [MobileNet-SSD](https://github.com/chuanqi305/MobileNet-SSD/). +It works with model taken from [MobileNet-SSD](https://github.com/djmv/MobilNet_SSD_opencv). Building the project with CMake will download prototxt and caffemodel, used for object detection. For running the python program use: