-
Notifications
You must be signed in to change notification settings - Fork 705
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
Reduce scanning area #791
Comments
This would be great as the user expects that the scan will occur when in the 'target area', and it can get confusing when a scan is triggered outside of that. |
Can this please be looked at? As paulc8712 said, it is very confusing for users when the scan does not occur where they expect. For our case, we are only interested in this for 1D barcodes. Looking through the source, there a method: MultiFormatOneDReader.decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) Could we have an option to call this against the center line of the image? |
Can you solve it yet? .. Help me. I same you |
We are using Zxing in Xamarin Forms for an iOS app. We are facing the same issue - Unable to reduce the scanning Area. |
I'm working on putting together a PR that addresses this. My solution allows a View (some sort of framing square/rectangle on the custom overlay) to be provided to the CameraAnalyzer class. Whatever the screen rotation/screen resolution/location of the scan area only what is inside that view will be looked at for scanning. There's also an option to autofocus that scan area. It achieves focus noticeably faster than the ContinuousPicture/Video modes. |
pull request completed: #889 |
Hello - is there any word on whether this pull request will be brought in? If so, any time frame or release planned? We really need this feature - so much so that we've already hacked our own version of ZXing.Net.Mobile - but the way we did it may have led to a decrease in the ability to scan long/complex bar codes. I'd really like to upgrade to a 3.x version that includes this feature right away. Thanks for listening :) EDIT: I finally saw that this was added to the '3.1 milestone' - any idea whether nitewulf's pull request is a proper fix for this issue? |
MisterAcoustic, I needed the feature for our inventory app and had to hack my own version as well. I've been working on it and other improvements for a couple of months. My PR is an upgraded 3.0 version. I took the latest master branch from Redeth's repo and modified that. If you want to pull my dev branch I'd love to hear some confirmation that it works as well as I believe. https://github.com/nitewulf/ZXing.Net.Mobile/tree/dev-scanarea |
Thanks nitewulf - I'm in the process of trying to build the latest code from here. My plan was to pull your fix into that version and see how well it works :). I have a few hurdles to cross because the solution doesn't compile out of the box for me - I think I'm missing necessary installs of various things - but when I get it going, I will let you know what I find. Thanks! |
Thanks, it's been fun to work on.
Could you share an example of the text and format of one of your overly
complicated barcodes? I'd be curious to print and play with it.
Yes, defining a ScanArea adjusts the sizes/offsets being passed into the
FastJavaByteArrayYUVLuminanceSource constructor. A neutral background
would be interesting. I wonder how that would work too.
I remember seeing that CameraResolutionSelector logic too. I think that
code is just for logging. The actual selection of the resolution (if one
wasn't specified in the MobileBarcodeScanningOptions) happens in the
CameraController.android class.
…On Thu, May 14, 2020 at 11:25 AM MisterAcoustic ***@***.***> wrote:
Hey nitewulf - First, I'd like to say that it seems you've done a lot of
nice work on this. However, for my purposes, there is a problem. We have
some overly complicated bar codes - really long text encoded. For these
kinds of codes, your changes seem to suffer from the same problems our
hacky changes did. When scanning with the full camera area, the library
will recognize these codes quite well currently - even slightly better than
our handheld laser scanners. However, using the restricted area to scan,
the codes are not recognized.
I believe that something else needs to be done to maintain the ability to
scan these longer codes. Our hack involved changing the values sent in to
the constructor of the FastJavaByteArrayYUVLuminanceSource. We effectively
reduced the size of the image the analyzer had to look at. I'm guessing
that this approach actually won't work. I haven't tracked down whether your
changes have a similar effect, but I'm guessing they do. I'm thinking that
perhaps instead of changing the area scanned, we may have to fill the parts
of the buffer we're not interested in with a constant value like white or
gray.
One last thing - in the FragmentActivityCustomScanArea, you have
CameraResolutionSelector code - but it doesn't actually select a
resolution. Here's what I did:
CameraResolutionSelector = availableResolutions => {
int bestFound = 0;
int foundIndex = 0;
int index = 0;
foreach (ZXing.Mobile.CameraResolution res in availableResolutions)
{
int currentSize = res.Height * res.Width;
System.Diagnostics.Trace.WriteLine("index: " + index.ToString() + " Height: " + res.Height.ToString() + " Width: " + res.Width.ToString());
System.Diagnostics.Trace.WriteLine("currentSize: " + currentSize.ToString() + " bestFound: " + bestFound.ToString());
if (currentSize >= bestFound)
{
bestFound = currentSize;
foundIndex = index;
}
index += 1;
}
System.Diagnostics.Trace.WriteLine("Selected Index: " + foundIndex.ToString() + " Height: " + availableResolutions[foundIndex].Height.ToString() + " Width: " + availableResolutions[foundIndex].Width.ToString());
return availableResolutions[foundIndex];
}
};
Please let me know what you think.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#791 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7DE4HASQITVUSNDL2PCI3RRQEPPANCNFSM4GLGKDAA>
.
|
Hi nitewulf, I added the bar code example to the previous post in one of my many edits. I see it displayed at the top of the post for some reason. The printed version that I'm testing with measures about 4 and 1/4 inches in width. I am currently confused, since I am seeing behavior all over the map from the library in general. It may be that your modifications are not part of the problem. On occasion, I see fantastic performance from the library - reads the long codes quickly and easily. Much of the time though, it's unlikely to read the code at all. I do not have an idea yet what might be happening, but I am thinking about focus issues, camera resolution, and I'm also noticing some exceptions being thrown from way down in the BarcodeReader.Decode function (no idea if they're important). Do you (or anyone listening) have an idea why the normal way of selecting a camera resolution doesn't pick the highest available resolution?:
I think that every time I attempt to use a CameraResolutionSelector to actually return a result, things are not working. Still confused, any input is appreciated. |
That's something I wanted to improve as well. Here's my branch for selecting the best resolution available that is closest to matching the aspect ratio of the surface view: https://github.com/nitewulf/ZXing.Net.Mobile/tree/dev-resolution-select I'll also have a branch at some point in the near future with my changes for focus areas. Basically I used my cropped scan area and made it autofocus on that area every (configurable number of milliseconds). I noticed a significant (hard to really quantify that, but it felt much faster) improvement over just letting the camera try to continuously autofocus. |
Hi nitewulf - I've been swamped. I was doing some testing, and it doesn't appear that you implemented the reduced scannning area for iOS devices - is that correct? I've also been trying to get AutoFocus to work more consistently, and I've been running into problems. On my samsung galaxy tab, I see autofocus working one time - then all further attempts will get "AutoFocus Failed" in the log. The camera app on the device still does autofocus normally. Any ideas on that? |
Yeah, I don't have any iOS devices to develop against. AutoFocus can be a jerk. I think the best overall solution for it is to continuously (with a configurable number of milliseconds in between) attempt to focus on the reduced scanning area instead of letting the camera try to automatically focus by itself. That's the last of the changes I've made to the library. I'll organize that into a proper PR in my repo soon. |
doesn't pullrequest #921 solve this issue? |
The latest package 3.0.0-beta5 doesn't have this update. scanPage = new ZXingScannerPage(new MobileBarcodeScanningOptions public MobileBarcodeScanningOptions()
} |
i took the branch of #921: https://github.com/michcons/ZXing.Net.Mobile/tree/narrow-scanning-area
... |
|
any update on this? |
More than a year has passed - please let us know when the PR will be merged. |
any update on this? |
When the PR will be merged? |
I need to reduce the scanning area so that the barcode when placed in the center of the red scan line then only it should be scanned.Please provide the way out for this
The text was updated successfully, but these errors were encountered: