This file contains hidden or 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
| FROM centos:7 | |
| MAINTAINER "orion" <[email protected]> | |
| # Steps needed to use systemd enabled docker containers. | |
| # Reference: https://hub.docker.com/_/centos/ | |
| ENV container docker | |
| RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ | |
| systemd-tmpfiles-setup.service ] || rm -f $i; done); \ | |
| rm -f /lib/systemd/system/multi-user.target.wants/*;\ | |
| rm -f /etc/systemd/system/*.wants/*;\ |
This file contains hidden or 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
| #!/bin/sh | |
| # Copyright 2020 Paul Morgan | |
| # License: GPLv2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) | |
| set -x | |
| set -e | |
| # | |
| # Docker build calls this script to harden the image during build. | |
| # | |
| # NOTE: To build on CircleCI, you must take care to keep the `find` | |
| # command out of the /proc filesystem to avoid errors like: |
This file contains hidden or 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
| <div className="qrCode"> | |
| <video | |
| style={{ | |
| maxWidth: 175, | |
| margin: "auto", | |
| }} | |
| onPlaying={e => { | |
| setCameraPlaying(true); | |
| }} id="video" playsInline autoPlay></video> |
This file contains hidden or 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
| public class BoofCVQRCodeReader { | |
| public static String read(String filePath) { | |
| // read the image to memory | |
| BufferedImage input = UtilImageIO.loadImage(filePath); | |
| // gray-out the image, easy to process | |
| GrayU8 gray = ConvertBufferedImage.convertFrom(input, (GrayU8) null); | |
| QrCodeDetector<GrayU8> detector = FactoryFiducial.qrcode(null, GrayU8.class); |
This file contains hidden or 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
| @PostMapping(path = "/upload", produces = MediaType.APPLICATION_JSON_VALUE) | |
| public ResponseEntity<QRTextResponseEntity> singleFileUpload(@RequestParam("qr_base64") MultipartFile file, | |
| RedirectAttributes redirectAttributes) { | |
| // there has to be a valid file | |
| if (file.isEmpty()) { | |
| redirectAttributes.addFlashAttribute("message", "Please select a file to upload"); | |
| throw new ResponseStatusException( | |
| HttpStatus.BAD_REQUEST, "file not valid" | |
| ); |
This file contains hidden or 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
| const uploadToServer = async (base64Str) => { | |
| // prepare the base64 image | |
| // const base64 = 'data:image/png;base64,' + base64Str; | |
| // convert base64 to post body blob | |
| const blob = await fetch(base64Str).then(res => res.blob()); | |
| const formData = new FormData(); | |
| formData.append('qr_base64', blob, 'qr_code.png'); |
This file contains hidden or 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
| const checkQrCode = () => { | |
| window.imageCapture.grabFrame() | |
| .then(imageBitmap => { | |
| const imageBase64 = imgToBase64(imageBitmap); | |
| console.log("get image bitmap and uploading to server"); | |
| uploadToServer(imageBase64); | |
| }) | |
| .catch(error => { | |
| console.log("error during image capture: ", error) | |
| }); |
This file contains hidden or 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
| const gotStream = (stream) => { | |
| window.stream = stream; // make stream available to console | |
| window.imageCapture = new ImageCapture(stream.getTracks()[0]); | |
| console.log(window.imageCapture) | |
| const videoElement = document.querySelector('video'); | |
| videoElement.srcObject = stream; | |
| setInterval(checkQrCode, 5000); |
This file contains hidden or 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
| const start = async (camId) => { | |
| // stop the currently running video | |
| stopVideo(); | |
| // use the rear camera, if any, else any camera | |
| const constraints = { | |
| video: { deviceId: camId ? { exact: camId } : undefined } | |
| }; | |
| // get medias and further process |
This file contains hidden or 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
| const initialiseCamera = async () => { | |
| try { | |
| let cam1 = null; // stores running rear camera ID | |
| let cam2 = null; // stores running default camera ID | |
| const devices = await navigator.mediaDevices.enumerateDevices(); | |
| // labels of rear camera, detected by popular mobile devices | |
| const rearCameraLabels = ['rear', 'back', 'environment']; |
NewerOlder