-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exporting the convert methods #1
Comments
I'll have to look up what JS image data looks like (canvas, image, I don't remember?). If it's a byte stream with predictable layout I can expose a method to handle it no problem. I have some enhancements I want to make to this library, including the ability to set encode and decode hints for JS requests. Would it be find for the function to be "yet another decode" function, where you hand it the JS image data directly and it handles the conversion in the background, or would a two step process be better, where one method generates the byte stream, and another decodes it? |
I guess exposing a function that handles the conversion of the image to what ever decode you use, should be preferable since you are decoupling it from the decoding function. exposing multiple such conversion methods can be even better. you can contact me and I can help you test and improve it. |
this is somehting I wrote to manipulate the Image data so I can pass it to zxing in my js app : reader.onload = async (e) => { |
Got it, I'll get familiar with this and get it implemented. I'm finishing up adding maxicode detection to rxing (zxing and rxing currently only support it in a "pure barcode" image) and then I'll get to this. Probably by the end of the week. |
please check out version 0.1.3 on npm https://www.npmjs.com/package/rxing-wasm and let me know if that meets your requirements. |
as you can see the in the console log - the result only has ptr in it (which I guess is a memory pointer address maybe?) |
I did tried to make it async and await those functions (just to see if anything changes) and it returned the same result |
I pushed another version, but it shouldn't make a huge difference here. The result should be an object, could you try using the |
ohh my bad. It worked! |
It's there! Check out the new I haven't written any documentation for it yet, so let me know if you have issues. |
great! will you make a NPM lib with it?, or , if you don't have the time to handle it, I can make a lib out of it. |
I'm going to close this, but feel free to re-open or open a new one if you have additional issues. The NPM package is currently at 0.1.4, which tracks one version back from the current rxing release. I should have 0.1.5 our later tonight or tomorrow. |
I plan to document all this next week. For that particular field it is looking for a string with a comma separated list of barcode format names. |
apparently, im getting this error of out of memory bounds because of try harder set to true |
If possible, please attach a sample image that generates the error, I'll look into it. |
literally turning on the TryHarder option - throws the error |
Just to verify, that should be: |
yes |
I haven't gotten a test bed up, so I cannot really debug this well. Could you try passing "true" to the TryHarder set_hint and seeing if that work? So far, I haven't gotten my own library to work without throwing an "unreachable" exception. |
Oh wow, I figured it out, I was passing in very wrong height and width data (does it show I haven't worked in node for almost a year?) I get a successful working decode of that image, passing in the hint with |
Here is the code I used, I think your issue is the import { convert_js_image_to_luma, decode_barcode_with_hints, DecodeHintDictionary, DecodeHintTypes } from "rxing-wasm";
const input = document.getElementById('image_file_input');
input.addEventListener('change', handleFiles);
function handleFiles(e) {
const canvas = document.getElementById('cvs');
const ctx = canvas.getContext('2d');
const img = new Image;
img.src = URL.createObjectURL(e.target.files[0]);
img.onload = function () {
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0, img.width, img.height);
}
}
const scan_btn = document.getElementById('scan_btn');
scan_btn.addEventListener('click', onClickScan);
function onClickScan() {
const canvas = document.getElementById('cvs');
const context = canvas.getContext('2d');
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
const luma_data = convert_js_image_to_luma(imageData.data);
const hints = new DecodeHintDictionary();
hints.set_hint(DecodeHintTypes.TryHarder, "true");
const result = decode_barcode_with_hints(luma_data, canvas.width, canvas.height, hints);
alert(result.text());
} |
Alright, I added a demo application in the examples folder. It shows one way to handle basic hints and decoding. Please let me know if your issue is resolved. |
if you need a video of the browser behaver I can provide one. But try on your machine first with this code 👍:
|
It breaks the cli app too (100% cpu in what looks like an infinite loop). I'll figure out what's going on with it. |
Two commits in the main repository fix the infinite loop. The image doesn't decode, but it no longer hangs. rxing-core/rxing@6389d05 This update is pushed to npm as 0.1.6 (https://www.npmjs.com/package/rxing-wasm) |
Watch out for versions 0.1.7 - 0.1.11. A change in some dependencies has caused some havoc I'm still sorting out. I suggest pinning to 0.1.6 for now |
This is resolved with npm version 0.1.12 This also brings a lot more documentation, and the ability to get metadata from the result object. A javascript |
I noticed that you need to convert the image to an array of 8bit luma data, or rgb before passing it to decode_barcode. why not also expose the methods that do that?
Maybe I'm wrong and you can do this in vanilla js, but I couldn't find any example that do that without installing zxing (for js).
If there are other ways to pass image from js to the decoding function without installing zxing, I will be happy to know .
The text was updated successfully, but these errors were encountered: