Skip to content

Commit

Permalink
Fixes (#23) (#24)
Browse files Browse the repository at this point in the history
* I am using the module from C++ but do not know the name of the loader that references the module. 

* use qt6.6
  • Loading branch information
EddyTheCo authored Sep 18, 2023
1 parent 33d7901 commit 65b04fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
os: ${{ matrix.os }}
sharedLib: true
qtVersion: '6.5.0'
qtVersion: '6.6.0'
qtModules: 'qtshadertools qtmultimedia'
release:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
20 changes: 14 additions & 6 deletions QtQrDec/Qrimagedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ EM_JS(void, call_start, (), {
video.srcObject = stream;
window.localStream = stream;
getimage=setInterval(function() {
//You need to define qtQR module when loading the module of the qt application.
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
let imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
var data=imageData.data.buffer;
var uint8Arr = new Uint8Array(data);
const numBytes = uint8Arr.length * uint8Arr.BYTES_PER_ELEMENT;
const dataPtr = qtClient.module()._malloc(numBytes);
const dataOnHeap = new Uint8Array(qtClient.module().HEAPU8.buffer, dataPtr, numBytes);
const dataPtr = qtQR.module()._malloc(numBytes);
const dataOnHeap = new Uint8Array(qtQR.module().HEAPU8.buffer, dataPtr, numBytes);
dataOnHeap.set(uint8Arr);
qtClient.module().QRImageDecoder.getdecoder().reload(dataOnHeap.byteOffset,video.width,video.height);
qtClient.module()._free(dataPtr);

qtQR.module().QRImageDecoder.getdecoder().reload(dataOnHeap.byteOffset,video.width,video.height);
qtQR.module()._free(dataPtr);
}, 100);

}).catch(alert);
Expand All @@ -70,8 +72,14 @@ EM_JS(void, call_start, (), {
});

EM_JS(void, call_stop, (), {
clearInterval(getimage);
localStream.getVideoTracks()[0].stop();
try {
getimage;
clearInterval(getimage);
localStream.getVideoTracks()[0].stop();
}catch(e) {
e; // => ReferenceError
console.log('getimage is not defined');
}
});

void QRImageDecoder::start()const
Expand Down

0 comments on commit 65b04fe

Please sign in to comment.