在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:cordova-plugin-camera-preview/cordova-plugin-camera-preview开源软件地址:https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview开源编程语言:Java 51.2%开源软件介绍:Cordova Plugin Camera PreviewCordova plugin that allows camera interaction from Javascript and HTML Releases are being kept up to date when appropriate. However, this plugin is under constant development. As such it is recommended to use master to always have the latest fixes & features. PR's are greatly appreciated. Features
InstallationUse any one of the installation methods listed below depending on which framework you use. To install the master version with latest fixes and features
or if you want to use the last released version on npm
iOS Quirks
<config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" overwrite="true">
<string>Allow the app to use your camera</string>
</config-file>
<!-- or for Phonegap -->
<gap:config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" overwrite="true">
<string>Allow the app to use your camera</string>
</gap:config-file> Android Quirks
MethodsstartCamera(options, [successCallback, errorCallback])Starts the camera preview instance.
Options: All options stated are optional and will default to values here
let options = {
x: 0,
y: 0,
width: window.screen.width,
height: window.screen.height,
camera: CameraPreview.CAMERA_DIRECTION.BACK,
toBack: false,
tapPhoto: true,
tapFocus: false,
previewDrag: false,
storeToFile: false,
disableExifHeaderStripping: false
};
CameraPreview.startCamera(options); When setting html, body, .ion-app, .ion-content {
background-color: transparent;
} When both If you capture large images in Android you may notice that performace is poor, in those cases you can set When capturing large images you may want them to be stored into a file instead of having them base64 encoded, as enconding at least on Android is very expensive. With the feature stopCamera([successCallback, errorCallback])Stops the camera preview instance. CameraPreview.stopCamera(); switchCamera([successCallback, errorCallback])Switch between the rear camera and front camera, if available. CameraPreview.switchCamera(); show([successCallback, errorCallback])Show the camera preview box. CameraPreview.show(); hide([successCallback, errorCallback])Hide the camera preview box. CameraPreview.hide(); takePicture(options, successCallback, [errorCallback])Take the picture. If width and height are not specified or are 0 it will use the defaults. If width and height are specified, it will choose a supported photo size that is closest to width and height specified and has closest aspect ratio to the preview. The argument CameraPreview.takePicture({width:640, height:640, quality: 85}, function(base64PictureData|filePath) {
/*
if the storeToFile option is false (the default), then base64PictureData is returned.
base64PictureData is base64 encoded jpeg image. Use this data to store to a file or upload.
Its up to the you to figure out the best way to save it to disk or whatever for your application.
*/
/*
if the storeToFile option is set to true, then a filePath is returned. Note that the file
is stored in temporary storage, so you should move it to a permanent location if you
don't want the OS to remove it arbitrarily.
*/
// One simple example is if you are going to use it inside an HTML img src attribute then you would do the following:
imageSrcData = 'data:image/jpeg;base64,' + base64PictureData;
$('img#my-img').attr('src', imageSrcData);
});
// OR if you want to use the default options.
CameraPreview.takePicture(function(base64PictureData){
/* code here */
}); takeSnapshot(options, successCallback, [errorCallback])Take snapshot of the camera preview. The resulting image will be the same size as specified in CameraPreview.takeSnapshot({quality: 85}, function(base64PictureData){
/*
base64PictureData is base64 encoded jpeg image. Use this data to store to a file or upload.
*/
// One simple example is if you are going to use it inside an HTML img src attribute then you would do the following:
imageSrcData = 'data:image/jpeg;base64,' +base64PictureData;
$('img#my-img').attr('src', imageSrcData);
}); getSupportedFocusModes(cb, [errorCallback])Get focus modes supported by the camera device currently started. Returns an array containing supported focus modes. See CameraPreview.getSupportedFocusModes(function(focusModes){
focusModes.forEach(function(focusMode) {
console.log(focusMode + ', ');
});
}); setFocusMode(focusMode, [successCallback, errorCallback])Set the focus mode for the camera device currently started.
CameraPreview.setFocusMode(CameraPreview.FOCUS_MODE.CONTINUOUS_PICTURE); getFocusMode(cb, [errorCallback])Get the focus mode for the camera device currently started. Returns a string representing the current focus mode.See CameraPreview.getFocusMode(function(currentFocusMode){
console.log(currentFocusMode);
}); getSupportedFlashModes(cb, [errorCallback])Get the flash modes supported by the camera device currently started. Returns an array containing supported flash modes. See CameraPreview.getSupportedFlashModes(function(flashModes){
flashModes.forEach(function(flashMode) {
console.log(flashMode + ', ');
});
}); setFlashMode(flashMode, [successCallback, errorCallback])Set the flash mode. See CameraPreview.setFlashMode(CameraPreview.FLASH_MODE.ON); getFlashMode(cb, [errorCallback])Get the flash mode for the camera device currently started. Returns a string representing the current flash mode.See CameraPreview.getFlashMode(function(currentFlashMode){
console.log(currentFlashMode);
}); getHorizontalFOV(cb, [errorCallback])Get the Horizontal FOV for the camera device currently started. Returns a string of a float that is the FOV of the camera in Degrees. CameraPreview.getHorizontalFOV(function(getHorizontalFOV){
console.log(getHorizontalFOV);
}); getSupportedColorEffects(cb, [errorCallback])Currently this feature is for Android only. A PR for iOS support would be happily accepted Get color modes supported by the camera device currently started. Returns an array containing supported color effects (strings). See CameraPreview.getSupportedColorEffects(function(colorEffects){
colorEffects.forEach(function(color) {
console.log(color + ', ');
});
}); setColorEffect(colorEffect, [successCallback, errorCallback])Set the color effect. See CameraPreview.setColorEffect(CameraPreview.COLOR_EFFECT.NEGATIVE); setZoom(zoomMultiplier, [successCallback, errorCallback])Set the zoom level for the camera device currently started. zoomMultipler option accepts an integer. Zoom level is initially at 1 CameraPreview.setZoom(2); getZoom(cb, [errorCallback])Get the current zoom level for the camera device currently started. Returns an integer representing the current zoom level. CameraPreview.getZoom(function(currentZoom){
console.log(currentZoom);
}); getMaxZoom(cb, [errorCallback])Get the maximum zoom level for the camera device currently started. Returns an integer representing the manimum zoom level. CameraPreview.getMaxZoom(function(maxZoom){
console.log(maxZoom);
}); getSupportedWhiteBalanceModes(cb, [errorCallback])Returns an array with supported white balance modes for the camera device currently started. See CameraPreview.getSupportedWhiteBalanceModes(function(whiteBalanceModes){
console.log(whiteBalanceModes);
}); getWhiteBalanceMode(cb, [errorCallback])Get the curent white balance mode of the camera device currently started. See CameraPreview.getWhiteBalanceMode(function(whiteBalanceMode){
console.log(whiteBalanceMode);
}); setWhiteBalanceMode(whiteBalanceMode, [successCallback, errorCallback])Set the white balance mode for the camera device currently started. See CameraPreview.setWhiteBalanceMode(CameraPreview.WHITE_BALANCE_MODE.CLOUDY_DAYLIGHT); getExposureModes(cb, [errorCallback])Returns an array with supported exposure modes for the camera device currently started. See CameraPreview.getExposureModes(function(exposureModes){
console.log(exposureModes);
}); getExposureMode(cb, [errorCallback])Get the curent exposure mode of the camera device currently started. See CameraPreview.getExposureMode(function(exposureMode){
console.log(exposureMode);
}); setExposureMode(exposureMode, [successCallback, errorCallback])Set the exposure mode for the camera device currently started. See CameraPreview.setExposureMode(CameraPreview.EXPOSURE_MODE.CONTINUOUS); getExposureCompensationRange(cb, [errorCallback])Get the minimum and maximum exposure compensation for the camera device currently started. Returns an object containing min and max integers. CameraPreview.getExposureCompensationRange(function(expoxureRange){
console.log("min: " + exposureRange.min);
console.log("max: " + exposureRange.max);
}); getExposureCompensation(cb, [errorCallback])
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论