1
votes

My matlab code does image processing, and I made matlab function which has 2 images as inputs. I wrote a separate java class to perform the imread function of matlab, i.e., to read the jpg images into 3D array (its an RGB image).

import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import QRcode_java.*;
import com.mathworks.toolbox.javabuilder.*;


public class Driver {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        encoder_class x=null;     //encoder_class is the class built from the  
                                        //matlab function                         

        Object[] barcode2=null;         //output of matlab function
        barcode_image_class barcode;     //class to imread the jpg image input
        barcode= new barcode_image_class();
        original_photo_class original_photo;  
             //class to imread another image input
        original_photo= new original_photo_class();

        try {
            x= new encoder_class();
            barcode2=x.encoder_function(barcode, original_photo); 
//**ERROR!** /*encoder_function is the matlab function written by me. this line gives an //error as the following: 
//"The method encoder_function(List, List) in the type encoder_class 
//is not applicable for the arguments (barcode_image_class, original_photo_class)"*/

        } catch (MWException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

Could you please tell me how to fix this error? Is it a problem with my java code, or the import of the matlab code? I am very new to Java, so I can't figure out the problem. Thanks!

1
Complete stab-in-the-dark: does it help if you wrap the arguments to x.encoder_function in a call to Arrays.asList, i.e. x.encoder_function(Arrays.asList(barcode), Arrays.asList(original_photo));? (You'll need to import java.util.Arrays;`.)Luke Woodward
Thanks Luke! this code removed the error! But now I am having some problem with the Matlab-Java interface: Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the library mclmcrrt7_15.dll, required by MATLAB Builder JA, on java.library.path. This library is typically installed along with MATLAB or the MCR, its absence may indicate an issue with that installation or the current path configuration.The MCR version that this component is trying to use is: 7.15.user1493972
I changed my Path in the system settings to ...\Files\Java\jdk1.6.0_33\bin But since I have Java version-7 installed, It is not using version-6. The problem is that matlab is connecting to version 6, and so there's an incompatibility. How do I solve this?user1493972

1 Answers

0
votes

From you comments, your have defined a method encoder_function(List, List) that takes two Lists as arguments. You are trying to call it with some parameters that are not Lists and that's why the compiler is complaining.

To fix this, you have to either:

  • Change encoder_function(List, List) definition to take barcode_image_class, original_photo_class as arguments and update the method's code accordingly

OR

  • Find a way to convert barcode_image_class, original_photo_class to List (either by implementing the List interface or by providing some helper method in both classes that convert them into Lists