bounding-box

What is the proper way to get bounding box for HTML elements relative to the Window?

笑着哭i 提交于 2019-12-04 04:58:06
I'm writing a Firefox extension. I'm trying to limit it to just XUL+Javascript (no XPCOM). When I get a mouseover event for an HTML element, I need to get its bounding box in the windows coordinate system (that is the built-in XUL document browser.xul). The obvious place to start is to put something like this in the mouseover event handler: var rect = e.target.getBoundingClientRect(); Which is great, but that gives me the rect in the HTML document's coordinate system, which is relative to the upper left corner of the HTML drawing area. I want to display a xul:panel element using panel

Doing Ajax updates in SVG breaks getBBox, is there a workaround?

拜拜、爱过 提交于 2019-12-04 03:46:14
I have an SVG page with some complex diagrams; I'm trying to add code that inserts even more complexity via an Ajax call on demand. This is mostly working, but the inserted nodes don't behave properly. In particular getBBox() fails on some elements, in Firefox the error is something like this: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMSVGLocatable.getBBox]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost:1555/svg-scripts.js :: addBackground :: line 91" data: no] The problem seems to be related to

How to find the nearest point in the perimeter of a rectangle to a given point?

妖精的绣舞 提交于 2019-12-03 15:48:51
This is a language-agnostic question. Given a rectangle's dimensions with l,t,w,h (left, top, width, height) and a point x,y , how do I find the nearest point on the perimeter of the rectangle to that point? I have tried to resolve it in Lua, but any other language would do. So far this is my best effort: local function nearest(x, a, b) if a <= x and x <= b then return x elseif math.abs(a - x) < math.abs(b - x) then return a else return b end end local function getNearestPointInPerimeter(l,t,w,h, x,y) return nearest(x, l, l+w), nearest(y, t, t+h) end This works for a point outside of the

Port MATLAB bounding ellipsoid code to Python

China☆狼群 提交于 2019-12-03 03:19:14
MATLAB code exists to find the so-called "minimum volume enclosing ellipsoid" (e.g. here , also here ). I'll paste the relevant part for convenience: function [A , c] = MinVolEllipse(P, tolerance) [d N] = size(P); Q = zeros(d+1,N); Q(1:d,:) = P(1:d,1:N); Q(d+1,:) = ones(1,N); count = 1; err = 1; u = (1/N) * ones(N,1); while err > tolerance, X = Q * diag(u) * Q'; M = diag(Q' * inv(X) * Q); [maximum j] = max(M); step_size = (maximum - d -1)/((d+1)*(maximum-1)); new_u = (1 - step_size)*u ; new_u(j) = new_u(j) + step_size; count = count + 1; err = norm(new_u - u); u = new_u; end U = diag(u); A =

Get the bounding box coordinates in the TensorFlow object detection API tutorial

旧时模样 提交于 2019-12-02 23:28:46
I am new to both python and Tensorflow. I am trying to run the object_detection_tutorial file from the Tensorflow Object Detection API , but I cannot find where I can get the coordinates of the bounding boxes when objects are detected. Relevant code: # The following processing is only for single image detection_boxes = tf.squeeze(tensor_dict['detection_boxes'], [0]) detection_masks = tf.squeeze(tensor_dict['detection_masks'], [0]) ... The place where I assume bounding boxes are drawn is like this: # Visualization of the results of a detection. vis_util.visualize_boxes_and_labels_on_image_array

drawing a bounding box in large images

半腔热情 提交于 2019-12-02 06:09:50
问题 I have a large binary image (4k x 7k pix) from which I want to extract the entire yellow portion as a single rectangle. I tried binary erosion to even out features inside the yellow region. Then I used the bbox method of skimage.regionprops but it does not seem to work fast enough for large image with one large bbox. Do you have any suggestion? 回答1: As the image you provided includes distracting axes, and is the wrong colour and too small, I created as realistic a version as I could with

Calculate bounding box of arbitrary pixel-based drawing

心已入冬 提交于 2019-12-01 18:55:43
Given a contiguous drawing of arbitrary pixels (e.g. on an HTML5 Canvas) is there any algorithm for finding the axis-aligned bounding box that is more efficient than simply looking at every pixel and recording the min/max x/y values ? adrix89 Just scanline from top left to right and down to get y top,and similar algorithm with different directions for the rest. Edit by Phrogz: Here's a pseudo-code implementation. An included optimization ensures that each scan line does not look at pixels covered by an earlier pass: function boundingBox() w = getWidth() # Assuming graphics address goes from [0

Bounding box using MATLAB for the image

此生再无相见时 提交于 2019-12-01 09:04:50
I am trying to draw a bounding box around the white blob in the image below: I did like this: bw = imread('box.jpg'); bw=im2bw(bw); imshow(bw) L = bwlabel(bw); s = regionprops(L, 'Area', 'BoundingBox'); s(1); area_values = [s.Area]; idx = find((100 <= area_values) & (area_values <= 1000)); % list of all the objects %whose area is between 100 and 1000 bw2 = ismember(L, idx); %construct a binary image containing all the objects whose %area is between 100 and 1000 by passing L and idx to ismember. imshow(bw2) The output bw2, so far is: Can someone one tell me how to draw a bounding box around

How to get a rectangular subimage from regionprops(Image,'BoundingBox') in Matlab?

一曲冷凌霜 提交于 2019-11-30 04:04:42
I have some particles that I've identified in a larger image, and need to parse into smaller images for each particle. I've used the regionprops 'BoundingBox' function, but haven't been successful yet. How can I now make a rectangular subimage of image I using BoundingBox? I can use BoundingBox to draw a rectangle on the original image, but the parameters returned by BoundingBox seem not to be of pixel dimension (x,y, width, height), (x1, y1, x2, y2), etc, which I would expect a bounding box to return. I've written some sample code using coins.png to make it easier for anyone to understand.

Oriented Bounding Box is Misshapen and the Wrong Size in OpenGL

扶醉桌前 提交于 2019-11-29 17:17:26
I'm writing a program in OpenGL to load a mesh and draw an oriented bounding box around said mesh. The mesh loads correctly but when I draw the bounding box the box is the wrong shape and far too small. The process I used to calculate this box was to use principle component analysis to find a covariance matrix. I then got the eigenvectors of that matrix and used those as a local co-ordinate system to find the 8 vertices of the cube. Then I calculated a transformation to move the cube from the local co-ordinate system to the global co-ordinate system. The code for calculating the covariance is