1

我的 matlab 代码进行图像处理,我制作了 matlab 函数,它有 2 个图像作为输入。我编写了一个单独的java 类来执行matlab 的imread 功能,即将jpg 图像读入3D 数组(它是一个RGB 图像)。

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();
        }
    }

}

你能告诉我如何解决这个错误吗?是我的java代码有问题,还是matlab代码的导入有问题?我对Java很陌生,所以我无法弄清楚问题所在。谢谢!

4

1 回答 1

0

根据您的评论,您已经定义了一个encoder_function(List, List)以两个Lists 作为参数的方法。你试图用一些不是Lists 的参数来调用它,这就是编译器抱怨的原因。

要解决此问题,您必须:

  • 更改encoder_function(List, List)定义以将barcode_image_class,original_photo_class作为参数并相应地更新方法的代码

或者

  • 找到一种方法将barcode_image_class,转换original_photo_classList(通过实现List接口或在两个类中提供一些帮助方法将它们转换为Lists
于 2012-07-01T08:28:15.960 回答