How would I modify ZXing to optimize for a specific barcode type? - zxing

ZXing currently performs poorly in my tests of Code 39 and Code 128, which are the only 1D barcode types we're interested in for our apps.
What strategy could we take for optimizing the ZXing code for these types?
What parts of the ZXing source code should we focus on if we wanted to, e.g., start by telling it to stop trying to look for and interpret the other 1D barcode formats (I'm assuming this would help it's success rate in identifying 39/129)?

The biggest thing you can do is to not scan for every other format. Just scan with Code39Reader and Code128Reader, and not MultiFormatReader (or, use it, but send hints to restrict the formats that are considered). In an Android app, this will mean that it can examine more frames for just your formats.
If you have a very fast mobile device -- or are working on a desktop computer -- enable TRY_HARDER mode.
If you want to hack the code -- the biggest thing to focus on for detection of 1D barcodes is the Binarizer. If you have a few months and background in image processing you can probably write something better.
The latter is part of the for-pay release of the Barcode Scanner app, called Barcode Scanner+. If you are willing to part with $3 you can see how much difference better image processing may make to your use case.

Related

How to make a simple OS with very specific features

I want to make a sort of operating system, but with some very specific features.
The only thing i need it to do is show a video, place some text over it, accept user input and some basic file manipulation.
Something that looks like an OS'es loading screen would do.
i am, however, a complete noob to this part of programming and i have no idea where to look. Don't worry i do not need a complete explaination for every single step, but it would be nice to know in what direction i should go search.
Anyone got an idea where to start searching?
Thanks in advance ;)
Although you narrowed down your specification it's still complicated enough. Playing video involves file I/O, a file system, storage device access, buffering mechanism, memory allocation, memory management primitives, GPU access. Accepting user input requires keyboard and mouse handling which requires a working USB layer. Not to mention that you needed to make the video decoding library work with your own system, unless you want to implement that from scratch too. That might require you to have an ABI or a POSIX emulation layer. You might need to port at least one or two graphics libraries like SDL.
That's why "OS loading screen"s don't play videos :)
You might get away with using BIOS only for accessing all devices. But BIOS and VBE are usually slow and may not work well with your video playing scenario. BIOS is slowly getting pushed out of PC ecosystem in favor of UEFI too.
If you don't need a custom OS, you can trim a Linux kernel down to the parts you need to have. Even that's not a trivial thing to do though.

Easy and straight-forward FFT of MP3 file

I have a MP3 file and need to constantly detect and show Hz value of this playing MP3 file. A bit of googling shows that I have 2 opportunities: use FFT or use Apple Accelerate framework. Unfortunately I haven't found any easy to use sample of neither. All samples, like AurioTouch etc, need tons of code to get simple number for sample buffer. Is there any easy example for pitch detection for iOS?
For example I've found https://github.com/clindsey/pkmFFT, but it's missing some files that its' author has removed. Anything working like that?
I'm afraid not. Working with sound is generally hard, and Core Audio makes no exception. Now to the matter at hand.
FFT is an algorithm for transforming input from time domain to frequency domain. Is not necessarily linked with sound processing, you can use it for other things other than sound as well.
Accelerate is an Apple provided framework, which among many other things offer an FFT implementation. So, you actually don't have two options there, just one and its implementation.
Now, depending on what you want to do(e.g. if you favour speed over accuracy, robustness over simplicity etc) and the type of waveform you have(simple, complex, human speech, music), FFT may be not enough on its own or not even the right choice for your task. There are other options, auto-correlation, zero-crossing, cepstral analysis, maximum likelihood to mention some. But none are trivial, except for zero-crossing, which also gives you the poorest results and will fail to work with complex waveforms.
Here is a good place to start:
http://blog.bjornroche.com/2012/07/frequency-detection-using-fft-aka-pitch.html
There are also other question on SO.
However, as indicated by other answers, this is not something that can just be "magically" done. Even if you license code from someone (eg, iZotope, and z-plane both make excellent code for doing what you want to do), you still need to understand what's going on to get data in and out of their libraries.
If you need fast pitch detection go with http://www.schmittmachine.com/dywapitchtrack.html
You'll find a IOS sample code inside.
If you need FFT you should use Apple Accelerate framework.
Hope this help

Suitability of CodeNameOne for image processing application

