Skip to content

Commit

Permalink
Fixing issues in dnn example
Browse files Browse the repository at this point in the history
Signed-off-by: Ravichandran <[email protected]>
  • Loading branch information
srivatsanadi authored and srivats07 committed Jun 17, 2022
1 parent 969673f commit d2861d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bindings/python/examples/dnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")


Expand Down
23 changes: 15 additions & 8 deletions bindings/python/examples/dnn/dnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion bindings/python/examples/dnn/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d2861d6

Please sign in to comment.