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
Solved

Linux Java: Green Screen Effect

Posted on 2013-01-28
11
455 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 114
session migration servlets 2 42
how to see all occupied ports on windows 10 laptop 15 75
ejb example issues 3 19
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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 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