In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to achieve in-depth learning OpenCV object detection in Faster-RCNN image recognition, the editor feels very practical, so share with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.
Faster-RCNN image recognition
Faster-RCNN object detection algorithm is the third version of R-CNN object detection algorithm, and there are Fast-RCNN and RCNN algorithms in front of it. Because R-CNN can not realize End-to-End training and Fast R-CNN Selective Search takes a long time, the author updates to Faster-RCNN object detection algorithm on the basis of this second edition.
Object detection
From the structure diagram below, we can see that the Faster-RCNN object detection algorithm integrates feature extraction, proposal extraction, Bounding Box Regression and Classification into one network, and the object detection speed not only hints but also avoids the shortcomings of the first two versions.
Faster R-CNN
Faster R-CNN object detection process:
1. Feature extraction (convolutional layer): Faster R-CNN uses convolution + relu+pooling pooling layer to extract the features of the detected object.
2. Regional prediction network (Region Proposal Network): RPN judges that the anchor point (anchors) belongs to a certain feature by softmax function, and then uses boundary box regression (bounding box regression) to modify anchors to obtain accurate object detection value.
3. Target area pooling (Roi Pooling): collect the input feature data and candidate target area, use this layer information to extract the target area feature data, and then fully connect the layer to identify the picture.
4. Classification: the target area feature data is used to calculate the too recognition picture, and the boundary box regression is used to obtain the exact location of the object detection.
Faster R-CNN flow chart
How to implement Faster R-CNN, and how to achieve the specific work of Faster R-CNN, the editor also referred to the source code of many netizens, but the amount of code is too large (as few as thousands of lines), we shared how to use opencv and MobileNet SSD image recognition and video real-time recognition.
Real-time recognition of MobileNet SSD video stream
MobileNet SSD image recognition
Opencv can also be used to implement the object detection algorithm of Faster R-CNN. Many codes are similar. Friends can also refer to previous articles.
Using OpenCV for object Detection based on Faster R-CNN Deep Learning
The Faster R-CNN prototxt and Faster R-CNN model models have been shared:
Reply: you can get it at RCNN.
There are two models:
Faster_rcnn_inception_v2 and faster_rcnn_resnet50,2 models are data trained on different training sets, of which faster_rcnn_inception_v2 model is smaller and faster. In this period, object detection is built according to this model. The code of the faster_rcnn_resnet50 model is exactly the same as that of the faster_rcnn_inception_v2 model. Just modify the path of the model.
In this section, we will use the deep neural network (dnn) module in OpenCV with Faster R-CNN prototxt and Faster R-CNN model to build our object detector
1. Models and third-party libraries
Model and third-party library
First, import the model and its parameters. If you use the faster_rcnn_resnet50 model, lines 12 and 13 are directly modified to the relative address of the faster_rcnn_resnet50 model.
2. Define the model recognition type
Define the model recognition type
Compared with SSD, Faster R-CNN model can recognize a lot of types, about 100species, almost including the types involved in life, of course, if you have strong data support, you can also train your own model (share how to train your model later)
3. Opencv to establish neural network.
Establishment of Neural Network by opencv
Comparing lines 51 and 52, we can see that the SSD model is trained on caffe, while the Faster R-CNN model is trained on tensorflow, but the powerful opencv library can easily load the pre-training model using the dnn function, and we can see that there is a difference between the model and the parameter file.
4. Calculate the blob and predict the neural network.
Calculate the blob and predict the neural network
Get the length and width parameters of the picture, re-adjust the length and width of the picture to 300cm 300 to calculate the blob of the picture, and then blob is passed into the neural network for calculation, and forward propagation is used to predict the picture.
5. Traverse the predicted value and extract the object that sets the threshold
Traverses the predicted value to extract the object that sets the threshold
The above is how to achieve in-depth learning OpenCV object detection in Faster-RCNN image recognition, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.