This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Semaphore(max) { | |
var counter = 0; | |
var waiting = []; | |
var take = function() { | |
if (waiting.length > 0 && counter < max){ | |
counter++; | |
let promise = waiting.shift(); | |
promise.resolve(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <p>Returns the supplied {@link com.google.android.gms.vision.CameraSource}'s {@link android.hardware.Camera} instance that is being used.</p> | |
* <p> | |
* If you want to set any of the camera parameters, here's an example that sets the focus mode to continuous auto focus and enables the flashlight: | |
* <blockquote> | |
* <code> | |
* Camera.Parameters params = camera.getParameters(); | |
* params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); | |
* params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); | |
* camera.setParameters(params); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* IF YOU WANT TO JUST ACCESS THE CAMERA INSTANCE SO THAT YOU CAN SET ANY OF THE PARAMETERS, VISIT THE FOLLOWING LINK: | |
* https://gist.github.com/Gericop/364dd12b105fdc28a0b6 | |
*/ | |
/** | |
* Custom annotation to allow only valid focus modes. | |
*/ | |
@StringDef({ | |
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE, |