|
|
I'm still new to Java. I'm having trouble while retrieving the RGB pixel values from my method, compareHexaRGB which in this method I could get the difference pixel values based on comparison of 2 similar images. I tried the printString2DArray method but it doesn't work. It stated either incompatible types: String[][] cannot be converted to String[] or produce errors such as [[Ljava.lang.String;@6d09a8df
After I get the values, I would like to combine it to one Hex value then convert it to ASCII characters. I couldn't proceed to this process as the retrieve value couldn't work.
Here is the code for compareHexaRGB() method:
public class compareHexaRGB
{
private static int w;
private static int h;
private static BufferedImage img;
private static BufferedImage img2;
private static String[][] check_hex2;
private static String[][] check_hex4;
private static String[][] message;
public static void compareHexaRGB(BufferedImage image, BufferedImage image2, int width, int height) throws IOException
{
w = width;
h = height;
img = image;
img2 = image2;
}
public void check() throws IOException
{
getPixelRGB1 pixel = new getPixelRGB1();
getPixelData1 newPD = new getPixelData1();
int[] rgb;
int count = 0;
int[][] pixelData = new int[w * h][3];
check_hex2 = new String[w][h];
check_hex4 = new String[w][h];
for(int i = 0; i < w; i++)
{
for(int j = 0; j < h; j++)
{
rgb = newPD.getPixelData(img, i, j);
for(int k = 0; k < rgb.length; k++)
{
pixelData[count][k] = rgb[k];
}
if(pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]))
{
System.out.println("\nPixel values at position 2 are the same." + "\n" + pixel.display_imgHex2()[i][j] + " " + pixel.display_img2Hex2()[i][j]);
}
if(pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j]))
{
System.out.println("\nPixel values at position 4 are the same." + "\n" + pixel.display_imgHex4()[i][j] + " " + pixel.display_img2Hex4()[i][j]);
}
if(!pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]))
{
System.out.println("\nPixel values at position 2 are not the same." + "\n" + pixel.display_imgHex2()[i][j] + " " + pixel.display_img2Hex2()[i][j]);
check_hex2[i][j] = pixel.display_img2Hex2()[i][j];
System.out.println("\nOutput Hex 2: " + check_hex2[i][j]);
}
if(!pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j]))
{
System.out.println("\nPixel values at position 4 are not the same." + "\n" + pixel.display_imgHex4()[i][j] + " " + pixel.display_img2Hex4()[i][j]);
check_hex4[i][j] = pixel.display_img2Hex4()[i][j];
System.out.println("\nOutput Hex 4: " + check_hex4[i][j]);
}
if(!pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]) || (!pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j])))
{
System.out.println("\nOne of the pixel values at position 2 and 4 are not the same." + "\n" + pixel.display_imgHex2()[i][j] + " " + pixel.display_img2Hex2()[i][j] + "\n" + pixel.display_imgHex4()[i][j] + " " + pixel.display_img2Hex4()[i][j]);
if(!pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]) || (pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j])))
{
check_hex2[i][j] = pixel.display_img2Hex2()[i][j];
System.out.println("\nOutput Hex 2: " + check_hex2[i][j]);
}
if(!pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j]) || (pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j])))
{
check_hex4[i][j] = pixel.display_img2Hex4()[i][j];
System.out.println("\nOutput Hex 4: " + check_hex4[i][j]);
}
}
count++;
System.out.println("\nOutput Count: " + count);
}
}
}
public String[][] getCheck_hex2()
{
return check_hex2;
}
public String[][] getCheck_hex4()
{
return check_hex4;
}
}
Code for extractMessage() method:
public class extractMessage
{
private static String character;
private static String[][] char1;
private static String[][] char2;
private static int w;
private static int h;
private static void printString2DArray(String[][] in)
{
for (int i = 0; i < in.length; i++)
{
if (i != 0)
{
System.out.print(", ");
}
System.out.print(java.util.Arrays.toString(in[i]));
}
}
public static void charExtract()
{
compareHexaRGB hexRGB = new compareHexaRGB();
char1 = new String[][]
{
new String[] { hexRGB.getCheck_hex2() }
};
System.out.println("Char 1: ");
printString2DArray(hexRGB.getCheck_hex2());
}
public String convertHexToString()
{
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder();
extractMessage extract = new extractMessage();
extract.charExtract();
for(int i = 0; i < extract.length(); i+=2)
{
String output = extract.substring(i, (i + 2));
int decimal = Integer.parseInt(output, 16);
sb.append((char)decimal);
temp.append(decimal);
}
return sb.toString();
}
}
Any help I would appreciate!
modified 9-Jan-14 11:23am.
|
|
|
|
|
Yout compareHexaRGB method does nothing so serves no purpose. I am not sure what display_imgHex2 is supposed to do, but why do you need to convert pixels to strings in order to compare them? Why not just something like:
if(pixel1[i][j] == pixel2[i][j]))
You seem to be creating something that is far more complicated than necessary.
Veni, vidi, abiit domum
|
|
|
|
|
what is the approach to calculate the weight (influence of each feature that is collected from YouTube metadata to recognize harassment videos) and the score (similarity ratio of each feature with training dataset)of the features in data mining for classification purpose.How to set threshold value of accuracy to check whether our classifier is classifying the testing dataset correctly or not ?? Also how to make our own Logistics Regression classifier for the classification whether the given vidoe is Harassment type or not ??
Plz reply asap...
Thanks in advance...
|
|
|
|
|
Does this have anything to do with Java?
Veni, vidi, abiit domum
|
|
|
|
|
Hello,
I have the following code in C#:
public void encrypt()
{
SeaX11:
...
if (Cnt != 47) goto SeaX12;
goto SeaX21;
SeaX12:
...
goto SeaX11;
SeaX21:
...
if (Cnt != 1) goto SeaX22;
goto SeaX23;
SeaX22: goto SeaX21;
SeaX23:
return;
}
to convert in Java. Can anyone help with this?
|
|
|
|
|
http://stackoverflow.com/questions/2430782/alternative-to-goto-statement-in-java[^]
Java reserves goto but does not define it. However, statement labels do exist, and in a strange twist break and continue were enhanced to accept them. You can only jump out of local blocks, but break operates on any block – not just loops. This makes Java break almost the full equivalent of C# goto.
Java switch operates on (boxed or unboxed) primitives and enums, and since Java SE 7 also on strings. You don’t need to qualify enum case values with the enum type as in C#. Java allows fall-through from one case to the next, just like C/C++. Use the compiler option -Xlint:fallthrough to warn against missing break statements. There is no equivalent to C# goto targeting a case label.
|
|
|
|
|
I would suggest you start from scratch and redesign your program. With all those goto statements it's impossible to figure out the logic.
Veni, vidi, abiit domum
|
|
|
|
|
I am afraid that I can't rewrite the code since it is ported from 8051 assembler to C#. I thought we could do something with
if/else to
goto ?
|
|
|
|
|
Since there is no goto statement in Java, you really do not have much choice.
Veni, vidi, abiit domum
|
|
|
|
|
Hello
i'm looking for a tool that can generate the needed JNI code using only header file in order to call native C/C++ functions from a library (.so file). i'm having hard time to find the documentation i need to understand the tools so i try to ask here
i'm using eclipse on linux
the popular tools are - SWIG, JNIWrapper, Gluegen, JNA, Bridj.
i wish the tool could do the following:
1. Generate JNI code that needed to call C/C++ code? (not another wrape like SWIG does)
2. Generate conversion code in the JNIEXPORT-JNICALL methods so a structs inside structs will also will be converted automatically and not only the external struct. SWIG, for example is passing a pointer only to the external struct.
3. Good performance. Does anywone ever checked those tools?
4. Examples. if you have examples i'd love to receive.
Thanks a lot in advance
Tomer
|
|
|
|
|
|
Thank you Veni
i don't want to write manually the JNI code. i'm looking for a tool that could do that with given header(.h) file.
Do you know if such tool exist and answers my needs?
Thanks
|
|
|
|
|
The javah command generates the basic .h files, which is about all you can do automatically. I don't know what other code you imagine can be generated for you.
Veni, vidi, abiit domum
|
|
|
|
|
The javah command generates only the signatures of the methods but it doesn't generates conversion of the parameters i want to pass. Until now i managed to work only with 1 out of many tools exist - SWIG: http://en.wikipedia.org/wiki/SWIG[^]
SWIG command generates part of the implementation file (.c file) and converts variables to JNI types. For example it generates code of conversion from int to jint. One disadvantage of SWIG is that it doesn't convert internal struct if this one is inside external struct
|
|
|
|
|
I have data in MySQL database i retrieve them to draw Graphics2D shapes, the data Stored in database as Medium-Text,
each 6 points(coordinates) in single line, i spilt spaces,new line and i parsed String[] to double[], i created 4 classes, -1st class for retrieving data from database.
-2nd class for pathEntry extends JPanel i declared 6 double variables to use them in paintComponent() method in curveTo() method(to draw curves).
-3rd class for Paths extends JPanel where i used ArrayList<pathentry> and called moveTo() method and loop on paintComponent() method in pathEntry class
-4th class i used JFrame to draw all Shapes are called from the last 3 classes to draw Shapes.
i stuck in the shapes did not display on the JFrame ?
1st Class:
public class selectStmt {
public Paths db = null;
.....
String values = null;
int noPrint = 0;
while (rs.next()) {
values = rs.getString(1);
String[] valueNewLine = values.split("\\r\\n");
double[] Points = new double[valueNewLine.length];
for(int i=0;i<valueNewLine.length;i++){
Points = StringtoDoubleArray (valueNewLine [i]);
db.add(valueNewLine[i]);
db.MoveToX= Points [Points.length - 2];
db.MoveToY = Points [Points.length - 1];
noPrint++;
if(noPrint % 6 == 0) {
System.out.println();
noPrint = 0;
}}
...
public double[] StringtoDoubleArray (String str){
double[] result = new double[6];
String[] temp = str.split("\\s");
for(int i=0;i<temp.length;i++){
result [i] = Double.parseDouble(temp[i]);
}
return result;
}
2nd Class:
public class Paths extends JPanel{
public double MoveToX=0;
public double MoveToY=0;
ArrayList <pathEntry> p=new ArrayList<pathEntry>();
<a href="/Members/override">@Override</a>
public void paintComponent(Graphics g) {
super.paintComponent(g);
update(g);
}
public void update(Graphics g){
Graphics2D g2d = (Graphics2D) g;
GeneralPath path=new GeneralPath();
path.moveTo(MoveToX,MoveToY);
for ( int i = 0 ; i < p.size() ; i++ ) {
p.get(i).paintComponent(g2d);
}
}
public void paint_dump() {
System.out.println(MoveToX+" "+MoveToY);
for ( int i = 0 ; i < p.size() ; i++ ) {
System.out.println(p.get(i));
}
}
public void add (String pathstr) {
pathEntry pe=new pathEntry();
String[] temp = pathstr.split("\\s");
pe.cx1 = Double.parseDouble(temp[0]);
pe.cy1 = Double.parseDouble(temp[1]);
pe.cx2 = Double.parseDouble(temp[2]);
pe.cy2 = Double.parseDouble(temp[3]);
pe.x2 = Double.parseDouble(temp[4]);
pe.y2 = Double.parseDouble(temp[5]);
this.p.add(pe);
}
}
3rd Class:
public class pathEntry extends JPanel{
public double cx1 = 0;
public double cy1=0;
public double cx2=0;
public double cy2=0;
public double x2=0;
public double y2=0;
<a href="/Members/override">@Override</a>
public void paintComponent(Graphics g) {
super.paintComponent(g);
update(g);
}
public void update(Graphics g){
Graphics2D g2d = (Graphics2D) g;
GeneralPath path=new GeneralPath();
path.curveTo( cx1 , cy1 , cx2 , cy2 , x2 , y2 );
g2d.draw(path);
g2d.fill(path);
}
}
4th Class :
public class Main extends JFrame {
public selectStmt s;
public static void main(String[] args){
Main m=new Main();
}
public Main(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1024, 768);
setTitle("Drawing Shapes");
setVisible(true);
s = new selectStmt();
add(s.db);
s.db.paint_dump();
}
}
modified 31-Dec-13 5:38am.
|
|
|
|
|
In your 3rd class you create a Path without an initial MoveTo .
Veni, vidi, abiit domum
|
|
|
|
|
i solved it with other way in 3nd class
public void paint (Graphics g, GeneralPath path) {
path.curveTo( cx1 , cy1 , cx2 , cy2 , x2 , y2 )};
and in the 2rd class i replaced with g2d.draw(path); instead in of 3rd class
Thanks anyways
|
|
|
|
|
is it possible to connect finger print module with web page for accessing attendance(using finger print module). If It is possible,then how?. pls send ans to my email odileepshkumaro@live.com
R.Dileep Kumar
|
|
|
|
|
Member 10487162 wrote: is it possible to connect finger print module with web page
Depends on what you mean exactly - but in general it is pointless to have a "web page" with a "remote" device. So of course that means the device would need to be on the box running the browser. In that situation interfacing with the device, at some level, is going to require JNI, so it means messing around a bit with the security of the browser. But of course such a setup is already a internal application anyways so that shouldn't be a problem.
Member 10487162 wrote: pls send ans to my email odileepshkumaro@live.com
No.
|
|
|
|
|
Hi,
I wanted to build unified client application which could able to understand multiple web services (Service provider) for the various category
All the request from our client(jsp/html) should be a web services and should talk with Mangomelon server, which in turn talk with third party server
I want to create servlet program to access multiple web-services
please let us solve this problem
|
|
|
|
|
Requirements are far from complete but the basic process is.
1. Learn how to call an external Web API in java
2. Code it to call one service
3. Wrap that in a class.
4. Depending on the exact APIs that you are calling you might be able to use the same class or copy and modify for each different external Web API
5. Use the above in your servlet.
I suggest STRONGLY that you consider error scenarios where the external servers fail to connect, or fail to respond. If you just assume they will work all of the time then when they do fail you will have no idea what is going on.
|
|
|
|
|
I wrote a test operation like this:
@WebMethod(operationName="setSomeInfo")
public String setSomeInfo(List<String> values){
String retval = "";
List<String> x = values;
if(x.size() > 3){
retval = x.get(3);
}
return retval;
}
and this works perfectly.
However, When I create an object like this:
public class MyWSObject {
private String mystring;
private List<String> mystringarr;
public void setMyString(String value){
mystring = value;
}
public void setMyStringArr(List<String> values){
mystringarr = values;
}
public String getMyString(){
return mystring;
}
public List<String> getMyStringArr(){
return mystringarr;
}
}
and I use it in an webmethod:
@WebMethod(operationName="setSomeInfo")
public String setSomeotherInfo(MyWSObject myobject){
String str_val = myobject.getMyString();
List<String> str_list = myobject.getMyStringArr();
}
I cannot consume it (completely). In the client the MyWSObject is recognized with the methods setMyString , getMyString and getMyStringArr , but not setMyStringArr .
I looked this up and it seems to be a known problem, but I find it hard to believe that something basic as an array or a list is so hard to define. I'm working with NetBeans/glassfish.
Is there a simple solution to this?
(Most solutions I found involved modifying the wsdl, setting compilation options or writing wrapping classes or a combination of those.)
|
|
|
|
|
You did try it with an array rather than the List?
|
|
|
|
|