We need to build an image processing application for smartphones (mainly for iPhone). The operations consist of:
image filtering
composite geometrical transformation
region growing
Also, the user is required to specify (touch) some parts of the image. Those parts would serve as inputs for the app. Example: eyes and lip in a face.
We have built a desktop version of this app. The processing part is quite heavy and we extensively used BufferedImage class.
Should we use CodeNameOne for building this app? If not then what alternatives do you suggest?
Please consider the following factors:
Performance
Ease of writing the code (for image processing)
I gave an answer for this in our discussion forum but I think its a worthwhile question for a duplicate post:
Generally for most platforms you should be fine in terms of performance except for iOS & arguably Windows Phone.
Codename One is optimized for common use cases, since iOS doesn't allow for JIT's it can never be as fast as Java on the desktop since its really hard to do some optimizations e.g. array bound check elimination. So every access to an array will contain a branch check which can be pretty expensive for image processing.
Add to that the fact that we don't have any image processing API's other than basic ARGB and you can get the "picture", it just won't be efficient or easy.
The problem is that this is a very specific field, I highly doubt you will find any solution that will help you with this sort of code. So your only approach AFAIK is to build native code to do the actual image processing heavy lifting.
You can do this with Codename One by using the NativeInterface API which allows you to invoke critical code in native code and use cn1lib's to wrap them as libraries. You would then be able to get native performance for that portion of the code but this would only make sense for critical sections in the code. If you write a lot of native code the benefits of Codename One start to dissipate and you might as well go to native.

Does a free API for a Augmented reality service exist?

Currently I am trying to create an app for iPhone which is capable of recognizing the objects on an image such as car, bus, building, bridge, human, etc, and label as object name with the help of Internet.
Is there any free service which provide solution to my problem, as object recognition its self a complex algorithm requiring digital image processing, neural networks and all.
Can this can be done via API?
If you want to recognise planar images the current generation of mobile AR SDKs from Metaio, Qualcomm and Layar will allow you to upload images to match against, and perform the matching.
If you want to match freely against a set of 3D objects, e.g. a Toyota Prius or the Empire state, the same techniques might be applied to match against sets of images taken at different rotations, but you might have to choose to match just one object due to limitations on how large an image database you can have with the service, or contact those companies for a custom solution, and it may not work very reliably given the state of the art is to reliably match against planar images.
If you want to recognize general classes (human, car, building), this is a very difficult problem, and I don't know of any solutions anywhere fast enough to operate online (which I assume is a requirement given you want an AR solution - is that a fair assumption?). It's been a few years since I studied CV, but at that time the most promising solution for visual classification was "bag of visual words" approaches - you might try reading up on those.
Take a look at Cortexica. Very useful for this sort of thing.
http://www.cortexica.com/
I haven't done work with mobile AR in a while, but the last time I was working on this stuff I was using Layar and starting to investigate Junaio. Those are oriented toward 3D graphics, not simply text labels, so for your use case you may be better served with OpenCV.
Note that Layar (and I believe Junaio too) works like a web app, where you put the content on your own server and give Layar the URL to link to.

Any way to create an arbitrary tone with Basic4android?

Is there any way with Basic4Android to make it emit a sound of arbitrary frequency (meaning, I don't want to have pre-recorded sound files) and duration?
In some "traditional" Basic languages this would be done via e.g. a BEEP command followed by the desired frequency and duration.
Basic4Android doesn't seem to support any equivalent command.
I am looking for this feature in order to program a Morse Code generating app and for this purpose I need to stay flexible regarding the audio frequency tone (must be user selectable) between e.g. 500Hz and lets say 1000 Hz as well as variable duration in milliseconds (in order to be able to generate variable user selectable speeds of the morse code dashes and dots and silent breaks inbetween)...
It's simply not practical or near to impossible to do this with prerecorded WAV's or you would end up in a huge WAV collection for all frequency/speed combinations.
It seems to be possible in Android to do so, see example here:
http://marblemice.blogspot.com/2010/...n-android.html
As far as I can interpret this code it calculates a sine wave tone "on the fly" at the desired frequency into a buffer array and uses that buffer data to generate and play it as a PCM stream.
Since above code seems to be quite simple I wonder if a clever Java programming guy would come up with a simple Basic4Android "Tone Generator" library which others could use for this purpose?
Unfortunately, I am only an old fashioned VisualBasic guy and making my first steps with Basic4Android...for creating my own library my skills are simply too lousy.
The Audio library was updated and you can now use the Beeper object to play "beep" sounds.
Dim b As Beeper
b.Initialize(300, 500) '300 milliseconds, 500hz
b.Beep
Updated library link
This is definitely possible to do on Android, in a java-based application. I don't know if Basic4Android can do this "natively" (I'd never heard of Basic4Android before this), but it appears that you can create libraries in java that can then be accessed by Basic4Android, so it would be theoretically possible to create a java library that does this and then call it from your B4A app.
However, since this would entail learning some java and the Android plugin for Eclipse anyway, maybe you should just take the plunge and learn java for Android? I'm a long-term Visual Basic guy myself (started in 1995), and it wasn't really that difficult to transition to C# and thence to java.