Extracts camera parameters from the solution. Checks for errors
185707
private boolean extractCalibration(DMatrixRMaj x , CameraPinhole calibration) {
		double s = x.data[5];

		double cx = calibration.cx = x.data[2]/s;
		double cy = calibration.cy = x.data[4]/s;
		double fy = calibration.fy = Math.sqrt(x.data[3]/s-cy*cy);
		double sk = calibration.skew = (x.data[1]/s-cx*cy)/fy;
		calibration.fx = Math.sqrt(x.data[0]/s - sk*sk - cx*cx);

		if( calibration.fx < 0 || calibration.fy < 0 )
			return false;
		if(UtilEjml.isUncountable(fy) || UtilEjml.isUncountable(calibration.fx))
			return false;
		if(UtilEjml.isUncountable(sk))
			return false;
		return true;
	}
735145
def check_picture(file_name, mediainfo_path=None):
    
    D = call_MediaInfo(file_name, mediainfo_path)
    # Check that the file analyzed was a valid movie
    if (
        ("Image" not in D) or
        ("Width" not in D["Image"]) or
        ("Height" not in D["Image"])
    ):
        raise MediaInfoError("Could not determine all picture paramters")

    return D
55767
def camera_position(self, pose=None):
        '''
        
        '''
        if pose is None:
            pose = self.pose()
        t, r = pose
        return -np.matrix(cv2.Rodrigues(r)[0]).T * np.matrix(t)
444905
def get_parameters(self):
        
        d = {}
        for k in ['label', 'verbose_name', 'required', 'hint', 'placeholder', 'choices',
            'default', 'validators', 'max_length']:
            d[k] = getattr(self, k)
        return d
257405
def fixed_parameters(self):
        
        libfn = utils.get_lib_fn('getTransformFixedParameters%s'%self._libsuffix)
        return np.asarray(libfn(self.pointer))
659553
def _load_calib(self):
        """"""
        # We'll build the calibration parameters as a dictionary, then
        # convert it to a namedtuple to prevent it from being modified later
        data = {}

        # Load the calibration file
        calib_filepath = os.path.join(self.sequence_path, 'calib.txt')
        filedata = utils.read_calib_file(calib_filepath)

        # Create 3x4 projection matrices
        P_rect_00 = np.reshape(filedata['P0'], (3, 4))
        P_rect_10 = np.reshape(filedata['P1'], (3, 4))
        P_rect_20 = np.reshape(filedata['P2'], (3, 4))
        P_rect_30 = np.reshape(filedata['P3'], (3, 4))

        data['P_rect_00'] = P_rect_00
        data['P_rect_10'] = P_rect_10
        data['P_rect_20'] = P_rect_20
        data['P_rect_30'] = P_rect_30

        # Compute the rectified extrinsics from cam0 to camN
        T1 = np.eye(4)
        T1[0, 3] = P_rect_10[0, 3] / P_rect_10[0, 0]
        T2 = np.eye(4)
        T2[0, 3] = P_rect_20[0, 3] / P_rect_20[0, 0]
        T3 = np.eye(4)
        T3[0, 3] = P_rect_30[0, 3] / P_rect_30[0, 0]

        # Compute the velodyne to rectified camera coordinate transforms
        data['T_cam0_velo'] = np.reshape(filedata['Tr'], (3, 4))
        data['T_cam0_velo'] = np.vstack([data['T_cam0_velo'], [0, 0, 0, 1]])
        data['T_cam1_velo'] = T1.dot(data['T_cam0_velo'])
        data['T_cam2_velo'] = T2.dot(data['T_cam0_velo'])
        data['T_cam3_velo'] = T3.dot(data['T_cam0_velo'])

        # Compute the camera intrinsics
        data['K_cam0'] = P_rect_00[0:3, 0:3]
        data['K_cam1'] = P_rect_10[0:3, 0:3]
        data['K_cam2'] = P_rect_20[0:3, 0:3]
        data['K_cam3'] = P_rect_30[0:3, 0:3]

        # Compute the stereo baselines in meters by projecting the origin of
        # each camera frame into the velodyne frame and computing the distances
        # between them
        p_cam = np.array([0, 0, 0, 1])
        p_velo0 = np.linalg.inv(data['T_cam0_velo']).dot(p_cam)
        p_velo1 = np.linalg.inv(data['T_cam1_velo']).dot(p_cam)
        p_velo2 = np.linalg.inv(data['T_cam2_velo']).dot(p_cam)
        p_velo3 = np.linalg.inv(data['T_cam3_velo']).dot(p_cam)

        data['b_gray'] = np.linalg.norm(p_velo1 - p_velo0)  # gray baseline
        data['b_rgb'] = np.linalg.norm(p_velo3 - p_velo2)   # rgb baseline

        self.calib = namedtuple('CalibData', data.keys())(*data.values())
