ros kinetic dnn -- OpenCV Error: Assertion failed -- cv2.error -- error: (-215) -- .bashrc -- deep learning [closed]
Hi, I'm doing a project including ROS and OpenCV. ROS kinetic is used for the communication between a camera (an external industry camera) and the computer (Ubuntu 16.04 LTS). I follow the guide/tutorial for Face detection with OpenCv and deep learning on https://www.pyimagesearch.com/2018/02...
When I run the python script with the command
python detect_faces.py --image rooster.jpg --prototxt deploy.prototxt.txt --model res10_300x300_ssd_iter_140000.caffemodel
I get this error
[INFO] loading model...
[INFO] computing object detections...
[ INFO:0] Initialize OpenCL runtime...
OpenCV Error: Assertion failed (input.dims == 4 && (input.type() == 5 || input.type() == 6)) in finalize, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/dnn/src/layers/convolution_layer.cpp, line 78
Traceback (most recent call last):
File "detect_faces.py", line 41, in <module>
detections = net.forward()
cv2.error: /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/dnn/src/layers/convolution_layer.cpp:78: error: (-215) input.dims == 4 && (input.type() == 5 || input.type() == 6) in function finalize
The problem ONLY appears when I have this line included in my .bashrc-file in the home directory
# -------- ROS DEPENDENCIES -------------
source /opt/ros/kinetic/setup.bash
The setup.bash-file contains
#!/usr/bin/env bash
# generated from catkin/cmake/templates/setup.bash.in
CATKIN_SHELL=bash
# source setup.sh from same directory as this file
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
. "$_CATKIN_SETUP_DIR/setup.sh"
I don't understand these files, it's quite new to me, but as it seems, the problem is that the script detect_faces.py
can't work when OpenCV is installed with ROS... does anyone understand the problem?
What is missing from OpenCV with ROS for this to work? Should I download a new package or add something in the bashrc-file? Or use an cv bridge?
Just to clearify, I haven't incorporated ROS with this script yet. I wanted to make it to work without reading from the camera, and only read a saved image in a folder to begin with.
. . . . .
I've found this package here https://github.com/yoshito-n-students... which says "A ROS package containing OpenCV's dnn module that is missing in OpenCV bundled with ROS".
How do I do to try this package?
For better understanding, this is the code for detect_faces.py
from the tutorial
# USAGE
# python detect_faces.py --image rooster.jpg --prototxt deploy.prototxt.txt --model res10_300x300_ssd_iter_140000.caffemodel
# import the necessary packages
import numpy as np
import argparse
import cv2
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="path to input image")
ap.add_argument("-p", "--prototxt", required=True,
help="path to Caffe 'deploy' prototxt file")
ap.add_argument("-m", "--model", required=True,
help="path to Caffe pre-trained model")
ap.add_argument("-c", "--confidence", type=float, default=0.5,
help="minimum probability to filter weak detections")
args = vars(ap.parse_args())
# load our serialized model from disk
print("[INFO] loading model...")
net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])
# load the input image and construct an input blob for the image
# by ...