Solved

Linux Java: Green Screen Effect

Posted on 2013-01-28
11
437 Views
Last Modified: 2013-02-04
Hello experts,

I am relatively new to the Java Programming language and am completely new in the Linux OS. I am currently trying to create a program that is capable of taking an image and replacing a "green screen" with a second image much like how new channels do the weather reports. Unfortunately, I do not quite understand many of the classes that I may need to use such as the File class and was hoping that you can either explain them or refer me to some sites where I can better understand them.

Thank you for your time.
0
Comment
Question by:Paul_ATL
  • 6
  • 4
11 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 38829203
Please explain the functionality that you need, without even mentioning Java classes. Don't try to anticipate what classes you need. Just say what you want it to do
http://technojeeves.com/joomla/index.php/free/117-smart-questions
0
 
LVL 35

Expert Comment

by:mccarl
ID: 38830728
Agree with what CEHJ has said above, but I would also add; a good place to start is the Java Tutorials
0
 

Author Comment

by:Paul_ATL
ID: 38831471
The functionality that I need is for the program to be able to identify two image files of the same dimensions specified by a user and transpose one of them onto the other in place of a solid "green screen" color. Once that's done, it needs to be able allow the user to save the new image.

Edit: I have attached the code that I have done so far along with an image of what errors came up while I was trying to compile. The compilation errors are from me testing to see that the code I have written so far works. For now, I am not certain how to change the code to read files specified by the user. I only know how to get the program to load up a specific file based on the filename. During the compilation, I used specific filenames, but have deleted them from the code that I have uploaded.
GreenScreen.java
ErrorMessages.jpg
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 100 total points
ID: 38832036
public LoadForeImage()

Open in new window

would be a constructor, which is not what you intend. What you need is

public void loadForeImage()

Open in new window

(method names in Java begin lower case)
0
 

Author Comment

by:Paul_ATL
ID: 38832113
I decided to change my code and moved the image reading process into the main method. After doing this, the program was able to compile with the new code, but I do not know how to set it up read the images. I will attach the new code here as well.

Thank you for your help.
GreenScreen.java
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 86

Expert Comment

by:CEHJ
ID: 38832539
It's a start. It's not far off, though there seems to be a little confusion and some duplication and strange file names.

a. you need to use proper methods in your class - there should be very little code in main
b. it's preferable (assuming your images are read-only) to load them as resources

http://technojeeves.com/joomla/index.php/free/126-loading-files-as-resources-in-java-with-netbeans
http://technojeeves.com/joomla/index.php/free/120-loading-files-as-resources-in-java-with-eclipse
e.g.
foreImage = ImageIO.read(getClass().getResourceAsStream("/images/foreImg.png"));

Open in new window

0
 

Author Comment

by:Paul_ATL
ID: 38833630
I have added in the code that should (hopefully) check to ensure that the files both exist and are readable. I have also moved the BufferedImage class coding portions back into the main method after the checking portion. Right now, the program gets an error about the getClass() being a non-static method being unusable as a reference from a static context. In order to get around that, I have removed that code for now.

The only error I am getting so far now has to deal with creating the file objects at the beginning of the main method. I am trying to get it so that the user specifies the file they want as args[0]. Because this is creating an error, I am assuming there will also be an error for the second file object that will become args[1].

I am attaching the new code that I have written so far. Thank you for your help.
GreenScreen.java
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38834863
being a non-static method being unusable as a reference from a static context. In order to get around that, I have removed that code for now.
As i already said above, that code should not be in main. That's the reason for your problem. Move it out into a non-static method
0
 

Author Comment

by:Paul_ATL
ID: 38836230
I have moved the file check and the buffer codes to a separate class and re-implemented the the getClass() method as well. This is so that I can have the large portion of code in a separate helper function that the main program can call upon. I have tried compiling the new code to make sure that it can be compiled and have gotten several errors, some for illegal start of expression as well as some others that I do not quite understand.
GreenScreen.java
ImageFile.java
ErrorMessages3.jpg
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38836851
Your errors show me that you're starting to try to run before you can walk. You need to get the basics down on classes and methods. Take the Oracle tutorials
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38850276
:)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now