102971
def read_parameters(request, view_kwargs=None, capture_errors=False):  # noqa: C901
    
    if view_kwargs is None:
        view_kwargs = {}
    params = {}
    errors = {}
    for param in request.api_info.operation.parameters:
        try:
            value = param.get_value(request, view_kwargs)
            if value is NO_VALUE:
                if param.has_default:
                    params[param.name] = param.default
                elif param.required:  # Required but missing
                    errors[param.name] = MissingParameter('parameter %s is required but missing' % param.name)
                continue  # No value, or a default was added, or an error was added.
            params[param.name] = param.cast(request.api_info.api, value)
        except (NotImplementedError, ImproperlyConfigured):
            raise
        except Exception as e:
            if not capture_errors:
                raise
            errors[param.name] = e
    if errors:
        raise ErroneousParameters(errors, params)
    return params
1253386
private void convertToOutput( View origin ) {
		structure = new SceneStructureMetric(false);
		observations = new SceneObservations(viewsAdded.size());

		// TODO can this be simplified?
		int idx = 0;
		for( String key : graph.cameras.keySet() ) {
			cameraToIndex.put(key,idx++);
		}

		structure.initialize(cameraToIndex.size(),viewsAdded.size(), graph.features3D.size());

		for ( String key : graph.cameras.keySet() ) {
			int i = cameraToIndex.get(key);
			structure.setCamera(i,true,graph.cameras.get(key).pinhole);
		}

		// look up table from old index to new index
		int viewOldToView[] = new int[ graph.nodes.size() ];
		Arrays.fill(viewOldToView,-1);
		for (int i = 0; i < viewsAdded.size(); i++) {
			viewOldToView[ graph.nodes.indexOf(viewsAdded.get(i))] = i;
		}

		for( int i = 0; i < viewsAdded.size(); i++ ) {
			View v = viewsAdded.get(i);
			int cameraIndex = cameraToIndex.get(v.camera.camera);
			structure.setView(i,v==origin,v.viewToWorld.invert(null));
			structure.connectViewToCamera(i,cameraIndex);
		}

		for (int indexPoint = 0; indexPoint < graph.features3D.size(); indexPoint++) {
			Feature3D f = graph.features3D.get(indexPoint);

			structure.setPoint(indexPoint,f.worldPt.x,f.worldPt.y,f.worldPt.z);

			if( f.views.size() != f.obsIdx.size )
				throw new RuntimeException("BUG!");

			for (int j = 0; j < f.views.size(); j++) {
				View view = f.views.get(j);
				int viewIndex = viewOldToView[view.index];
				structure.connectPointToView(indexPoint,viewIndex);

				Point2D_F64 pixel = viewsAdded.get(viewIndex).observationPixels.get(f.obsIdx.get(j));
				observations.getView(viewIndex).add(indexPoint,(float)(pixel.x),(float)(pixel.y));
			}
		}

	}
467710
def create_visual_input(camera_parameters, name):
        
        o_size_h = camera_parameters['height']
        o_size_w = camera_parameters['width']
        bw = camera_parameters['blackAndWhite']

        if bw:
            c_channels = 1
        else:
            c_channels = 3

        visual_in = tf.placeholder(shape=[None, o_size_h, o_size_w, c_channels], dtype=tf.float32,
                                   name=name)
        return visual_in
601970
public static <T extends CameraPinhole> void save(T parameters , Writer outputWriter ) {
		PrintWriter out = new PrintWriter(outputWriter);

		Yaml yaml = createYmlObject();

		Map<String, Object> data = new HashMap<>();

		if( parameters instanceof CameraPinholeBrown) {
			out.println("# Pinhole camera model with radial and tangential distortion");
			out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape");
			out.println("# radial = radial distortion, (t1,t2) = tangential distortion");
			out.println();
			putModelRadial((CameraPinholeBrown) parameters, data);
		} else if( parameters instanceof CameraUniversalOmni ) {
			out.println("# Omnidirectional camera model with radial and tangential distortion");
			out.println("# C. Mei, and P. Rives. \"Single view point omnidirectional camera calibration" +
					" from planar grids.\"  ICRA 2007");
			out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape");
			out.println("# mirror_offset = offset mirror along z-axis in unit circle");
			out.println("# radial = radial distortion, (t1,t2) = tangential distortion");
			out.println();
			putModelUniversalOmni((CameraUniversalOmni) parameters, data);
		} else {

			out.println("# Pinhole camera model");
			out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape");
			out.println();
			putModelPinhole(parameters,data);
		}

		yaml.dump(data,out);

		out.close();
	}
377049
public void getCameraMatrix(int view , DMatrixRMaj cameraMatrix ) {
		cameraMatrix.reshape(3,4);
		CommonOps_DDRM.extract(P,view*3,0,cameraMatrix);

		for (int col = 0; col < 4; col++) {
			cameraMatrix.data[cameraMatrix.getIndex(0,col)] *= pixelScale;
			cameraMatrix.data[cameraMatrix.getIndex(1,col)] *= pixelScale;
		}
	}
282828
def is_feasible(self, solution):
        
        newvars = solution.new.keys()
        for newvar in newvars:
            for c in self._constraints_for_var.get(newvar, []):
                values = c.extract_values(solution, use_defaults=True)
                if not c(*values):
                    return False
        return True
282871
def geometry(self):
        

        if self.coord is None:
            return None
        ra = self.coord.ra.degree
        dec = self.coord.dec.degree
        ccds = []

        for geo in self._geometry[self.camera]:
            ycen = geo["dec"] + dec
            xcen = geo["ra"] / math.cos(math.radians(ycen)) + ra
            try:
                dy = geo["ddec"]
                dx = geo["dra"] / math.cos(math.radians(ycen))
                ccds.append([xcen - dx / 2.0, ycen - dy / 2.0, xcen + dx / 2.0, ycen + dy / 2.0])
            except:
                rad = geo["rad"]
                ccds.append([xcen, ycen, rad])
        return ccds
830720
def process_params(params)
      parameters = { url: CGI.unescape(params.url) }

      if params.metadata
        parameters[:metadata] = extract_metadata(params.metadata)
      end

      parameters
    end
1197045
def getparams(self, param):
        

        return list(cparam for cparam in self.values() if cparam == param)
873952
def _poseFromQuad(self, quad=None):
        '''
        
        '''
        if quad is None:
            quad = self.quad
        if quad.ndim == 3:
            quad = quad[0]
        # http://answers.opencv.org/question/1073/what-format-does-cv2solvepnp-use-for-points-in/
        # Find the rotation and translation vectors.
        img_pn = np.ascontiguousarray(quad[:, :2],
                                      dtype=np.float32).reshape((4, 1, 2))

        obj_pn = self.obj_points - self.obj_points.mean(axis=0)
        retval, rvec, tvec = cv2.solvePnP(
            obj_pn,
            img_pn,
            self.opts['cameraMatrix'],
            self.opts['distCoeffs'],
            flags=cv2.SOLVEPNP_P3P  # because exactly four points are given
        )
        if not retval:
            print("Couln't estimate pose")
        return tvec, rvec
505376
private void processParameters() throws BadElementException, IOException {
        type = JPEG;
        originalType = ORIGINAL_JPEG;
        InputStream is = null;
        try {
            String errorID;
            if (rawData == null){
                is = url.openStream();
                errorID = url.toString();
            }
            else{
                is = new java.io.ByteArrayInputStream(rawData);
                errorID = "Byte array";
            }
            if (is.read() != 0xFF || is.read() != 0xD8)	{
                throw new BadElementException(errorID + " is not a valid JPEG-file.");
            }
            boolean firstPass = true;
            int len;
            while (true) {
                int v = is.read();
                if (v < 0)
                    throw new IOException("Premature EOF while reading JPG.");
                if (v == 0xFF) {
                    int marker = is.read();
                    if (firstPass && marker == M_APP0) {
                        firstPass = false;
                        len = getShort(is);
                        if (len < 16) {
                            Utilities.skip(is, len - 2);
                            continue;
                        }
                        byte bcomp[] = new byte[JFIF_ID.length];
                        int r = is.read(bcomp);
                        if (r != bcomp.length)
                            throw new BadElementException(errorID + " corrupted JFIF marker.");
                        boolean found = true;
                        for (int k = 0; k < bcomp.length; ++k) {
                            if (bcomp[k] != JFIF_ID[k]) {
                                found = false;
                                break;
                            }
                        }
                        if (!found) {
                            Utilities.skip(is, len - 2 - bcomp.length);
                            continue;
                        }
                        Utilities.skip(is, 2);
                        int units = is.read();
                        int dx = getShort(is);
                        int dy = getShort(is);
                        if (units == 1) {
                            dpiX = dx;
                            dpiY = dy;
                        }
                        else if (units == 2) {
                            dpiX = (int)(dx * 2.54f + 0.5f);
                            dpiY = (int)(dy * 2.54f + 0.5f);
                        }
                        Utilities.skip(is, len - 2 - bcomp.length - 7);
                        continue;
                    }
                    if (marker == M_APPE) {
                        len = getShort(is) - 2;
                        byte[] byteappe = new byte[len];
                        for (int k = 0; k < len; ++k) {
                            byteappe[k] = (byte)is.read();
                        }
                        if (byteappe.length >= 12) {
                            String appe = new String(byteappe, 0, 5, "ISO-8859-1");
                            if (appe.equals("Adobe")) {
                                invert = true;
                            }
                        }
                        continue;
                    }
                    if (marker == M_APP2) {
                        len = getShort(is) - 2;
                        byte[] byteapp2 = new byte[len];
                        for (int k = 0; k < len; ++k) {
                            byteapp2[k] = (byte)is.read();
                        }
                        if (byteapp2.length >= 14) {
                            String app2 = new String(byteapp2, 0, 11, "ISO-8859-1");
                            if (app2.equals("ICC_PROFILE")) {
                                int order = byteapp2[12] & 0xff;
                                int count = byteapp2[13] & 0xff;
                                
                                // some jpeg producers don't know how to count to 1
                                if (order < 1) {
                                	order = 1;
                                }
                                if (count < 1) {
                                	count = 1;
                                }
                                if (icc == null){
                                    icc = new byte[count][];
                                }
                                int idx = order - 1;
                                if( idx >= 0 ) {
                                	icc[idx] = byteapp2;
                                }                                
                            }
                        }
                        continue;
                    }
                    firstPass = false;
                    int markertype = marker(marker);
                    if (markertype == VALID_MARKER) {
                        Utilities.skip(is, 2);
                        if (is.read() != 0x08) {
                            throw new BadElementException(errorID + " must have 8 bits per component.");
                        }
                        scaledHeight = getShort(is);
                        setTop(scaledHeight);
                        scaledWidth = getShort(is);
                        setRight(scaledWidth);
                        colorspace = is.read();
                        bpc = 8;
                        break;
                    }
                    else if (markertype == UNSUPPORTED_MARKER) {
                        throw new BadElementException(errorID + ": unsupported JPEG marker: " + marker);
                    }
                    else if (markertype != NOPARAM_MARKER) {
                        Utilities.skip(is, getShort(is) - 2);
                    }
                }
            }
        }
        finally {
            if (is != null) {
                is.close();
            }
        }
        plainWidth = getWidth();
        plainHeight = getHeight();
        if (icc != null) {
            int total = 0;
            for (int k = 0; k < icc.length; ++k) {
                if (icc[k] == null) {
                    icc = null;
                    return;
                }
                total += icc[k].length - 14;
            }
            byte[] ficc = new byte[total];
            total = 0;
            for (int k = 0; k < icc.length; ++k) {
                System.arraycopy(icc[k], 14, ficc, total, icc[k].length - 14);
                total += icc[k].length - 14;
            }
            try {
            	ICC_Profile icc_prof = ICC_Profile.getInstance(ficc);
            	tagICC(icc_prof);
            }
            catch(IllegalArgumentException e) {
            	// ignore ICC profile if it's invalid.
            }
            icc = null;
        }
    }