I have to associate a couple of text parameters (a UUID and a couple of strings representing integers) to a PNG image in a way they can follow the image when the PNG file is passed from an Android device to another through the Net. This is the typical situation in which I would use a couple of custom auxiliary chuncks (similar to EXIF fields ) to store my data inside the PNG image itself.
Maybe it is just me but the only info I was able to find about reading and writing PNG custom metadata from Java code on Android was this SO post:
Writing image metadata in Java, preferably PNG
that even offers some code (quite verbose, as usual with Java).
Those same SO post refers also to PNGJ: http://code.google.com/p/pngj/
To be honest, I would be happy to not use yet another library in this project.
Does anybody know of others ways to write and read text metadata in a PNG file in Android? Maybe a less verbose way... Maybe a way that does not require a separated library....
Any other source of information? Any tutorial? Any example?
I'm open to use a different (but equivalent) image file format, if needed (JPEG, whatever).
A solution working also on iOS and Windows 8 Phone would be a plus but it is not actually required.
I had to do something similar lately, so I had to study the subject.
Android offers you no option of manipulating png metadata. You will have to use an external library (PNGJ seems like a good option).
In my case, since I am making changes to the Android frameworks, I didn't use an external lib, but made changes to skia (the Android graphics library instead).
If you need more info on that I can give you, but I think it's irrelevant in your case.
Related
A previous answer provides code for reading the quantization tables of jpeg files in Java. However it uses javax.imageio.ImageIO which, according to this answer, isn't available on the Android platform.
How can I read read the quantization tables of jpeg files on Android in Kotlin or the Java subset available on Android?
edit
I have found the korlibs/korim Kotlin library which seems to read the quantization tables. But I'm still a beginner with Kotlin so I haven't yet figured out how I go from a string with the path to the JPEG file to printing out the quantization table.
I am, unfortunately, not aware of such an API for Android.
However, parsing the JPEG quantization tables aren't that hard... You could probably have a look at my JPEGSegmentUtil and QuantizationTable (originally by Helmut Dersch) classes and adapt them to Android. The mentioned code is available under BSD license.
You would need to replace the javax.imageio.ImageInputStream with a different type, preferably something that implements java.io.DataInput and has proper seek/skip, replace javax.imageio.IIOException with normal IOException, and perhaps a few more tweaks.
If you only need to read quantization tables then the simplest solution would be to implement parsing yourself. Basic sample (in C#; but Java/Kotlin implementation is pretty similar): https://stackoverflow.com/a/46162800/136138
This conversation might also be useful: JPEG file quantization table definition
If you need to do more JPEG-related operations then look at JpegKit that wraps the native libjpeg-turbo library.
I know we can extract text from image using ocr. But I need to extract the text present in video, like those in video lectures. Or in other words is it possible to transcribe a video to text. Is that possible? If so please suggest me how to do it in java or any other language.
My naive linux driven approach would be:
check: does the OCR work in my operating system?
extract some samples from the video using the normal runner. Each runner (for example VLC) has such a functionality.
check: how good is the OCR in extracting text from image files?
check: how good is the OCR in extracting text from image files with the background the video is providing?
get software to extract frames from videos in batch -> there is various software which allows to create contact-sheets, this should also be able to extract images in full resolution at abitrary points in time out of the video. Full resolution might be necessary to allow the OCR to work. Perhaps you can clip the images first, if you know, that the text is positioned in fixed rectangles.
Worst case you let OCR analyse each frame of the movie.
That mostly depends on how good and how fast your OCR is working. Everything else to me is very proven software. The language might be bash-shell-script, since the components will probably be separate linux programs. As I mentioned, it depends on the quality, performance and runtime environment of your OCR.
Yes, You can do that and there are 3 ways you can achieve it.
Split, Classify and train on your own.
Get a performance server,
A. Extract images from the video
B. Develop and Train your machine learning model. You can use tensor flow to do the same.
Note: If you prefer to train models on your own, make sure you have enough time as sometime the developing and training requires few months and you should have data to train them.
Use an OCR framework
USE API(Freemium model). There are many available in the market. Just google them and your will have many in hand.
This question is an extension to my previous question:
Problems associated with my screenshot-taking software
Now with the problems solved, I want to convert the .png images to .avi file. Now the format of images and video doesn't really matter since the images are written to the disk using javax.swing.ImageIO so I can change the save format. So they are BufferedImage before being made as .png
Most questions here on similar topics were asked to use some 3rd party software and all. I want to do it using just Java.
Where do I begin?
Can you help me understand this?
If you don't mind using 3rd party libraries you might want to take look at Xuggler. It's a wrapper for ffmpeg that helped me some time ago.
Update: This demo might contain all you need: https://github.com/xuggle/xuggle-xuggler/blob/master/src/com/xuggle/mediatool/demos/CaptureScreenToFile.java
I'm in the process of writing a Java and FFmpeg based video editor, and I'm trying to find a library that would allow me to create a video from frames rendered via Java2D.
By 'video' I mean in a standard format (preferably vp8/webm, but anything common should be alright). It would be a plus if there was some facility for modifying preexisting videos as well, but that may need to be left to ffmpeg. Audio isn't needed as I'll mainly be working with ffmpeg for that.
The obvious solution would be to save each frame as an image and have ffmpeg combine them - but I worry about performance and quality using this method. Additionally, some tests showed that even short videos (less than 5 minutes) at 1280x720 resolution would be pretty massive in size - which I'd like to avoid if possible. Working a little more directly with compressed formats rather than huge batches of image files would certainly be preferred, or at least some method that isn't too hungry for disk space.
I'm not against homebrew solutions either (I'm already writing the ffmpeg bindings from scratch), but I don't know how practical it would be to write my own vp8 encoder for something that seems like it should be fairly simple.
Any suggestions on where to go with this? Or is the best solution to generate a individual image files and combine them later?
Thanks!
Have you had a look at Xuggler? It should be able to encode videos in the way you describe, though I haven't tried producing videos from a series of BufferedImages it should be possible.
It sits on top of ffmpeg and is pretty powerful with what it can achieve - it's not the easiest API to start with but there are a number of good tutorials around.
Canon/Nikon/other cameras save raw output of their sensor in some of their proprietary formats (.CR2, whatever). Is there any Java library designed to read them and convert into manageable BufferedImages?
I don't reqlly care here about fully customizable conversion similar to ufraw or imagemagick, rather something simple that "just works" for rendering simple previews of such images.
I've been where you are, and I feel for you. Your best bet is to use an Adobe or dcraw-based program to create thumbnails automatically. Temporary DNG files using Adobe's converter may be easier to use.
IF you insist on doing it in Java, you're about to run into a mountain of pain. RAW formats change often, have all sorts of crazy nuances and are intentionally hard to work with. Camera makers want you to use THEIR RAW conversion software, to show the camera's abilities at its best and screw Adobe. The guy behind dcraw found that some are camera manufacturers even use encryption now!
The existing Java libraries are poor -- JRawIO has improved since I last looked at it, but it supports only a fraction of the formats that dcraw does. In addition to the listed libraries, the imagero library may provide the ability to display a thumbnail for your image.
From personal experience, don't even think about writing your own RAW file reader.
I tried to do this with a very simple RAW format once (just a solid array of sensor data, 12 bits per pixel). The dcraw source translates badly to Java. You haven't seen such a nightmare of bit-fiddling ever. Took me days to debug problems with byte alignment and endian-ness.
jrawio is a plugin for Java Image I/O. With it you can read the raster data, the thumbnails and the metadata from the raw image file.
nef and cr2 already contains preview images in jpeg. just find the right offset and the right length to extract it...
Laurent Clevy # lclevy.free.fr/raw
Laurent
Unless you want to write you own file parser/loader (sounds fun imho ;) ), perhaps JMagick will help you. I haven't tried it and it might not work given your target platform since JMagick uses JNI.
UPDATE: dcraw looks like a good resource/reference