Solved

Linux Java: Green Screen Effect

Posted on 2013-01-28
11
441 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

930 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

12 Experts available now in Live!

Get 1:1 Help Now