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

How to calculate the height of an NSAttributedString with given width in iOS 6 [duplicate]

Option 2 does work in iOS with the proper parameters. NSAttributedString *attrStr = … // your attributed string CGFloat width = 300; // whatever your desired width is CGRect rect = [attrStr boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil]; Without the proper values for the options parameter you will get the wrong height. It is also … 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

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

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