Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

draw bounding box on image python cv2

# cv2.rectangle(img, pt1, pt2, color, thickness, lineType, shift)
cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)

"""
x1,y1 ------
|          |
|          |
|          |
--------x2,y2
"""
Comment

draw bounding box on image python opencv

## drawing b.box for given coutour


contours, _ = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
for c in contours:
    rect = cv2.boundingRect(c)
    if rect[2] < 100 or rect[3] < 100: continue
    print cv2.contourArea(c)
    x,y,w,h = rect
    cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),2)
    cv2.putText(im,'Moth Detected',(x+w+10,y+h),0,0.3,(0,255,0))
cv2.imshow("Show",im)
cv2.waitKey()  
cv2.destroyAllWindows()
Comment

PREVIOUS NEXT
Code Example
Python :: code to calculate dice score 
Python :: how to change username of a bot using discord.py 
Python :: Return a Series containing counts of unique values. 
Python :: get all file in folder python 
Python :: install python in centos7 
Python :: Reverse an string Using Recursion in Python 
Python :: json to base64 python 
Python :: create a new dataframe from existing dataframe pandas 
Python :: pandas Unnamed: 0 
Python :: accept user input in python 
Python :: dense rank in pandas 
Python :: change column name pandas 
Python :: numpy count occurrences in array 
Python :: find where df series is null and print 
Python :: pandas read_csv column names 
Python :: create dict from two columns pandas 
Python :: check where bool in a list python 
Python :: python write list to excel file 
Python :: beautifulsoup remove all html tags 
Python :: python display name plot 
Python :: urllib urlretrieve python 3 
Python :: python merge lists 
Python :: python sleep 1 second 
Python :: python kivy 
Python :: smtplib send pdf 
Python :: json python 
Python :: Write a Python program to get the Python version you are using. 
Python :: numpy add new column 
Python :: qrcode.make python 
Python :: flask api abort 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =