Hi,
I am beginner in HIPI and the domain of image processing and I have a question about calculating an image features using sift. For that, I use this code :
************************** CODE : BEGIN ****************************
// value is the Float Image
int w = value.getWidth();
int h = value.getHeight();
// conversion of floatImage to opencv Mat
Mat image = new Mat(h,w, CV_32FC3);
FloatIndexer idx = image.createIndexer();
float[] rgb = {0.0f,0.0f,0.0f};
int indice =0;
for (int i =0;i<h;i++) {
for (int j=0;j<w;j++) {
rgb[0] = value.getPixelArray().getElem(indice);
rgb[1] = value.getPixelArray().getElem(indice+1);
rgb[2] = value.getPixelArray().getElem(indice+2);
idx.put(i, j, 0, rgb[0]);
idx.put(i, j, 1, rgb[1]);
idx.put(i, j, 2, rgb[2]);
indice = indice+3;
}
}
// Convert the image from RGB To grayscale
cvtColor(image, image, COLOR_RGB2GRAY);
// SIFT features
SIFT sift = new SIFT().create();
KeyPointVector keypoints = new KeyPointVector();
Mat descriptors = new Mat();
sift.detect(image, keypoints);
sift.compute(image,keypoints,descriptors);
****************************CODE : END ***************************
Then, I get this error :
Error: java.lang.RuntimeException: /projects/bytedeco/javacpp-presets/opencv/cppbuild/linux-x86_64/opencv_contrib-3.2.0/modules/xfeatures2d/src/sift.cpp:770: error: (-5) image is empty or has incorrect depth (!=CV_8U) in function detectAndCompute
at org.bytedeco.javacpp.opencv_features2d$Feature2D.detect(Native Method)
at org.hipi.examples.Hbasefeatures$FeaturesMapper.map(Hbasefeatures.java:185)
at org.hipi.examples.Hbasefeatures$FeaturesMapper.map(Hbasefeatures.java:63)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
From the error, I think that the problem is that the type of opencv Mat that I give to the detect and compute methods is not the right one.
Can you tell me please if the image conversion from RGB to Grayscale isn't right ?
Have you any idea about how this opencv Mat passed to thoses methods should be ?