Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set(self, o):
if type(o) is Point2D:
self.x = o.x
self.y = o.y
elif type(o) is tuple:
self.x = o[0]
self.y = o[1]
elif jg.is_instance_of(gateway, o, gateway.jvm.georegression.struct.point.Point2D_F64):
self.x = o.getX()
self.y = o.getY()
elif jg.is_instance_of(gateway, o, gateway.jvm.georegression.struct.point.Point2D_F32):
self.x = o.getX()
self.y = o.getY()
else:
raise Exception("Unknown object type")
paramRanges = []
##Using some bsearch code here thanks to Forrest Stonedahl and the NetLogo team
for paramSpec in paramSpecs:
paramRange = []
if (jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.DoubleDiscreteSpec") | jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.DoubleContinuousSpec")) :
count = paramSpec.choiceCount()
val_min = paramSpec.getValueFromChoice(0,count)
val_max = paramSpec.getValueFromChoice(count - 1,count)
step = (val_max - val_min)/(count - 1)
paramRange = [val_min,step,val_max]
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.CategoricalSpec"):
count = paramSpec.choiceCount()
paramRange = []
for choice in range(0,count):
paramRange.append(paramSpec.getValueFromChoice(choice,count))
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.ConstantSpec"):
paramRange = [paramSpec.getValueFromChoice(0,1)]
paramRanges.append(paramRange)
return paramRanges
def set(self, src):
if isinstance(src, Polygon2D):
self.vertexes = []
for v in src.vertexes:
self.vertexes.append(v.copy())
elif jg.is_instance_of(gateway, src, gateway.jvm.georegression.struct.shapes.Polygon2D_F64):
self.vertexes = []
for i in range(src.size()):
self.vertexes.append(Point2D(src.get(i)))
elif jg.is_instance_of(gateway, src, gateway.jvm.georegression.struct.shapes.Polygon2D_F32):
self.vertexes = []
for i in range(src.size()):
self.vertexes.append(Point2D(src.get(i)))
else:
self.vertexes = []
for v in src:
self.vertexes.append(Point2D(v[0], v[1]))
def __init__(self, java_object):
JavaWrapper.__init__(self, java_object)
if is_instance_of(gateway, java_object, gateway.jvm.boofcv.struct.distort.Point3Transform2_F32):
self.is32 = True
self.point_out = create_java_point_2D_f32()
elif is_instance_of(gateway, java_object, gateway.jvm.boofcv.struct.distort.Point3Transform2_F64):
self.is32 = False
self.point_out = create_java_point_2D_f64()
else:
raise RuntimeError("Unexpected java object. "+java_object.getClass().getSimpleName())
def set(self, o):
if type(o) is Quadrilateral2D:
self.a.set(o.a)
self.b.set(o.b)
self.c.set(o.c)
self.d.set(o.d)
elif jg.is_instance_of(gateway, o, gateway.jvm.georegression.struct.shapes.Quadrilateral_F64):
self.a.set(o.getA())
self.b.set(o.getB())
self.c.set(o.getC())
self.d.set(o.getD())
else:
raise Exception("Unknown object type")
def visualize_matches(image_left, image_right, points_src, points_dst, match_indexes,
title="Associated Features"):
if type(points_src) is list:
points_src = pyboof.p2b_list_point2D(points_src, np.double)
if type(points_dst) is list:
points_dst = pyboof.p2b_list_point2D(points_dst, np.double)
if type(match_indexes) is list:
raise Exception("Haven't bothered to implement python to java conversion for match_indexes yet")
# If possible, convert images into a BufferedImage data type
if jg.is_instance_of(gateway, image_left, gateway.jvm.boofcv.struct.image.ImageBase):
image_left = gateway.jvm.boofcv.io.image.ConvertBufferedImage.convertTo(image_left, None, True)
if jg.is_instance_of(gateway, image_right, gateway.jvm.boofcv.struct.image.ImageBase):
image_right = gateway.jvm.boofcv.io.image.ConvertBufferedImage.convertTo(image_right, None, True)
panel = gateway.jvm.boofcv.gui.feature.AssociationPanel(20)
panel.setImages(image_left, image_right)
panel.setAssociation(points_src, points_dst, match_indexes)
gateway.jvm.boofcv.gui.image.ShowImages.showWindow(panel, title)
def getParamRanges(self):
paramSpecs = self.__bridge.getParamList(self.__session, self.__path).getParamSpecs()
paramRanges = []
##Using some bsearch code here thanks to Forrest Stonedahl and the NetLogo team
for paramSpec in paramSpecs:
paramRange = []
if (jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.DoubleDiscreteSpec") | jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.DoubleContinuousSpec")) :
count = paramSpec.choiceCount()
val_min = paramSpec.getValueFromChoice(0,count)
val_max = paramSpec.getValueFromChoice(count - 1,count)
step = (val_max - val_min)/(count - 1)
paramRange = [val_min,step,val_max]
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.CategoricalSpec"):
count = paramSpec.choiceCount()
paramRange = []
for choice in range(0,count):
paramRange.append(paramSpec.getValueFromChoice(choice,count))
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.ConstantSpec"):
paramRange = [paramSpec.getValueFromChoice(0,1)]
paramRanges.append(paramRange)
return paramRanges
def set(self, o):
if type(o) is Point2D:
self.x = o.x
self.y = o.y
elif type(o) is tuple:
self.x = o[0]
self.y = o[1]
elif jg.is_instance_of(gateway, o, gateway.jvm.georegression.struct.point.Point2D_F64):
self.x = o.getX()
self.y = o.getY()
elif jg.is_instance_of(gateway, o, gateway.jvm.georegression.struct.point.Point2D_F32):
self.x = o.getX()
self.y = o.getY()
else:
raise Exception("Unknown object type")
def set(self, src):
if isinstance(src, Polygon2D):
self.vertexes = []
for v in src.vertexes:
self.vertexes.append(v.copy())
elif jg.is_instance_of(gateway, src, gateway.jvm.georegression.struct.shapes.Polygon2D_F64):
self.vertexes = []
for i in range(src.size()):
self.vertexes.append(Point2D(src.get(i)))
elif jg.is_instance_of(gateway, src, gateway.jvm.georegression.struct.shapes.Polygon2D_F32):
self.vertexes = []
for i in range(src.size()):
self.vertexes.append(Point2D(src.get(i)))
else:
self.vertexes = []
for v in src:
self.vertexes.append(Point2D(v[0], v[1]))
def setParamsRandom(self):
paramSpecs = self.__bridge.getParamList(self.__session, self.__path).getParamSpecs()
##Using some bsearch code here thanks to Forrest Stonedahl and the NetLogo team
for paramSpec in paramSpecs:
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.DoubleDiscreteSpec"):
paramValue = paramSpec.generateRandomValue(self.__gateway.jvm.org.nlogo.api.MersenneTwisterFast())
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.DoubleContinuousSpec"):
paramValue = paramSpec.generateRandomValue(self.__gateway.jvm.org.nlogo.api.MersenneTwisterFast())
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.CategoricalSpec"):
paramValue = paramSpec.generateRandomValue(self.__gateway.jvm.org.nlogo.api.MersenneTwisterFast())
if type(paramValue) != bool:#isinstance(data[i][k], bool)
paramValue = '"{}"'.format(paramSpec.generateRandomValue(self.__gateway.jvm.org.nlogo.api.MersenneTwisterFast()))
if jg.is_instance_of(self.__gateway,paramSpec,"bsearch.space.ConstantSpec"):
paramValue = paramSpec.generateRandomValue(self.__gateway.jvm.org.nlogo.api.MersenneTwisterFast())
print("NetLogo command: set " + str(paramSpec.getParameterName()) + " " + str(paramValue))
self.__bridge.command(self.__session, "set " + str(paramSpec.getParameterName()) + " " + str(paramValue))