Calculate the bounding box’s X, Y, Height and Width of a rotated element via JavaScript

I know this is a bit late, but I’ve written a fiddle for exactly this problem, on an HTML5 canvas: http://jsfiddle.net/oscarpalacious/ZdQKg/ I hope somebody finds it useful! I’m actually not calculating your x,y for the upper left corner of the container. It’s calculated as a result of the offset (code from the fiddle example): this.w … Read more

Calculating percentage of Bounding box overlap, for image detector evaluation

For axis-aligned bounding boxes it is relatively simple. “Axis-aligned” means that the bounding box isn’t rotated; or in other words that the boxes lines are parallel to the axes. Here’s how to calculate the IoU of two axis-aligned bounding boxes. def get_iou(bb1, bb2): “”” Calculate the Intersection over Union (IoU) of two bounding boxes. Parameters … Read more

Detecting collision of two sprites that can rotate [duplicate]

A lot will depend on how you are managing your objects, but… import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.KeyStroke; import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public … Read more

How to get string width on Android?

You can use the getTextBounds(String text, int start, int end, Rect bounds) method of a Paint object. You can either use the paint object supplied by a TextView or build one yourself with your desired text appearance. Using a Textview you Can do the following: Rect bounds = new Rect(); Paint textPaint = textView.getPaint(); textPaint.getTextBounds(text, … Read more

Calculate Bounding box coordinates from a rotated rectangle

Transform the coordinates of all four corners Find the smallest of all four x’s as min_x Find the largest of all four x’s and call it max_x Ditto with the y’s Your bounding box is (min_x,min_y), (min_x,max_y), (max_x,max_y), (max_x,min_y) AFAIK, there isn’t any royal road that will get you there much faster. If you are … Read more

Extracting text OpenCV

I used a gradient based method in the program below. Added the resulting images. Please note that I’m using a scaled down version of the image for processing. c++ version The MIT License (MIT) Copyright (c) 2014 Dhanushka Dangampola Permission is hereby granted, free of charge, to any person obtaining a copy of this software … Read more