开发者

Computer vision for a length ratio

开发者 https://www.devze.com 2023-03-19 10:17 出处:网络
Let\'s say I take a picture of two hammers side-by-side (although they may be aligned differently, but always one on the right and one on the left), wherein each might look like this, and I want to ca

Let's say I take a picture of two hammers side-by-side (although they may be aligned differently, but always one on the right and one on the left), wherein each might look like this, and I want to calculate the ratio of the lengths of the handles of the hammers.

For example, the output from an input image would be the length of the red part of开发者_运维知识库 the one on the left (its handle) divided by the length of the handle of the one on the right.

How would I go about doing this?


If you know the handle color it doesn't sound hard. Just select those pixels and take the longer side of a minimum oriented bounding box.


Here are a couple of hints:

Make sure that the bounding boxes of the hammers don't overlap. If you can guarantee this, try this approach:

  1. Scale the image to width=10%, height=10px. Find the largest amount of pixels in background color near the middle of the image. That allows you to separate the two hammers into individual images. Multiply the positions by 10 to transform them back into coordinates of the original image.

  2. Create two images (one for each hammer)

  3. Crop the border

  4. Scale the image to width = 10px, height = 10%. Count all reddish pixels (save the image and examine the pixel values for red and non-red parts to get an idea what to look for)

0

精彩评论

暂无评论...
验证码 换一张
取 消