create_polygon

create_polygon: function(points_list)

Params

points_list: list of points with the format:

  {'x' : Number,
   'y' : Number}

Example

let points_list = []
points_list.push({'x' : 100, 'y' : 100})
points_list.push({'x' : 200, 'y' : 100})
points_list.push({'x' : 100, 'y' : 200})
diffgram.create_polygon(points_list)

Example from OpenCV approxPolyDP()

cv.approxPolyDP(contour, tmp, epsilon, true);
polypoints = tmp.data32S

let offset_x = instance.x_min
let offset_y = instance.y_min
let points_list = []
for (let i = 0; i < polypoints.length; i++) {
  if (i % 2 != 0) {continue}
  let x = polypoints[i] + offset_x
  let y = polypoints[i + 1] + offset_y
  points_list.push({'x' : x, 'y' : y})
}

diffgram.create_polygon(points_list)

Description

Creates an instance of type polygon at the desired spatial coordinates.
The instance defaults to the current label the user has selected.

The function uses check_reasonableness and will warn if the instance is not reasonable (eg has negative values).


Did this page help you?