我的项目是使用 OpenCV 库识别 Android 上的叶子。我使用ORB检测来获取图像的关键点并使用ORB描述符来获取关键点的特征。这是我使用的代码:
bmp=BitmapFactory.decodeResource(getResources(),R.drawable.t1);
Utils.bitmapToMat(bmp, mat);
FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
detector.detect(mat, keypoints);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
extractor.compute(mat, keypoints, features);
Run Code Online (Sandbox Code Playgroud)
来源:http : //answers.opencv.org/question/6260/orb-features/
但是每次我输入相同的图像,该图像的关键点总是不同的。如果总是不同,我可以将关键点的特征保存到数据库吗?或者我应该保存图像以保存特征数据?如果可以保存到数据库,我该怎么做??
我完成了获得灰度值,但我不知道如何使用函数将灰度转换为二进制图像.请帮帮我,这里是我的功能代码:
public Bitmap toBinary(Bitmap bmpOriginal) {
int width, height, threshold;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
threshold = 127;
final Bitmap bmpBinary = null;
for(int x = 0; x < width; ++x) {
for(int y = 0; y < height; ++y) {
// get one pixel color
int pixel = bmpOriginal.getPixel(x, y);
//get grayscale value
int gray = (int)(pixel & 0xFF);
//get binary value
if(gray < threshold){
bmpBinary.setPixel(x, y, 0);
} else{
bmpBinary.setPixel(x, y, 255);
}
}
}
return bmpBinary; …Run Code Online (Sandbox Code Playgroud) 我的项目是基于android的草药识别.我使用ORB来获取关键点,功能和匹配功能.
我想用这个算法:
{
for (j=MinID; j<=MaxID; j++){
MatOfDMatch matches = DetectUtility.match(features, matFromJson(DB.GetORBFitur(j)));
List<DMatch> matchesList = matches.toList();
Double max_dist = 0.0;
Double min_dist = 100.0;
for (int i = 0; i < matchesList.size(); i++){
Double dist = (double) matchesList.get(i).distance;
if (dist < min_dist && dist != 0){
min_dist = dist;
}
if (dist > max_dist){
max_dist = dist;
}
}
Run Code Online (Sandbox Code Playgroud)
从这个网站,我得到这个代码:
//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
std::vector< …Run Code Online (Sandbox Code Playgroud)