This question already has answers here:
Microphone level in Java
(2 answers)
Closed 10 years ago.
I know there are some questions already like that but always only a part of the answer.
I just want to get the current decibels which are "recorded" by the microphone.
I got as far that i have opened a TargetDataLine but the read method only returns confusing bytes :/
Could you tell me how i can read the decibels?
If you are interested in measuring, for example, dB SPL, This is not possible, at least not in the sense you probably mean. Here is one of several answers about using a computer mike to measure absolute sound intensity: How can I calculate audio dB level?
If you are confused about what the bytes mean and are interested in, for example, measuring change in volume/sound intensity/something like that over time, that is doable, but it's a different question. There are many questions about how to interpret the raw data that comes out of javasound and other audio apis here on SO, but a better source is a tutorial. One good place to start is with some of the examples and tutorials over at java sound resources. You might also be interested in my slides from a talk on the basics of computer audio.
Related
I’m trying to build a sketch that shows me levels of audio coming into a system. I want to be able to do more than 2 channels so i know that i need more than the processing.sound library can provide currently and my searching has led me to javax.sound.sampled.*, however this is as far as my searching and playing has got me.
Does anyone know how to query the system for how many lines are coming in and to get the amplitude of audio on each line?
This is kind of a composite question.
For the number of lines, see Accessing Audio System Resources in the Java tutorials. There is sample code there for inspecting what lines are present. If some of the terms are confusing, most are defined in the tutorial immediately preceding this one.
To see what is on the line, check Capturing Audio.
To get levels, you will probably want to do some sort of rolling average (usually termed as root-mean-square). The "controls" (sometimes) provided at a higher level are kind of iffy for a variety of reasons.
In order to calculate those levels, though, you will have to convert the byte data to PCM. The example code in Using Files and Format Converters has example code that shows the point where the conversion would take place. In the first real example given, under the heading "Reading Sound Files" take note of the place where the comment sits that reads
// Here, do something useful with the audio data that's
// now in the audioBytes array...
I recall there are already StackOverflow questions that show the commands needed to convert bytes to PCM.
This question already has answers here:
Closing Streams in Java
(6 answers)
Closed 6 years ago.
With huge advancements in CUPs able to process mass amounts of information in fractions of seconds, why is it important that I close a file stream?
Remember that not all devices are the same, platforms like mobile(smartphones and tablets) need to be as efficient as possible. Or if the application has a big user base, maybe when 400 people are logged in there wont be that many problems, but what happens when it goes to ~40k? You have to make your code as versatile as possible, always think about scalability.
This question already has answers here:
Turn Image into Text - Java [duplicate]
(4 answers)
Closed 7 years ago.
I want to search a word from image(scanned copy), retrieve values from image, highlight the location. Is there any API or library available for processing images. I am using Swing for displaying images.
You need something to convert the pixels into characters. That something is a program that provides OCR.
Keep in mind that any program you use will provide its best approximation of what it thinks the character is. While technology has improved a lot, there are many fonts, sufficient noise, and various other confounding factors that could result in false input (where the character is not what you would have deemed it to be). There are also scenarios where the input cannot be mapped to a character. Write your software defensively to handle both cases, as this should be considered "non validated input".
Check out "tesseract". It isn't Java, put available for most platforms open-source, and you can call the command-line program from java via System.exec()
https://code.google.com/p/tesseract-ocr/
given the images in the correct format, it's recognition rate is even better than many commercial OCR software products.
I am working on a personal project. Basically I have a collection of small sound clips, like a clap or a beep noise. I want to create a program that listens for the sounds via a mic or some form of audio input, and when I play sound clip it should identify that clip.
I have tried looking into this myself and have found this article.
http://www.redcode.nl/blog/2010/06/creating-shazam-in-java/
I tried replicating it, but I have found that it doesn't work as expected. I am guessing the sound clips I am using to create my hash from are too small to create enough values to compare.
Wondering if there any well know programs or algorithms that are capable of doing this.
Dan Ellis' slides are probably a good start. They explain the principal task of audio fingerprinting and the two best known approaches:
The Shazam algorithm by A. Wang (paper)
The Philips (now Gracenote) algorithm by Haitsma/Kalker (paper)
As you have already tried the landmark (Shazam) approach, perhaps it's worth your time to fiddle around with the stream-based approach. Since your queries are very short, you might also want to tweak the analysis frame length and overlap. Shorter frames and greater overlap may improve your results for very short samples. If you want to delve even deeper into the Haitsma/Kalker algorithm, you might also be interested in this unfortunately paywalled paper (by me).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I spent quite some time researching for a library that allows me to compare images to one another in Java.
I didn't really find anything useful, maybe my GoogleSearch-skill isn't high enough so I thought I'd ask you guys if you could point me into a direction of where I could find something like this.
Basically what I want to do is to compare two images with each other and get a value of how much the two are similar. Like a percentage or so.
I hope you guys have something I can use, I wouldn't know how to write something like that myself...
PS: It doesn't necessarily has to be in Java, that's just the environment my app will be running.
You could take a look at two answers on SO itself: this one is about image comparison itself, offering links to stuff in C++ (if I read correctly) while this one offers links to broader approaches, one being in C.
I would suggest starting with the second link since there's links on that discussion that'll lead to implementation code of some relevant techniques which you might be able to "translate" into Java yourself.
That's the best my google skills could do, no Java though - sorry. I hope it's a good starting point!
EDIT:
Here's someone with your problem who wrote his own comparison class in Java. I didn't read the source code though. He expressly states that he couldn't find Java libraries for that purpose either, so that's why he wrote it himself.
Oh, and this question on SO has probably the best links on this, all regarding Java libraries of image processing. Hopefully there's one amongst them that can compare images for similarity.
Ok, last edit:
The Java Image Processing Cookbook shows a Java implementation of a basic algorithm to determine the difference between two pictures. It also has an email to contact the guy who wrote it as well as a host of references. No library though.
EDIT after reading your comment to your question:
Unless you've already checked all of the above links, since what you want seems to be checking whether two images are equal, I would suggest starting with the Java Image Processing Cookbook (since that has an implementation of an algorithm in Java to check for equal images) and the last link to an SO question. Also, check PerceptualImageDiff and the source code of that project (C++); it sounds really nifty - it's apparently supposed to check whether two images look equal to the human visual system.
Just off the top of my head, OpenCV is a great image processing library, but it might be overkill if you just want to compare images. If that's the case, I'd go with ImageJ.
Someone already asked how to do this using OpenCV here.
I'd use C++ for this, but if you must use Java, there is a project which made a Java wrapper for OpenCV, here.
I used the class in this link to compare two product images, and the results were cool. It's not very hard to implement it just to be used for comparing two images, you just need to delete the lines of JAI and Swing and such. It resizes images to 300x300 and returns a difference value such as "1234". The maximum difference value is near "11041", it's stated in the link. Doing a division, you can simply get the percentage. If interested I can post the modified code here later.
The results were cool, but I still got "digital camera photos", detected to be similar to "TV photos". So, I used ImageJ to detect edges in the picture. Using the detect edges operation, ImageJ converts the image into a edge detected greyform image. Than I put the two edge-detected images in the same comparator and multiplied the both values. The results got even more accurate.
Getting the edge-detected form of the images