Panel.image displays some images with the wrong orientation - java

We are working on Tensorflow to train a dataset of images.
To get images we record video using our phones and, using OpenCV in Python we extract each frame and save them as JPG images. I rotate some of them to portrait mode with the Photos App on Windows 10.
Then, we have our own annotation tool written in Java to label each item we see on the images. It return a CSV file for each object with their coordinates (in percentage).
However, when I ran the training yesterday, I noticed via the tensorboard interface that some were not annotated rightly (the ones I rotated with Photos)
Here is the image opened on Tensorboard, you can see that the can is very badly annotated.
It turns out that if I open this image with our Java software it is well annotated, but as you can see below, the image is horizontal (it doesn't take in account the rotation applied with Photos) :
If I open it with Paint, or the explorer it appears in portrait mode like in tensorboard.
An other fact, If I send the picture via Facebook, and download it again, it will appear in portrait mode on the Java tool as it would have been from the beginning.
I tried to rotate the image with Paint this time, and it appears correctly in the Java tool.
The code that displays the image in Java:
panel.image = New File(srcFile);
The code that saves video frame in Python:
cap = cv.VideoCapture(video_path)
while cap.isOpened():
ret, frame = cap.read()
if ret:
try:
cv.imwrite(output_img_path, frame)
except Exception:
pass
else:
break
cap.release()
Do you know why Java ignores the rotation applied via the Win10 Photos software, why it works via Paint ?
Is there a way to make Java take it in account because it would be very unpleasant to start again from scratch.
Thanking you in advance,

After noticing that rotating images with Paint instead of Photos was giving what we wanted, I found out what was wrong.
"If you’re using Windows 10, File Explorer and the default image viewer will properly obey the Exif Orientation tag, so photos that come from your smartphone or digital camera will be display properly. Google’s Android and Apple’s iOS both natively create photos with the Exif Orientation tag and support it." (source)
I used JPG autorotate to fix this.

Related

CodenameOne - Importing set of images in the theme

My CodenameOne app is mainly intended to be the iOS counterpart of an existing Android app. It is for older devices, in fact, as soon as possible, or in the future, a Swift app is going to replace it for OS 14>.
I need some customised icons and I have the svg code for it.
Initially I had to use the Flamingo tool, that converts svg files in Java classes.
I used it like
ScaleImageButton appButton=new ScaleImageButton(new AppIcon().scaled(doubleButtonSize,doubleButtonSize).toImage());
It is cumbersome but it does not even work on iOS.
So now I resorted to create png images for every icon in every dpi level, as it can also be done on Android.
I renamed the files so they follow the standard I think it is proposed in CodenameOne.
The possible names are:
verylow.png
low.png
medium.png
high.png
veryhigh.png
560.png
hd.png
2hd.png
4k.png
In the end it has to be used like
Image icon = theme.getImage("icon.png");
It seems that the images can be imported in the project in more than one way.
I was said to include them in the theme.
According to the CN1 developer guide I have to set the size for each.
If I import them as a whole (selecting the folder or selecting all images and hitting the "Open" button) in the theme editor a dialog appears with all wrong sizes (but they resemble a particular set of choice, although very unlikely).
They are not always the same sizes but neither they are defaulted according to the provided set of images.
I provide images as 24px, 36px, 48px, 72px, 96px, 144px, 192px, 288px, 384px for normal size icons, and also I provide double sized images for double size icons in my app (the values are not doubled as expected).
I also have to check "Square image" and "Preserve aspect ratio" options (my images are already square).
Then the strangest part is that there is a percentage, I see it is 20 for example.
The caption reads "will affect all entries". I understood that it is to scale images, that is what a developer just do not want, unless the developer has wrong sizes, but still proportioned among themselves, that cannot be the case I think.
However I do not need any scaling, the images are right as they are. I created them on purpose.
The developer guide is not enough clear to me.
So I am asking
is it right to tweak the wrong size to match the right ones, and what about the percentage?
This specific UI is a bit out of date by now and wasn't used much even when it was added. Most users opted to do desktop scaling for multi images.
The scale option is designed to scale down from a high resolution image on the desktop. You don't want/need that.
You don't need to edit the file. Just make sure to turn on the XML team mode and make sure your images use the right file names. Then once you save the images will appear in the resource file.
I suggest adding a multi-image using the standard method of add in the menu. Then replacing all the generated images with your copies and reopening the file, then saving again (the last save is important as it will override the res file).

Animated Splash screen in Netbeans Java

I am trying to make animated Gif Splash screen in java netbeans but it doesn't works.. so I use jpg or PNG files it works .. I want to use gif animated file in splash screen I am using -splash:src/Images/sspp.PNG in VM options.. please tell some solutions so I am able to use animated splash screen.
I think you'll find that the problem comes down to two things...
1.Using the command line parameter (-splash), Java expects the image to be a file on the file system, whereas the manifest file expects it to be an embedded resource.
2.Java doesn't seem capable of playing optimised gifs, that is gifs whose frames represent the difference between the last and current frame, instead of a complete image (as far as the splash screen goes).
I tried using
and
The first image failed, but the second worked, the difference, as near as I can tell, is the first is optimized and the second is not...

Running Android app with web view on various devices with various physical sizes and resolutions

I've got Android application running in landscape mode on 10" tablet with 1280x800 px resolution. App contains web view including picture with 1280x720 px size, so it's kind of full screen web view.
If I run the very same application on HTC One X smartphone, which is 4.7", 720 x 1280 px, also in landscape mode, web view seems to display only part of the picture, much less as I would expect. It even looks like physical 1/4 of the original, top left quarter.
Does anybody have any experience of running same app on similar or even different resolutions with completely different physical screen sizes?
Any recommendations?
For instance, I would like to run this app also on 7" tablets, where the resolution is only 1024x600 px. Can I still do that without need of changing picture size?
That is just the behavior of a web view/web page in general. Unless you tell it to with JavaScript or css, it wont care how big your screen is and will display all the content at the exact pixel size specified. You can more than likely dynamically re-size the image with JavaScript or css.
This may be what you are looking for: How can I resize an image dynamically with CSS as the browser width/height changes?
According to this thread:
Android Webview initial zoom out
This is the right answer:
webview.getSettings().setLoadWithOverviewMode(true);
This will cause the webview to be zoomed out initially.
webview.getSettings().setUseWideViewPort(true);
The Webview will have a normal viewport (like desktop browser),
You can create separate stylesheets for each density.
http://developer.android.com/guide/webapps/targeting.html#DensityCSS
just to conclude this, all changes had to be done on portal side in html, js and css in order to display it correctly on various tablets.
Playing with settings of WebView element didn't help in this case.

Images that look good on display seriously degrade when printed

I have this JAVA swing desktop application where i am printing some reports.
The reports contain some text and some images.
These images, when displayed on the screen through my application, looks absolutely fine.
But when the same image image is sent for printing on a formatted document, the image part looks degraded in quality but the text remains perfect.
Any suggestions on how to go about this?
P.S. The application is being used at more than 100 different centers. It is not a printer issue as all the printers can not be defected at the same time. I was thinking if any one could suggest me on how to set the dpi of the document to be printed so that i could get a higher resolution.

Java System Tray Icon on MacOS 10.7.4 not showing animated gif

I'm trying to get an animated gif to appear in the MACOS System Tray using Java. I have PNG icons showing corretly, but as soon as I try and set the icon to an animated gif (so I can show a spinning timer) it goes blank and shows nothing in the system menu tray.
According to the JavaDocs for the System Tray class, setImage should automatically support animated images if given but it doesn't specify the image format or anything else required to get animated icons in the system tray.
Does anyone know how to get this working?
Chances are this problem cannot be resolved with the java.awt.SystemTray class. The only option you have is to try JDIC which uses native code. Frankly I'm not sure whether the JDIC project is maintained anymore, it is quite hard to find information on the web...
In a project of mine I used JDIC do integrate the system tray. You can use it as starting point and get the libraries from there, if you can't find any other resources.

Categories

Resources