[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Linux Java: Green Screen Effect

Posted on 2013-01-28
11
Medium Priority
?
516 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 36

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
CEHJ earned 200 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
 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

650 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