Call method from different class in a different package (beginner)

Hello, i have the following Problem: I have a class Histogramm.java inside a package Basis And my Main.java inside the package Main Histogramm.java has a function i want to call from Main.java
package Basis;

import java.util.*;
import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;
import Main.Aufgaben02;

public class Histogramm {

//other methods etc

public int[] gibHistogrammDaten(Mat bildMatrix) {
int[] histogramm = new int[256];
for(int i = 0; i<bildMatrix.rows();i++) {
for(int j = 0; j<bildMatrix.cols(); j++) {
double[] temp = bildMatrix.get(i,j);
histogramm[(int)temp[0]]++;
}
}
return histogramm;
}
}
package Basis;

import java.util.*;
import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;
import Main.Aufgaben02;

public class Histogramm {

//other methods etc

public int[] gibHistogrammDaten(Mat bildMatrix) {
int[] histogramm = new int[256];
for(int i = 0; i<bildMatrix.rows();i++) {
for(int j = 0; j<bildMatrix.cols(); j++) {
double[] temp = bildMatrix.get(i,j);
histogramm[(int)temp[0]]++;
}
}
return histogramm;
}
}
in my Main.java file i have a a Matrix that i want to pass to the gibHistogrammDaten(Mat bildMatrix) method.
package Main;

import org.opencv.core.*;
import org.opencv.imgcodecs.Imgcodecs;
import Basis.Histogramm.*;

import java.util.*;

import Basis.Bild;

public class Aufgaben02 {

public static void main(String[] args) {

//more code not relevant to the question

Histogramm lel = new Histogramm();
Mat hilfeOne = Imgcodecs.imread("Bilder/Blume.jpg", Imgcodecs.IMREAD_UNCHANGED);
int[] histogramm = new int[256];
}
package Main;

import org.opencv.core.*;
import org.opencv.imgcodecs.Imgcodecs;
import Basis.Histogramm.*;

import java.util.*;

import Basis.Bild;

public class Aufgaben02 {

public static void main(String[] args) {

//more code not relevant to the question

Histogramm lel = new Histogramm();
Mat hilfeOne = Imgcodecs.imread("Bilder/Blume.jpg", Imgcodecs.IMREAD_UNCHANGED);
int[] histogramm = new int[256];
}
I've been trying to call that method for a couple hours now. I tried setting the method to static public static int[] gibHistogrammDaten(Mat bildMatrix) which didn't work. I also tried creating an object of Histogramm lel = new Histogramm(); to go the route of int[] histogramm = lel.gibHistogrammDaten(hilfeOne); but that didn't work either. Next try was
int[] histogramm = new int[256];
histogram = gibHistogrammDaten(hilfeOne);
int[] histogramm = new int[256];
histogram = gibHistogrammDaten(hilfeOne);
which just tells me "The method gibHistogrammDaten(Mat) is undefined for the type Aufgaben02" Pretty much every answer i've found on google didn't work.
2 Replies
JavaBot
JavaBot4w ago
This post has been reserved for your question.
Hey @Wannabree! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
JavaBot
JavaBot4w ago
Post Closed
This post has been closed by <@237269674654433282>.

Did you find this page helpful?