rectangles

How to detect when rotated rectangles are colliding each other

只愿长相守 提交于 2020-07-03 13:00:47
问题 After saw this question many times and replied with an old (an not usable) code I decide to redo everything and post about it. Rectangles are defined by: center : x and y for his position (remember that 0;0 is TOP Left, so Y go down) size : x and y for his size angle for his rotation (in deg, 0 deg is following axis OX and turn clockwise) The goal is to know if 2 rectangles are colliding or not. 回答1: Will use Javascript in order to demo this (and also provide code) but I can be done on every

Different font sizes in the same annotation of matplotlib?

杀马特。学长 韩版系。学妹 提交于 2020-06-24 22:20:10
问题 I need to annotate a pylab rectangle with few data lines - which are of different length. Searching through the matplotlib documentation, and Googling, I could not find a way to give different parts of an annotation different sizes. The following snippet demonstrates the problem: import pylab from matplotlib.patches import Rectangle pylab.rcParams['verbose.level'] = 'debug-annoying' def draw_rectangle(lower, upper, entry): ax = pylab.subplot(111) r = Rectangle( lower, upper[0]-lower[0], upper

how to crop area of an image inside a rectangle or a squre?

梦想与她 提交于 2020-05-17 07:07:34
问题 First of all I take the picture and then I draw a rectangle over it. Now I just want to crop the image inside the rectangle. I tried drawing contours but that didn't work out in my case. I am stuck on it. import cv2 import numpy as np img = cv2.imread("C:/Users/hp/Desktop/segmentation/abc.jpg", 0); h, w = img.shape[:2] kernel = np.ones((15,15),np.uint8) e = cv2.erode(img,kernel,iterations = 2) d = cv2.dilate(e,kernel,iterations = 1) ret, th = cv2.threshold(d, 150, 255, cv2.THRESH_BINARY_INV)

Simultaneously Aggregating Overlapping Ranges (A Rectangle Problem)

喜你入骨 提交于 2020-02-06 23:59:44
问题 My Problem Consider a set of data with two intervals. For instance, consider a student schedule of classes. Each record has a begin and end date, and each class has a period start time and a period end time. But this schedule is not 'normalized' in the sense that some records overlap. So if you search for records encompassing a given date and period for a student, you might get multiple matches. Here's a contrived example. I represent the dates as integers to simplify the problem: declare

Center of rotated cv::Rect

帅比萌擦擦* 提交于 2020-01-23 05:35:46
问题 I have an image, and I place a rectangle on the image. Then I rotate the image. How do I get the center of the rectangle on the rotated image? Or can I rotate a rectangle somehow to put on rotated image? I think in this case rotation must be done along same point with point used to rotate image. This is the image with a rectangle placed on it. This is the rotated image. Here is the code I use to rotate my image: cv::Mat frame, frameRotated; frame = cv::imread("lena.png"); cv::Rect rect(225

c# Take a screenshot of specific area [closed]

[亡魂溺海] 提交于 2020-01-14 05:02:48
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I know there are many questions like this but none of their answers are working for me or just I can't do it correctly, anyway if it's possible please give me a simple code! I know the location of the green dot

How to divide a set of overlapping ranges into non-overlapping ranges?

送分小仙女□ 提交于 2020-01-12 07:16:13
问题 Let's say you have a set of ranges: 0 - 100: 'a' 0 - 75: 'b' 95 - 150: 'c' 120 - 130: 'd' Obviously, these ranges overlap at certain points. How would you dissect these ranges to produce a list of non-overlapping ranges, while retaining information associated with their original range (in this case, the letter after the range)? For example, the results of the above after running the algorithm would be: 0 - 75: 'a', 'b' 76 - 94: 'a' 95 - 100: 'a', 'c' 101 - 119: 'c' 120 - 130: 'c', 'd' 131 -

How can I draw a rounded rectangle as the border for a rounded Form?

Deadly 提交于 2020-01-11 10:53:10
问题 I'm creating a Form that has a rounded border (as shown in this question). As this person also seems to have an issue with, I can't seem to draw a rounded border. This is code I have used for setting up the actual border shape: // ... within InitializeComponent ... this.FormBorderStyle = FormBorderStyle.None; IntPtr handle = CreateRoundRectRgn(0, 0, Width, Height, 20, 20); Region = System.Drawing.Region.FromHrgn(handle); DeleteObject(handle); this.ResizeRedraw = true; This is code that

How can I draw a rounded rectangle as the border for a rounded Form?

拥有回忆 提交于 2020-01-11 10:53:10
问题 I'm creating a Form that has a rounded border (as shown in this question). As this person also seems to have an issue with, I can't seem to draw a rounded border. This is code I have used for setting up the actual border shape: // ... within InitializeComponent ... this.FormBorderStyle = FormBorderStyle.None; IntPtr handle = CreateRoundRectRgn(0, 0, Width, Height, 20, 20); Region = System.Drawing.Region.FromHrgn(handle); DeleteObject(handle); this.ResizeRedraw = true; This is code that

How to divide an area composed of small squares into bigger rectangles?

非 Y 不嫁゛ 提交于 2020-01-10 14:24:23
问题 Where would i go to look for algorithms that take a 2d grid of values that are either 0 or 1 as input and then identifies all possible non-overlapping rectangles in it? In a more practical explanation: I am drawing a grid that is represented by a number of squares, and i wish to find a way to combine as many adjacent squares into rectangles as possible, in order to cut down on the time spent on cycling through each square and drawing it. Maximum efficiency is not needed, speed is more