opencv - Measure real size of irregular shapes in picture -


i have 2 "contours" shapes in array, 1 contourn square know real size, , other mole need make proportional measurement. here image example:

enter image description here

the square has 10x10mm, how can know size of other shape based on square?

what tried far this:

var moleperimeter = cvinvoke.arclength(contours[0], false); double molearea = cvinvoke.contourarea(contours[0], false); var squareperimeter = cvinvoke.arclength(squares[0], true); double squarearea = cvinvoke.contourarea(squares[0], false); textbox2.appendtext("area: " + squarearea / molearea); textbox2.appendtext("perimeter: " + squareperimeter / moleperimeter); 

but dont thinks corret.

assuming mole in circular shape, may use cv::boundingrect(), return cv::rect(), may use rectangular dimensions of mole.

similarly have rectangular dimensions of white patch. dimensions of mole (w1 x h1) , of white patch (w2 x h2).

now calculate dimension of mole w.r.t real world dimensions:

real_w_patch, real_h_patch = 10, 10  real_w_mole = w1/w2 * real_w_patch real_h_mole = h1/h2 * real_h_patch 

note: make sure variables either in float or double make precise calculations.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -