Opens a camera, and attempts to establish preview mode at the specified width and height.
348108
private void openCamera(int desiredWidth, int desiredHeight, int requestedCameraType) {
        // There's a confusing conflation of Camera index in Camera.open(i)
        // with Camera.getCameraInfo().facing values. However the API specifies that Camera.open(0)
        // will always be a rear-facing camera, and CAMERA_FACING_BACK = 0.
        if (mCamera != null) {
            throw new RuntimeException("camera already initialized");
        }

        Camera.CameraInfo info = new Camera.CameraInfo();

        // Try to find a front-facing camera (e.g. for videoconferencing).
        int numCameras = Camera.getNumberOfCameras();
        int targetCameraType = requestedCameraType;
        boolean triedAllCameras = false;
        cameraLoop:
        while (!triedAllCameras) {
            for (int i = 0; i < numCameras; i++) {
                Camera.getCameraInfo(i, info);
                if (info.facing == targetCameraType) {
                    mCamera = Camera.open(i);
                    mCurrentCamera = targetCameraType;
                    break cameraLoop;
                }
            }
            if (mCamera == null) {
                if (targetCameraType == requestedCameraType)
                    targetCameraType = (requestedCameraType == Camera.CameraInfo.CAMERA_FACING_BACK ? Camera.CameraInfo.CAMERA_FACING_FRONT : Camera.CameraInfo.CAMERA_FACING_BACK);
                else
                    triedAllCameras = true;
            }

        }

        if (mCamera == null) {
            mCurrentCamera = -1;
            throw new RuntimeException("Unable to open camera");
        }

        Camera.Parameters parms = mCamera.getParameters();

        postCameraOpenedEvent(parms);

        List<String> focusModes = parms.getSupportedFocusModes();
        if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
            parms.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
        } else if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
            parms.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
        } else {
            if (VERBOSE) Log.i(TAG, "Camera does not support autofocus");
        }

        List<String> flashModes = parms.getSupportedFlashModes();
        String flashMode = (mDesiredFlash != null) ? mDesiredFlash : mCurrentFlash;
        if (isValidFlashMode(flashModes, flashMode)) {
            parms.setFlashMode(flashMode);
        }

        parms.setRecordingHint(true);

        List<int[]> fpsRanges = parms.getSupportedPreviewFpsRange();
        int[] maxFpsRange = null;
        // Get the maximum supported fps not to exceed 30
        for (int x = fpsRanges.size() - 1; x >= 0; x--) {
            maxFpsRange = fpsRanges.get(x);
            if (maxFpsRange[1] / 1000.0 <= 30) break;
        }
        if (maxFpsRange != null) {
            parms.setPreviewFpsRange(maxFpsRange[0], maxFpsRange[1]);
        }

        choosePreviewSize(parms, desiredWidth, desiredHeight);
        // leave the frame rate set to default
        mCamera.setParameters(parms);

        int[] fpsRange = new int[2];
        Camera.Size mCameraPreviewSize = parms.getPreviewSize();
        parms.getPreviewFpsRange(fpsRange);
        String previewFacts = mCameraPreviewSize.width + "x" + mCameraPreviewSize.height;
        if (fpsRange[0] == fpsRange[1]) {
            previewFacts += " @" + (fpsRange[0] / 1000.0) + "fps";
        } else {
            previewFacts += " @" + (fpsRange[0] / 1000.0) + " - " + (fpsRange[1] / 1000.0) + "fps";
        }
        if (VERBOSE) Log.i(TAG, "Camera preview set: " + previewFacts);
    }
664796
public void handleCameraPreviewTouchEvent(MotionEvent ev) {
        if (mFullScreen != null) mFullScreen.handleTouchEvent(ev);
        if (mDisplayRenderer != null) mDisplayRenderer.handleTouchEvent(ev);
    }
341835
function () {
            var self = this;

            // add all defined cameras
            this.settings.cameras.forEach(function(camera) {
                self.cameras.set(camera.name, camera);
            });

            // empty or no default camera
            if (this.cameras.has("default") === false) {
                if (typeof default_camera === "undefined") {
                    var width = me.video.renderer.getWidth();
                    var height = me.video.renderer.getHeight();
                    // new default camera instance
                    default_camera = new me.Camera2d(0, 0, width, height);
                }
                this.cameras.set("default", default_camera);
            }

            // reset the game manager
            me.game.reset();

            // call the onReset Function
            this.onResetEvent.apply(this, arguments);
        }
1248092
def move_camera(action, action_space, minimap):
  """"""
  minimap.assign_to(spatial(action, action_space).camera_move.center_minimap)
957562
def set_display_mode(self, zoom,layout='continuous'):
        """"""
        
        if(zoom=='fullpage' or zoom=='fullwidth' or zoom=='real' or zoom=='default' or not isinstance(zoom,basestring)):
            self.zoom_mode=zoom
        else:
            self.error('Incorrect zoom display mode: '+zoom)
        if(layout=='single' or layout=='continuous' or layout=='two' or layout=='default'):
            self.layout_mode=layout
        else:
            self.error('Incorrect layout display mode: '+layout)
1127425
def resize_preview(self, dw, dh):
        ""

        # identify preview
        if self._objects_moving:
            id_ = self._objects_moving[0]
            tags = self.canvas.gettags(id_)
            for tag in tags:
                if tag.startswith('preview_'):
                    _, ident = tag.split('preview_')
                    preview = self.previews[ident]
                    preview.resize_by(dw, dh)
                    self.move_previews()
                    break
        self._update_cregion()
240003
private void startPreview() {
		// Sanity check. Parts of this code assume it's on this thread. If it has been put into a handle
		// that's fine just be careful nothing assumes it's on the main looper
		if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
			throw new RuntimeException("Not on main looper! Modify code to remove assumptions");
		}

		if( verbose ) {
			Log.i(TAG,"startPreview()");
		}

		try {
			open.mLock.lock();

			if (null == open.mCameraDevice || null == open.mCameraSize) {
				Log.i(TAG,"  aborting startPreview. Camera not open yet.");
				return;
			}

			closePreviewSession();
			open.surfaces = new ArrayList<>();
			open.mPreviewRequestBuilder = open.mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);

			if( mTextureView != null && mTextureView.isAvailable() ) {
				SurfaceTexture texture = mTextureView.getSurfaceTexture();
				assert texture != null;
				texture.setDefaultBufferSize(open.mCameraSize.getWidth(), open.mCameraSize.getHeight());

				// Display the camera preview into this texture
				Surface previewSurface = new Surface(texture);
				open.surfaces.add(previewSurface);
				open.mPreviewRequestBuilder.addTarget(previewSurface);
			}

			// This is where the image for processing is extracted from
			Surface readerSurface = open.mPreviewReader.getSurface();
			open.surfaces.add(readerSurface);
			open.mPreviewRequestBuilder.addTarget(readerSurface);

			createCaptureSession();
		} catch (CameraAccessException e) {
			e.printStackTrace();
		} finally {
			open.mLock.unlock();
		}
	}
1168745
private void setUpAndConfigureCamera() {
		// Open and configure the camera
		mCamera = openConfigureCamera(mCameraInfo);
		setCameraDisplayOrientation(mCameraInfo,mCamera);

		// Create an instance of Camera
		mPreview.setCamera(mCamera);

		if( processing != null ) {
			processing.init(mDraw,mCamera,mCameraInfo,previewRotation);
		}
	}
1112296
function startCameraDefaultResolution () {
  let facingMode = facingModeSelectElement.value;
  cameraPhoto.startCamera(FACING_MODES[facingMode])
    .then(() => {
      let log =
          `Camera started with default resolution and ` +
          `prefered facingMode : ${facingMode}`;
      console.log(log);
    })
    .catch((error) => {
      console.error('Camera not started!', error);
    });
}
449479
function startFPSMonitor() {
        checkInit();
        var data = new Data();
        var w = new MonitorWidget("FPS", "", 2 /* HideMax */ | 1 /* HideMin */ | 4 /* HideMean */ | 32 /* RoundValues */);
        container.appendChild(w.element);
        var samples = [];
        var last = 0;
        function update(now) {
            var elapsed = (now - (last === 0 ? now : last)) / 1000;
            var fps = 1 / elapsed;
            if (fps !== Infinity) {
                if (samples.length === 64) {
                    samples.shift();
                }
                samples.push(fps);
                var sum = 0;
                for (var i = 0; i < samples.length; i++) {
                    sum += samples[i];
                }
                var mean = sum / samples.length;
                data.addSample(mean);
                w.addResult(data.calc());
            }
            last = now;
            requestAnimationFrame(update);
        }
        requestAnimationFrame(update);
    }
1270069
def create(self, width, height):
        
        return Image.new(self.mode, (width, height))
433794
public static Webcam openDefault( int desiredWidth , int desiredHeight) {
		Webcam webcam = Webcam.getDefault();

		// Webcam doesn't list all available resolutions. Just pass in a custom
		// resolution and hope it works
		adjustResolution(webcam,desiredWidth,desiredHeight);

		webcam.open();
		return webcam;
	}
111869
async function setupCamera(cameraLabel) {
  if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
    throw new Error(
        'Browser API navigator.mediaDevices.getUserMedia not available');
  }

  const videoElement = document.getElementById('video');

  stopExistingVideoCapture();

  const videoConstraints = await getConstraints(cameraLabel);

  const stream = await navigator.mediaDevices.getUserMedia(
      {'audio': false, 'video': videoConstraints});
  videoElement.srcObject = stream;

  return new Promise((resolve) => {
    videoElement.onloadedmetadata = () => {
      videoElement.width = videoElement.videoWidth;
      videoElement.height = videoElement.videoHeight;
      resolve(videoElement);
    };
  });
}
131593
function(width, height){
            this.map.setSize(width, height);
            this.player.fov.setSize(width, height);
            this.entityManager.setSize(width, height);
            this.lighting.setSize(width, height);
        }
568962
function start(mode, target, system, containerDef, container, out, cb) {
    if (mode !== 'preview') {
      main.setup(config, mode, target, system, containerDef, container, out, cb);
    } else {
      cb();
    }
  }
861025
void initFromCameraParameters(Camera camera) {
    Camera.Parameters parameters = camera.getParameters();
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point theScreenResolution = new Point();
    getDisplaySize(display, theScreenResolution);
    screenResolution = theScreenResolution;
    Log.i(TAG, "Screen resolution: " + screenResolution);
    cameraResolution = findBestPreviewSizeValue(parameters, screenResolution);
    Log.i(TAG, "Camera resolution: " + cameraResolution);
  }
1219812
def camera_action(self, mouse_pos):
    """"""
    action = sc_pb.Action()
    action_spatial = mouse_pos.action_spatial(action)
    mouse_pos.obs_pos.assign_to(action_spatial.camera_move.center_minimap)
    return action