def ndarray(classtype, dimensions): """ E.g. for a two-dimensional native double array, use: arr = ndarray(Double.TYPE, [3, 4]) which is equivalent to, using the jython jarray library: arr = array((zeros(4, 'd'), zeros(4, 'd'), zeros(4, 'd')), Class.forName("[D")) but here the native array is created via java.lang.reflect.Array.newInstance(class, dimensions). """ return newArray(classtype, dimensions)
def nativeArray(stype, dimensions): """ Create a native java array such as a double[3][4] like: arr = nativeArray('d', (3, 4)) stype is one of: 'c': char 'b': byte 's': short 'h': short (like in the jarray package) 'i': integer 'l': long 'f': float 'd': double 'z': boolean """ return newArray(__nativeClass[stype].TYPE, dimensions)
def nativeArray(stype, dimensions): """ Create a native java array such as a double[3][4] like: arr = nativeArray('d', (3, 4)) In other words, trivially create primitive two-dimensional arrays or multi-dimensional arrays from Jython. Additionally, if dimensions is a digit, the array has a single dimension. stype is one of: 'c': char 'b': byte 's': short 'h': short (like in the jarray package) 'i': integer 'l': long 'f': float 'd': double 'z': boolean """ return newArray(primitiveTypeClass[stype].TYPE, dimensions)
try: modelFound = model.filterRansac(candidates, inliers, 1000, maxEpsilon, minInlierRatio, minNumInliers) if modelFound: # Apply the transformation defined by the model to the first point # of each pair (PointMatch) of points. That is, to the point from # the first image. PointMatch.apply(inliers, model) except NotEnoughDataPointsException, e: print e if modelFound: print("SUCCESS! Saving results...") # Register images rigid = newArray(Double.TYPE, (6, )) model.toArray(rigid) line = "%d,%s,%s,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d\n" % ( i, list1[i], list2[i], rigid[0], rigid[1], rigid[2], rigid[3], rigid[4], rigid[5], model.cost, 1) f.write(line) print("Done.") print else: line = "%d,%s,%s,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d\n" % ( i, list1[i], list2[i], 1, 0, 0, 1, 0, 0, model.cost, 0) f.write(line) print("Some problem occured for image pair %d..." % (i + 1)) print f.close()