def covariance(self): cptr = self._call_cfunc( "vital_feature_covar", [self.C_TYPE_PTR], [self], Covariance.c_ptr_type(2, ctypes.c_double), ) return Covariance(2, ctypes.c_double, from_cptr=cptr)
def covariance(self): cptr = self._call_cfunc( "vital_feature_covar", [self.C_TYPE_PTR], Covariance.c_ptr_type(2, ctypes.c_double), self ) return Covariance(2, ctypes.c_double, from_cptr=cptr)
def covariance(self): """ :return: a copy of this camera's center covariance :rtype: Covariance """ cam_covar = self.VITAL_LIB['vital_camera_center_covar'] cam_covar.argtypes = [self.c_ptr_type(), VitalErrorHandle.c_ptr_type()] cam_covar.restype = Covariance.c_ptr_type(3) with VitalErrorHandle() as eh: c_ptr = cam_covar(self, eh) return Covariance(3, from_cptr=c_ptr)
def covariance(self, covar): if not isinstance(covar, Covariance): # Try an make a covariance out of whatever was provided covar = Covariance(2, self._datatype, covar) print "Setting covar:", covar self._call_cfunc( "vital_feature_{}_set_covar".format(self._tchar), [self.C_TYPE_PTR, Covariance.c_ptr_type(2, self._datatype)], [self, covar], )
def covariance(self, c): """ Set new landmark covariance :type c: vital.types.Covariance """ expected_covar_type = Covariance.c_ptr_type(3, self._datatype) # Convert covariance to correct type if necessary if c.C_TYPE_PTR != expected_covar_type: c = Covariance(3, self._datatype, c.to_matrix()) self._call_cfunc('vital_landmark_{}_set_covar'.format(self._tchar), [self.C_TYPE_PTR, expected_covar_type], [self, c])
def covariance(self, covar): if not isinstance(covar, Covariance): # Try an make a covariance out of whatever was provided covar = Covariance(2, self._datatype, covar) print "Setting covar:", covar self._call_cfunc( "vital_feature_{}_set_covar".format(self._tchar), [self.C_TYPE_PTR, Covariance.c_ptr_type(2, self._datatype)], None, self, covar )
def covariance(self, covar): if self._datatype is None: raise VitalNoTypeInfoException("Type info required but not present") if not isinstance(covar, Covariance): # Try an make a covariance out of whatever was provided covar = Covariance(2, self._datatype, covar) print "Setting covar:", covar self._call_cfunc( "vital_feature_{}_set_covar".format(self._tchar), [self.C_TYPE_PTR, Covariance.c_ptr_type(2, self._datatype)], [self, covar], )
def covariance(self, covar): if self._datatype is None: raise VitalNoTypeInfoException( "Type info required but not present") if not isinstance(covar, Covariance): # Try an make a covariance out of whatever was provided covar = Covariance(2, self._datatype, covar) print "Setting covar:", covar self._call_cfunc( "vital_feature_{}_set_covar".format(self._tchar), [self.C_TYPE_PTR, Covariance.c_ptr_type(2, self._datatype)], [self, covar], )
def test_from_cptr(self): # Create a new covariance from C function and create new python instance # from that pointer c_new_func = VitalObject.VITAL_LIB['vital_covariance_3d_new'] c_new_func.argtypes = [VitalErrorHandle.C_TYPE_PTR] c_new_func.restype = Covariance.c_ptr_type(3, ctypes.c_double) with VitalErrorHandle() as eh: c_ptr = c_new_func(eh) c = Covariance(N=3, c_type=ctypes.c_double, from_cptr=c_ptr) nose.tools.assert_is(c.C_TYPE_PTR, Covariance.c_ptr_type(3, ctypes.c_double)) numpy.testing.assert_array_equal(c.to_matrix(), numpy.eye(3)) c_new_func = VitalObject.VITAL_LIB['vital_covariance_3f_new'] c_new_func.argtypes = [VitalErrorHandle.C_TYPE_PTR] c_new_func.restype = Covariance.c_ptr_type(3, ctypes.c_float) with VitalErrorHandle() as eh: c_ptr = c_new_func(eh) c = Covariance(N=3, c_type=ctypes.c_float, from_cptr=c_ptr) nose.tools.assert_is(c.C_TYPE_PTR,Covariance.c_ptr_type(3, ctypes.c_float)) numpy.testing.assert_array_equal(c.to_matrix(), numpy.eye(3))
def test_from_cptr(self): # Create a new covariance from C function and create new python instance # from that pointer c_new_func = VitalObject.VITAL_LIB['vital_covariance_3d_new'] c_new_func.argtypes = [VitalErrorHandle.C_TYPE_PTR] c_new_func.restype = Covariance.c_ptr_type(3, ctypes.c_double) with VitalErrorHandle() as eh: c_ptr = c_new_func(eh) c = Covariance(N=3, c_type=ctypes.c_double, from_cptr=c_ptr) nose.tools.assert_is(c.C_TYPE_PTR, Covariance.c_ptr_type(3, ctypes.c_double)) numpy.testing.assert_array_equal(c.to_matrix(), numpy.eye(3)) c_new_func = VitalObject.VITAL_LIB['vital_covariance_3f_new'] c_new_func.argtypes = [VitalErrorHandle.C_TYPE_PTR] c_new_func.restype = Covariance.c_ptr_type(3, ctypes.c_float) with VitalErrorHandle() as eh: c_ptr = c_new_func(eh) c = Covariance(N=3, c_type=ctypes.c_float, from_cptr=c_ptr) nose.tools.assert_is(c.C_TYPE_PTR, Covariance.c_ptr_type(3, ctypes.c_float)) numpy.testing.assert_array_equal(c.to_matrix(), numpy.eye(3))
def covariance(self): cptr = self._call_cfunc('vital_landmark_covariance', [self.C_TYPE_PTR], [self], Covariance.c_ptr_type(3)) return Covariance(3, from_cptr=cptr)