add the horizonal red line and yellow dots during codeReader.decodeFromVideoDevice
See original GitHub issueHi,
Is there away to add features to help user to better orient the phone in front of the barcode?
I am thinking about the horizontal red line and the yellow dots, like in the android app. or CornerDetector
here a running example to use for.
Thanks
<script
type="text/javascript" src="https://unpkg.com/@zxing/library@latest"></script>
<!--
<script type="text/javascript" src="xzing.js"></script>
-->
<script type="text/javascript">
window.addEventListener('load', function () {
let selectedDeviceId;
// https://github.com/zxing-js/library/issues/374
// enable TRY_HARDER using hints
const hints = new Map(); // hints is a JS Map Object
hints.set(ZXing.DecodeHintType.TRY_HARDER, true);
// the code reader will enable try harder once it reads this
// you gotta pass hints to the code reader to enable TRY_HARDER
const codeReader = new ZXing.BrowserMultiFormatReader(
// I broke this in new lines so I can comment and give you tips
null, // first param is a delay between scans
hints // this allows you to customize code reader
);
console.log('ZXing code reader initialized')
codeReader.listVideoInputDevices()
.then((videoInputDevices) => {
const sourceSelect = document.getElementById('sourceSelect')
selectedDeviceId = videoInputDevices[0].deviceId
if (videoInputDevices.length >= 1) {
videoInputDevices.forEach((element) => {
const sourceOption = document.createElement('option')
sourceOption.text = element.label
sourceOption.value = element.deviceId
sourceSelect.appendChild(sourceOption)
})
sourceSelect.onchange = () => {
selectedDeviceId = sourceSelect.value;
};
const sourceSelectPanel = document.getElementById('sourceSelectPanel')
sourceSelectPanel.style.display = 'block'
}
document.getElementById('startButton').addEventListener('click', () => {
var audio = new Audio('beep.mp3');
codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
if (result) {
audio.play();
console.log(result)
document.getElementById('result').textContent = result.text
//Shiny.onInputChange("send_serialNumber_id", result.text);
Shiny.setInputValue("send_serialNumber_id", result.text, {priority: "event"});
}
if (err && !(err instanceof ZXing.NotFoundException)) {
console.error(err)
document.getElementById('result').textContent = err
}
})
console.log(`Started continous decode from camera with id ${selectedDeviceId}`)
});
document.getElementById('resetButton').addEventListener('click', () => {
codeReader.reset()
document.getElementById('result').textContent = '';
console.log('Reset.')
});
})
.catch((err) => {
console.error(err)
})
})
</script>
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Ubuntu Manpage: ffplay - FFplay media player
FFplay is a very simple and portable media player using the FFmpeg libraries and the SDL library. It is mostly used as a...
Read more >Control of Double Inverted Pendulum First Approach
An Inverted double pendulum is a combination of two individual pendulums which represents an example of a nonlinear and unstable dynamic system and...
Read more >ffmpeg Documentation
The decoder produces uncompressed frames (raw video/PCM audio/. ... For example to enable repeated log output, add the level prefix, and set loglevel...
Read more >Table of Contents - AUTEL
Put blocks in front of the drive wheels and never leave the vehicle ... Keep the scan tool dry, clean, free from oil/water...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Transfering this issue to the browser repository. Once the main features are estabilished I can try to create such feature. Thanks.
@kmezhoud, basically all you need to do is use the code provided and adapt for your needs. Bellows will give you a red horizontal line (not yet very stylish, but with some more css it’s easily improved). For dots basically just add further DIV elements with
position: absolute
and style them accordingly.