logo
down
shadow

How to identify empty rectangle using OpenCV


How to identify empty rectangle using OpenCV

By : Enteez
Date : October 23 2020, 08:10 AM
hope this fix your issue It will be extremely helpful if you share your code in your question as we can modify it to answer your question.
Anyway, with the amount of information i get from your question, i see that you have done most of the work using findContour. To separate empty boxes from filled box, use the function countNonZero.
code :
x,y,w,h = contour_box[i]
total_white = cv2.countNonZero(img_Src[y:y+h,x:x+w])
ratio = total_white / float(w*h)

# if the white pixel count is 80% of box size, box is empty
if ratio > 0.8 :
     box_is_empty = True


Share : facebook icon twitter icon
How to identify subtriangle within a rectangle given a coordinate in that rectangle

How to identify subtriangle within a rectangle given a coordinate in that rectangle


By : Ashiqur Rahman
Date : March 29 2020, 07:55 AM
Hope this helps
code :
aboveRed = x*h > y*w;
aboveGreen = (w-x)*h > y*w;
if (aboveRed)
{
    if (aboveGreen) return "C"; else return "B";
}
else
{
    if (aboveGreen) return "D"; else return "A";
}
OpenCV - How to find rectangle contour of a rectangle with round corner?

OpenCV - How to find rectangle contour of a rectangle with round corner?


By : 梁思前
Date : March 29 2020, 07:55 AM
Any of those help I'm trying to find the contour of a rectangle object with round corner in a image. I tried HoughLinesP and findContours, but did not achieve the desired result. , You need to find the bounding rectangle of the found contours.
code :
img = cv2.imread("image.png", -1)

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

binary = cv2.bitwise_not(gray)

(_,contours,_) = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

for contour in contours:
    (x,y,w,h) = cv2.boundingRect(contour)
    cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0), 2)
Opencv: How to use rectangle() function to draw a rectangle on a COPY of an image rather than the original image?

Opencv: How to use rectangle() function to draw a rectangle on a COPY of an image rather than the original image?


By : Ricardo Soares
Date : March 29 2020, 07:55 AM
This might help you this is what I am trying to accomplish. I have some images with multiple bounding boxes associated with each image. I want to load an image, draw box1 on image, and save the new image as image_1. Then I want to draw box2 on image, and save it as image_2. The problem I am having currently is that image_2 ends up with both box1 and box2 on it, rather than just box2. I tried to circumvent the issue by saving a temporary copy of the image each time I draw a new bounding box, but it seems like the original image still gets modified somehow. How can I create a copy of the loaded img such that changes to the copy will not get propagated to the loaded img when I call opencv's rectangle() function? Below is what I have currently. , This can be accomplished fairly easily using numpy.
code :
for i in range(len(boxes[fname])):
   temp = numpy.copy(img)
   .....
tmp = img
How to draw a rounded rectangle (rectangle with rounded corners) with OpenCV?

How to draw a rounded rectangle (rectangle with rounded corners) with OpenCV?


By : user4677644
Date : March 29 2020, 07:55 AM
it fixes the issue I realized, this is much easier that I thought. Here is my function. I hope it is helpful for someone.
Algorithm for finding an empty space that fits a rectangle that is closest to a target rectangle among other rectangles

Algorithm for finding an empty space that fits a rectangle that is closest to a target rectangle among other rectangles


By : Diegomx
Date : March 29 2020, 07:55 AM
should help you out You might investigate map labeling algorithms. See, for example, these lecture notes by Robero Tamassia @Brown: PDF download.
Related Posts Related Posts :
  • Submitting login form with scrapy
  • How do i edit the favicon in the Browsable API in Django REST framework?
  • multiprocessing.Pool.map_async doesn't seem to... do anything at all?
  • Python Selenium: Stale Element Reference Exception Error
  • Datetime conversion - How to extract the inferred format?
  • Import YAML variables automatically?
  • How to create a powershell shortcut for my python file
  • Python's 'set' operator doesn't work with numpy.nan
  • Pass object fields and one2many fields on same method - Odoo v8
  • Select columns based on column name and location in Pandas
  • Standardizing timeseries in Pandas using interpolation
  • How many tweets can be collected?
  • how format specifier taking value while tuple list is passed
  • How to print a numpy array with data type?
  • Timeout child thread for python3
  • How can I regroup a dataframe and accumulate a colume's values?
  • Bulk Insert into SQL Server with Python not working
  • Removing last rows of each group based on condition in a pandas dataframe
  • Why the css file can not be found in Django template?
  • targeting center of mass - scipy / numpy
  • Foursquare - get tips from VENUE_ID
  • Unpack a dictionary to format
  • encoding special characters in python2
  • Replacing integers with NaN results in the entire column becoming float dtype
  • Python 3.6 - BeautifulSoup4, parse table AttributeError: ResultSet object has no attribute 'findAll'
  • Convert panda date list to python list of date strings
  • escape response from Scrapy to parse json
  • How to create a same dropdown menu for different labels?
  • Why are some python variables uppercase whereas others are lowercase?
  • Machine Learning, What are the common techniques for feature engineering and presenting the model?
  • Modify value of a Django form field during clean() and validate again
  • Heroku Django app can't start up -- 'No module named site'
  • Getting list of dates (excluding weekends)
  • Im trying to create the regular expression to include the text and not the href
  • Python file.readline(2) reads first 2 charectars
  • Groupby with handling empty bin in python
  • Modifying Gcode
  • calling a value in a dictionary within a dictionary (reading a json file)
  • Bouncing ball invalid syntax why is that?
  • Python making a counter
  • Python rstrip and split
  • What does the String mean in numpy.r_?
  • How to correctly extend variable __all__ in a __init__.py?
  • Python behaves weird with piped input
  • Python 3 two dimensional list comprehension
  • How to slice image by broadcasting slices? Error: 'only integer scalar arrays can be converted to a scalar index' in pyt
  • (Python Beginner) Need a start on classes
  • IndexError: At least one sheet must be visible
  • How to solve a system of linear equations over the nonnegative integers?
  • Pandas keep the most complete rows
  • "List index out of range" error in Python Memory Match game
  • Numpy: how to use argmax results to get the actual max?
  • Google Cloud Dataflow can't import 'google.cloud.datastore'
  • Calculate pandas DataFrame column by custom routine which accepts dictionary as input
  • Connect to a Class Method by it's method name holded into a var in a for loop in python
  • PyQt5 signals and threading.Timer
  • Replace 2 characters in a string in python
  • Passing command line arguments from a folder script to a file script
  • Understand the syntaxe X[Y == c] in Numpy
  • Optimize beginner python script about substring replacement
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org