def vxOpticalFlowPyrLKNode_int(graph, old_images, new_images, old_points, new_points_estimates, new_points, termination, epsilon, num_iterations, use_initial_estimate, window_dimension): #validate parameters logger = logging.getLogger(__name__) ret0 = defn.verifyGraph(graph) ret1 = defn.verifyPyramid(old_images) ret2 = defn.verifyPyramid(new_images) ret3 = defn.verifyArray(old_points) ret4 = defn.verifyArray(new_points) ret5 = len(window_dimension) == 2 ret6 = defn.verifyArray(new_points_estimates) ret7 = window_dimension[0] == window_dimension[1] ret8 = (window_dimension[0] == 11) | (window_dimension[0] == 13) ret = ret0 & ret1 & ret2 & ret3 & ret4 & ret5 & ret6 & ret7 & ret8 if ret is not True: logger.error('vxOpticalFlowPyrLKNode: one or all parameters are wrong') raise AttributeError max_count = 30 final_epsilon = 0.01 if ((termination < brcm_openvx.VX_TERM_CRITERIA_ITERATIONS) or (termination > brcm_openvx.VX_TERM_CRITERIA_BOTH)): logger.error('vxOpticalFlowPyrLKNode: termination not supported') raise ValueError if ((isinstance(epsilon, numbers.Number) == False) or (isinstance(num_iterations, numbers.Number) == False)): logger.error('vxOpticalFlowPyrLKNode: epsilon is not a valid number') raise TypeError if termination is brcm_openvx.VX_TERM_CRITERIA_ITERATIONS or termination is brcm_openvx.VX_TERM_CRITERIA_BOTH: max_count = min(max(num_iterations, 0), 100) if termination is brcm_openvx.VX_TERM_CRITERIA_EPSILON or termination is brcm_openvx.VX_TERM_CRITERIA_BOTH: final_epsilon = min(max(epsilon, 0.), 10.) final_epsilon = final_epsilon * final_epsilon logger.info( 'vxOpticalFlowPyrLKNode:use_initial_estimate is not used currently') final_epsilon = int(final_epsilon * (1 << 28)) node = defn.create_dict(defn.VX_NODE, graph) node['VX_DATA'] = OpticalFlowPyrLKNode( graph['VX_DATA'], old_images['VX_DATA'], new_images['VX_DATA'], old_points['VX_DATA'], new_points_estimates['VX_DATA'], new_points['VX_DATA'], max_count, final_epsilon, window_dimension[0]) graph['VX_DATA'].node.append(node) return node
def vxGetPyramidLevel_int(pyramid, idx): logger = logging.getLogger(__name__) ret = defn.verifyPyramid(pyramid) if ret is not True: logger.error('vxGetPyramidLevel: pyramid cannot be verified') raise AttributeError if idx > (pyramid['VX_DATA'].levels - 1): logger.error('vxGetPyramidLevel: level doesnt exist') raise AttributeError image = defn.create_dict(defn.VX_IMAGE, pyramid) image['VX_DATA'] = pyramid['VX_DATA'].images[idx] pyramid['VX_PARENT']['VX_IMAGE'].append(image) return image
def vxLaplacianPyramidNode_int(graph, input, laplacian, output): #validate parameters logger = logging.getLogger(__name__) ret0 = defn.verifyGraph(graph) ret1 = defn.verifyImage(input) ret2 = defn.verifyPyramid(laplacian) ret3 = defn.verifyImage(output) ret = ret0 & ret1 & ret2 & ret3 if ret is not True: logger.error('vxLaplacianPyramidNode: one or all parameters are wrong') raise AttributeError node = defn.create_dict(defn.VX_NODE, graph) laplacianNode = VXLaplacianPyramidNode(graph['VX_DATA'], input['VX_DATA'], laplacian['VX_DATA'], output['VX_DATA']) node['VX_DATA'] = laplacianNode graph['VX_DATA'].node.append(node) return node
def vxGaussianPyramidNode_int(graph, input, pyramiid): #validate parameters logger = logging.getLogger(__name__) ret0 = defn.verifyGraph(graph) ret1 = defn.verifyImage(input) ret2 = defn.verifyPyramid(pyramiid) ret = ret0 & ret1 & ret2 if ret is not True: logger.error('vxGaussianPyramidNode: one or all parameters are wrong') raise AttributeError node = defn.create_dict(defn.VX_NODE, graph) gaussPyrNode = VXGaussianPyramidNode(graph['VX_DATA'], input['VX_DATA'], pyramiid['VX_DATA']) if (pyramiid['VX_DATA'].scale is brcm_openvx.VX_SCALE_PYRAMID_ORB): for i in range(pyramiid['VX_DATA'].levels - 1): gaussPyrNode.scaleNode[i].compute(graph['VX_DATA']) node['VX_DATA'] = gaussPyrNode graph['VX_DATA'].node.append(node) return node