Implementation of SelectiveSearch using python OpenCV
Let’s Manually build the Region for SelectiveSearch
Importing Libraries
Python3
# importing necessary libraries import cv2 import selectivesearch import matplotlib.pyplot as plt |
Creation of bounding boxes Manually
Python3
# Load the image image_path = 'img_1.jpg' image = cv2.imread(image_path) # Define bounding box coordinates (x, y, width, height) bounding_boxes = [ ( 100 , 50 , 200 , 150 ), # Example bounding box 1 ( 300 , 200 , 150 , 100 ), # Example bounding box 2 # Add more bounding boxes as needed ] # Draw bounding boxes on the image for (x, y, w, h) in bounding_boxes: cv2.rectangle(image, (x, y), (x + w, y + h), ( 0 , 255 , 0 ), 2 ) # Display the image with bounding boxes cv2_imshow(image) # Wait for a key press and close the window cv2.waitKey( 0 ) cv2.destroyAllWindows() |
Output:
This bit of code shows how to load and display a picture with bounding boxes drawn around key areas. It specifies bounding boxes as tuples of (x, y, width, and height) coordinates and uses the OpenCV library (cv2) to read an image. The next step is to use cv2.rectangle() to create green rectangles around each location of interest on the image when the code loops over the list of bounding boxes. After using cv2_imshow() to display the image with bounding boxes, the software waits for a key press before destroying all open windows and releasing resources using cv2.waitKey(0) and cv2.destroyAllWindows().
OpenCV Selective Search For Object Detection
OpenCV is a Python library that is used to study images and video streams. It basically extracts the pixels from the images and videos (stream of image) so as to study the objects and thus obtain what they contain. It contains low-level image processing and high-level algorithms for object detection, feature matching etc.
In this article, we will dive into a computer vision technique i.e. selective search for Object Detection in OpenCV.
Table of Content
- Object Detection
- Selective Search
- Implementation of SelectiveSearch using python OpenCV
- Selective Search using Region proposals
Contact Us