Java Media Framework video source window - java

I'm writing a java App thats going to run on windows and uses the JMF, I've got the video capture working but I need to stop the Video Source Window from popping up each time I start the App, this is the first time I've used the JMF however I've looked at the Api and googled but found nothing that talks about the Video Source Window. Thanks.

Most likely you created your window like this:
ml is your MediaLocator
videoPanel is where your adding the video window too
Player player = Manager.createRealizedPlayer(ml);
Component video = player.getVisualComponent();
video.setSize(videoPanel.getSize());
video.setPreferredSize(videoPanel.getPreferredSize());
videoPanel.add(video);
player.start();
A simple solution would then to not add the video component to a panel and call player.stop();
But without any example of your code, all I can do is speculate.
Hope this helps

Related

Panel.image displays some images with the wrong orientation

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.

Sikuli doesn't see the game I'm trying to automate

I'm running Sikuli API from Java on a game we are running in the company on full screen. The problem is that Sikuli sees the layer beneath the game (the desktop) but not the game itself. It's like the game is transparent to Sikuli. I took a screenshot through RobotFW and also, the image I'm getting is the layer beneath. So this looks like a general issue and not specific to Sikuli.
What can I do?
The games are developed in Unity
What if you use a App.focus(<appName>) before executing your code?
By using App.focus() you pull that application to the foreground.

Playing Video in JFrame?

I'm trying to play video within a JFrame, I've been looking around online for a while and everything I have tried (VLCJ, Xuggger i think its called) doesn't work, the errors I get can I can never seem to fix, the closest I have gotten is using JMF which is very old, it can never play a video file but as mentioned, it's the furthust I've gotten. Is there any good little API's / examples I can look at?
Thanks.
I guess that depends on the video, however there are a few build in mechanism.
You could use java fx http://docs.oracle.com/javafx/2/media/simpleplayer.htm
And then build javafx into your JFrame, like here: http://docs.oracle.com/javafx/8/embed_swing/jfxpub-embed_swing.htm
If embedding in java seems to be a bad solution, there is always the possibility to open the systems media player:
Desktop.getDesktop().open(new File("the.mp4"));

How to split video into frames using OpenCV Java?

I'm working on a project to analyze the motion of an object across a video, and I want to split the video into BufferedImage to analyze them frame by frame. Is OpenCV the best library for doing this? If so, how would the code look (I looked on their website but couldn't find it in the documentation). I'm new at this, so any help would be appreciated.
class org.opencv.videoio.VideoCapture allows to read video frame by frame.
Here is example of usage:
http://www.programcreek.com/java-api-examples/index.php?api=org.opencv.videoio.VideoCapture

Change logo image in VLC player dynamically

I want to control VLC player via command line in windows 7 64 bit. I want to overlay an image in particular position on a video stream. This can be done easily via vlc command line option.
Now I want to change this logo image while video is playing. Is there any way to o it? ie change logo image while vlc player play some video.
I will call this commands from net beans Java....
Have a look at vlcj. (I never used it but looking at the listed features it seems like it's capable of what you are trying to achieve.)

Categories

Resources