包含sift算法java代碼的詞條

寫一個簡單的JAVA排序程序

// 排序

從策劃到設計制作,每一步都追求做到細膩,制作可持續(xù)發(fā)展的企業(yè)網(wǎng)站。為客戶提供網(wǎng)站設計制作、成都網(wǎng)站制作、網(wǎng)站策劃、網(wǎng)頁設計、域名申請、網(wǎng)絡空間、網(wǎng)絡營銷、VI設計、 網(wǎng)站改版、漏洞修補等服務。為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造優(yōu)易品牌,攜手廣大客戶,共同發(fā)展進步。

public class Array

{

public static int[] random(int n) //產(chǎn)生n個隨機數(shù),返回整型數(shù)組

{

if (n0)

{

int table[] = new int[n];

for (int i=0; itable.length; i++)

table[i] = (int)(Math.random()*100); //產(chǎn)生一個0~100之間的隨機數(shù)

return table; //返回一個數(shù)組

}

return null;

}

public static void print(int[] table) //輸出數(shù)組元素

{

if (table!=null)

for (int i=0; itable.length; i++)

System.out.print(" "+table[i]);

System.out.println();

}

public static void insertSort(int[] table) //直接插入排序

{ //數(shù)組是引用類型,元素值將被改變

System.out.println("直接插入排序");

for (int i=1; itable.length; i++) //n-1趟掃描

{

int temp=table[i], j; //每趟將table[i]插入到前面已排序的序列中

// System.out.print("移動");

for (j=i-1; j-1 temptable[j]; j--) //將前面較大元素向后移動

{

// System.out.print(table[j]+", ");

table[j+1] = table[j];

}

table[j+1] = temp; //temp值到達插入位置

System.out.print("第"+i+"趟: ");

print(table);

}

}

public static void shellSort(int[] table) //希爾排序

{

System.out.println("希爾排序");

for (int delta=table.length/2; delta0; delta/=2) //控制增量,增量減半,若干趟掃描

{

for (int i=delta; itable.length; i++) //一趟中若干組,每個元素在自己所屬組內(nèi)進行直接插入排序

{

int temp = table[i]; //當前待插入元素

int j=i-delta; //相距delta遠

while (j=0 temptable[j]) //一組中前面較大的元素向后移動

{

table[j+delta] = table[j];

j-=delta; //繼續(xù)與前面的元素比較

}

table[j+delta] = temp; //插入元素位置

}

System.out.print("delta="+delta+" ");

print(table);

}

}

private static void swap(int[] table, int i, int j) //交換數(shù)組中下標為i、j的元素

{

if (i=0 itable.length j=0 jtable.length i!=j) //判斷i、j是否越界

{

int temp = table[j];

table[j] = table[i];

table[i] = temp;

}

}

public static void bubbleSort(int[] table) //冒泡排序

{

System.out.println("冒泡排序");

boolean exchange=true; //是否交換的標記

for (int i=1; itable.length exchange; i++) //有交換時再進行下一趟,最多n-1趟

{

exchange=false; //假定元素未交換

for (int j=0; jtable.length-i; j++) //一次比較、交換

if (table[j]table[j+1]) //反序時,交換

{

int temp = table[j];

table[j] = table[j+1];

table[j+1] = temp;

exchange=true; //有交換

}

System.out.print("第"+i+"趟: ");

print(table);

}

}

public static void quickSort(int[] table) //快速排序

{

quickSort(table, 0, table.length-1);

}

private static void quickSort(int[] table, int low, int high) //一趟快速排序,遞歸算法

{ //low、high指定序列的下界和上界

if (lowhigh) //序列有效

{

int i=low, j=high;

int vot=table[i]; //第一個值作為基準值

while (i!=j) //一趟排序

{

while (ij vot=table[j]) //從后向前尋找較小值

j--;

if (ij)

{

table[i]=table[j]; //較小元素向前移動

i++;

}

while (ij table[i]vot) //從前向后尋找較大值

i++;

if (ij)

{

table[j]=table[i]; //較大元素向后移動

j--;

}

}

table[i]=vot; //基準值的最終位置

System.out.print(low+".."+high+", vot="+vot+" ");

print(table);

quickSort(table, low, j-1); //前端子序列再排序

quickSort(table, i+1, high); //后端子序列再排序

}

}

public static void selectSort(int[] table) //直接選擇排序

{

System.out.println("直接選擇排序");

for (int i=0; itable.length-1; i++) //n-1趟排序

{ //每趟在從table[i]開始的子序列中尋找最小元素

int min=i; //設第i個數(shù)據(jù)元素最小

for (int j=i+1; jtable.length; j++) //在子序列中查找最小值

if (table[j]table[min])

min = j; //記住最小元素下標

if (min!=i) //將本趟最小元素交換到前邊

{

int temp = table[i];

table[i] = table[min];

table[min] = temp;

}

System.out.print("第"+i+"趟: ");

print(table);

}

}

private static void sift(int[] table, int low, int high) //將以low為根的子樹調(diào)整成最小堆

{ //low、high是序列下界和上界

int i=low; //子樹的根

int j=2*i+1; //j為i結點的左孩子

int temp=table[i]; //獲得第i個元素的值

while (j=high) //沿較小值孩子結點向下篩選

{

if (jhigh table[j]table[j+1]) //數(shù)組元素比較(改成為最大堆)

j++; //j為左右孩子的較小者

if (temptable[j]) //若父母結點值較大(改成為最大堆)

{

table[i]=table[j]; //孩子結點中的較小值上移

i=j; //i、j向下一層

j=2*i+1;

}

else

j=high+1; //退出循環(huán)

}

table[i]=temp; //當前子樹的原根值調(diào)整后的位置

System.out.print("sift "+low+".."+high+" ");

print(table);

}

public static void heapSort(int[] table)

{

System.out.println("堆排序");

int n=table.length;

for (int j=n/2-1; j=0; j--) //創(chuàng)建最小堆

sift(table, j, n-1);

// System.out.println("最小堆? "+isMinHeap(table));

for (int j=n-1; j0; j--) //每趟將最小值交換到后面,再調(diào)整成堆

{

int temp = table[0];

table[0] = table[j];

table[j] = temp;

sift(table, 0, j-1);

}

}

public static void mergeSort(int[] X) //歸并排序

{

System.out.println("歸并排序");

int n=1; //已排序的子序列長度,初值為1

int[] Y = new int[X.length]; //Y數(shù)組長度同X數(shù)組

do

{

mergepass(X, Y, n); //一趟歸并,將X數(shù)組中各子序列歸并到Y中

print(Y);

n*=2; //子序列長度加倍

if (nX.length)

{

mergepass(Y, X, n); //將Y數(shù)組中各子序列再歸并到X中

print(X);

n*=2;

}

} while (nX.length);

}

private static void mergepass(int[] X, int[] Y, int n) //一趟歸并

{

System.out.print("子序列長度n="+n+" ");

int i=0;

while (iX.length-2*n+1)

{

merge(X,Y,i,i+n,n);

i += 2*n;

}

if (i+nX.length)

merge(X,Y,i,i+n,n); //再一次歸并

else

for (int j=i; jX.length; j++) //將X剩余元素復制到Y中

Y[j]=X[j];

}

private static void merge(int[] X, int[] Y, int m, int r, int n) //一次歸并

{

int i=m, j=r, k=m;

while (ir jr+n jX.length) //將X中兩個相鄰子序列歸并到Y中

if (X[i]X[j]) //較小值復制到Y中

Y[k++]=X[i++];

else

Y[k++]=X[j++];

while (ir) //將前一個子序列剩余元素復制到Y中

Y[k++]=X[i++];

while (jr+n jX.length) //將后一個子序列剩余元素復制到Y中

Y[k++]=X[j++];

}

public static void main(String[] args)

{

// int[] table = {52,26,97,19,66,8,49};//Array.random(9);{49,65,13,81,76,97,38,49};////{85,12,36,24,47,30,53,91,76};//;//{4,5,8,1,2,7,3,6};// {32,26,87,72,26,17};//

int[] table = {13,27,38,49,97,76,49,81}; //最小堆

System.out.print("關鍵字序列: ");

Array.print(table);

// Array.insertSort(table);

// Array.shellSort(table);

// Array.bubbleSort(table);

// Array.quickSort(table);

// Array.selectSort(table);

// Array.heapSort(table);

// Array.mergeSort(table);

System.out.println("最小堆序列? "+Array.isMinHeap(table));

}

//第9章習題

public static boolean isMinHeap(int[] table) //判斷一個數(shù)據(jù)序列是否為最小堆

{

if (table==null)

return false;

int i = table.length/2 -1; //最深一棵子樹的根結點

while (i=0)

{

int j=2*i+1; //左孩子

if (jtable.length)

if (table[i]table[j])

return false;

else

if (j+1table.length table[i]table[j+1]) //右孩子

return false;

i--;

}

return true;

}

}

/*

程序運行結果如下:

關鍵字序列: 32 26 87 72 26 17 8 40

直接插入排序

第1趟排序: 26 32 87 72 26 17 8 40

第2趟排序: 26 32 87 72 26 17 8 40

第3趟排序: 26 32 72 87 26 17 8 40

第4趟排序: 26 26 32 72 87 17 8 40 //排序算法穩(wěn)定

第5趟排序: 17 26 26 32 72 87 8 40

第6趟排序: 8 17 26 26 32 72 87 40

第7趟排序: 8 17 26 26 32 40 72 87

關鍵字序列: 42 1 74 25 45 29 87 53

直接插入排序

第1趟排序: 1 42 74 25 45 29 87 53

第2趟排序: 1 42 74 25 45 29 87 53

第3趟排序: 1 25 42 74 45 29 87 53

第4趟排序: 1 25 42 45 74 29 87 53

第5趟排序: 1 25 29 42 45 74 87 53

第6趟排序: 1 25 29 42 45 74 87 53

第7趟排序: 1 25 29 42 45 53 74 87

關鍵字序列: 21 12 2 40 99 97 68 57

直接插入排序

第1趟排序: 12 21 2 40 99 97 68 57

第2趟排序: 2 12 21 40 99 97 68 57

第3趟排序: 2 12 21 40 99 97 68 57

第4趟排序: 2 12 21 40 99 97 68 57

第5趟排序: 2 12 21 40 97 99 68 57

第6趟排序: 2 12 21 40 68 97 99 57

第7趟排序: 2 12 21 40 57 68 97 99

關鍵字序列: 27 38 65 97 76 13 27 49 55 4

希爾排序

delta=5 13 27 49 55 4 27 38 65 97 76

delta=2 4 27 13 27 38 55 49 65 97 76

delta=1 4 13 27 27 38 49 55 65 76 97

關鍵字序列: 49 38 65 97 76 13 27 49 55 4 //嚴書

希爾排序

delta=5 13 27 49 55 4 49 38 65 97 76

delta=2 4 27 13 49 38 55 49 65 97 76 //與嚴書不同

delta=1 4 13 27 38 49 49 55 65 76 97

關鍵字序列: 65 34 25 87 12 38 56 46 14 77 92 23

希爾排序

delta=6 56 34 14 77 12 23 65 46 25 87 92 38

delta=3 56 12 14 65 34 23 77 46 25 87 92 38

delta=1 12 14 23 25 34 38 46 56 65 77 87 92

關鍵字序列: 84 12 43 62 86 7 90 91

希爾排序

delta=4 84 7 43 62 86 12 90 91

delta=2 43 7 84 12 86 62 90 91

delta=1 7 12 43 62 84 86 90 91

關鍵字序列: 32 26 87 72 26 17

冒泡排序

第1趟排序: 26 32 72 26 17 87

第2趟排序: 26 32 26 17 72 87

第3趟排序: 26 26 17 32 72 87

第4趟排序: 26 17 26 32 72 87

第5趟排序: 17 26 26 32 72 87

關鍵字序列: 1 2 3 4 5 6 7 8

冒泡排序

第1趟排序: 1 2 3 4 5 6 7 8

關鍵字序列: 1 3 2 4 5 8 6 7

冒泡排序

第1趟排序: 1 2 3 4 5 6 7 8

第2趟排序: 1 2 3 4 5 6 7 8

關鍵字序列: 4 5 8 1 2 7 3 6

冒泡排序

第1趟排序: 4 5 1 2 7 3 6 8

第2趟排序: 4 1 2 5 3 6 7 8

第3趟排序: 1 2 4 3 5 6 7 8

第4趟排序: 1 2 3 4 5 6 7 8

第5趟排序: 1 2 3 4 5 6 7 8

關鍵字序列: 38 26 97 19 66 1 5 49

0..7, vot=38 5 26 1 19 38 66 97 49

0..3, vot=5 1 5 26 19 38 66 97 49

2..3, vot=26 1 5 19 26 38 66 97 49

5..7, vot=66 1 5 19 26 38 49 66 97

關鍵字序列: 38 5 49 26 19 97 1 66

0..7, vot=38 1 5 19 26 38 97 49 66

0..3, vot=1 1 5 19 26 38 97 49 66

1..3, vot=5 1 5 19 26 38 97 49 66

2..3, vot=19 1 5 19 26 38 97 49 66

5..7, vot=97 1 5 19 26 38 66 49 97

5..6, vot=66 1 5 19 26 38 49 66 97

關鍵字序列: 49 38 65 97 76 13 27 49

0..7, vot=49 49 38 27 13 49 76 97 65

0..3, vot=49 13 38 27 49 49 76 97 65

0..2, vot=13 13 38 27 49 49 76 97 65

1..2, vot=38 13 27 38 49 49 76 97 65

5..7, vot=76 13 27 38 49 49 65 76 97

關鍵字序列: 27 38 65 97 76 13 27 49 55 4

low=0 high=9 vot=27 4 27 13 27 76 97 65 49 55 38

low=0 high=2 vot=4 4 27 13 27 76 97 65 49 55 38

low=1 high=2 vot=27 4 13 27 27 76 97 65 49 55 38

low=4 high=9 vot=76 4 13 27 27 38 55 65 49 76 97

low=4 high=7 vot=38 4 13 27 27 38 55 65 49 76 97

low=5 high=7 vot=55 4 13 27 27 38 49 55 65 76 97

關鍵字序列: 38 26 97 19 66 1 5 49

直接選擇排序

第0趟排序: 1 26 97 19 66 38 5 49

第1趟排序: 1 5 97 19 66 38 26 49

第2趟排序: 1 5 19 97 66 38 26 49

第3趟排序: 1 5 19 26 66 38 97 49

第4趟排序: 1 5 19 26 38 66 97 49

第5趟排序: 1 5 19 26 38 49 97 66

第6趟排序: 1 5 19 26 38 49 66 97

最小堆

關鍵字序列: 81 49 76 27 97 38 49 13 65

sift 3..8 81 49 76 13 97 38 49 27 65

sift 2..8 81 49 38 13 97 76 49 27 65

sift 1..8 81 13 38 27 97 76 49 49 65

sift 0..8 13 27 38 49 97 76 49 81 65

13 27 38 49 97 76 49 81 65

sift 0..7 27 49 38 65 97 76 49 81 13

sift 0..6 38 49 49 65 97 76 81 27 13

sift 0..5 49 65 49 81 97 76 38 27 13

sift 0..4 49 65 76 81 97 49 38 27 13

sift 0..3 65 81 76 97 49 49 38 27 13

sift 0..2 76 81 97 65 49 49 38 27 13

sift 0..1 81 97 76 65 49 49 38 27 13

sift 0..0 97 81 76 65 49 49 38 27 13

最大堆

關鍵字序列: 49 65 13 81 76 27 97 38 49

sift 3..8 49 65 13 81 76 27 97 38 49

sift 2..8 49 65 97 81 76 27 13 38 49

sift 1..8 49 81 97 65 76 27 13 38 49

sift 0..8 97 81 49 65 76 27 13 38 49

97 81 49 65 76 27 13 38 49

sift 0..7 81 76 49 65 49 27 13 38 97

sift 0..6 76 65 49 38 49 27 13 81 97

sift 0..5 65 49 49 38 13 27 76 81 97

sift 0..4 49 38 49 27 13 65 76 81 97

sift 0..3 49 38 13 27 49 65 76 81 97

sift 0..2 38 27 13 49 49 65 76 81 97

sift 0..1 27 13 38 49 49 65 76 81 97

sift 0..0 13 27 38 49 49 65 76 81 97

關鍵字序列: 52 26 97 19 66 8 49

歸并排序

子序列長度n=1 26 52 19 97 8 66 49

子序列長度n=2 19 26 52 97 8 49 66

子序列長度n=4 8 19 26 49 52 66 97

關鍵字序列: 13 27 38 49 97 76 49 81 65

最小堆序列? true

*/

java opencv 怎樣確定sift 匹配結果

這幾天繼續(xù)在看Lowe大神的SIFT神作,看的眼花手腳抽筋。也是醉了!?。。嵲诳床幌氯?,來點干貨。我們知道opencv下自帶SIFT特征檢測以及MATCH匹配的庫,這些庫完全可以讓我們進行傻瓜似的操作。但實際用起來的時候還不是那么簡單。下文將對一個典型的基于OPENCV的SIFT特征點提取以及匹配的例程進行分析,并由此分析詳細的對OPENCV中SIFT算法的使用進行一個介紹。

OPENCV下SIFT特征點提取與匹配的大致流程如下:

讀取圖片-》特征點檢測(位置,角度,層)-》特征點描述的提取(16*8維的特征向量)-》匹配-》顯示

其中,特征點提取主要有兩個步驟,見上行黃子部分。下面做具體分析。

1、使用opencv內(nèi)置的庫讀取兩幅圖片

2、生成一個SiftFeatureDetector的對象,這個對象顧名思義就是SIFT特征的探測器,用它來探測衣服圖片中SIFT點的特征,存到一個KeyPoint類型的vector中。這里有必要說keypoint的數(shù)據(jù)結構,涉及內(nèi)容較多,具體分析查看opencv中keypoint數(shù)據(jù)結構分析,里面講的自認為講的還算詳細(表打我……)。簡而言之最重要的一點在于:

keypoint只是保存了opencv的sift庫檢測到的特征點的一些基本信息,但sift所提取出來的特征向量其實不是在這個里面,特征向量通過SiftDescriptorExtractor 提取,結果放在一個Mat的數(shù)據(jù)結構中。這個數(shù)據(jù)結構才真正保存了該特征點所對應的特征向量。具體見后文對SiftDescriptorExtractor 所生成的對象的詳解。

就因為這點沒有理解明白耽誤了一上午的時間。哭死!

3、對圖像所有KEYPOINT提取其特征向量:

得到keypoint只是達到了關鍵點的位置,方向等信息,并無該特征點的特征向量,要想提取得到特征向量就還要進行SiftDescriptorExtractor 的工作,建立了SiftDescriptorExtractor 對象后,通過該對象,對之前SIFT產(chǎn)生的特征點進行遍歷,找到該特征點所對應的128維特征向量。具體方法參見opencv中SiftDescriptorExtractor所做的SIFT特征向量提取工作簡單分析。通過這一步后,所有keypoint關鍵點的特征向量被保存到了一個MAT的數(shù)據(jù)結構中,作為特征。

4、對兩幅圖的特征向量進行匹配,得到匹配值。

兩幅圖片的特征向量被提取出來后,我們就可以使用BruteForceMatcher對象對兩幅圖片的descriptor進行匹配,得到匹配的結果到matches中,這其中具體的匹配方法暫沒細看,過段時間補上。

至此,SIFT從特征點的探測到最后的匹配都已經(jīng)完成,雖然匹配部分不甚了解,只掃對于如何使用OPENCV進行sift特征的提取有了一定的理解。接下來可以開始進行下一步的工作了。

附:使用OPENCV下SIFT庫做圖像匹配的例程

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

// opencv_empty_proj.cpp : 定義控制臺應用程序的入口點。

//

#include "stdafx.h"

#include opencv.hpp

#include features2d/features2d.hpp

#includenonfree/nonfree.hpp

#includelegacy/legacy.hpp

#include

using namespace std;

using namespace cv;

int _tmain(int argc, _TCHAR* argv[])

{

const char* imagename = "img.jpg";

//從文件中讀入圖像

Mat img = imread(imagename);

Mat img2=imread("img2.jpg");

//如果讀入圖像失敗

if(img.empty())

{

fprintf(stderr, "Can not load image %s\n", imagename);

return -1;

}

if(img2.empty())

{

fprintf(stderr, "Can not load image %s\n", imagename);

return -1;

}

//顯示圖像

imshow("image before", img);

imshow("image2 before",img2);

//sift特征檢測

SiftFeatureDetector siftdtc;

vectorkp1,kp2;

siftdtc.detect(img,kp1);

Mat outimg1;

drawKeypoints(img,kp1,outimg1);

imshow("image1 keypoints",outimg1);

KeyPoint kp;

vector::iterator itvc;

for(itvc=kp1.begin();itvc!=kp1.end();itvc++)

{

cout"angle:"angle"\t"class_id"\t"octave"\t"pt"\t"responseendl;

}

siftdtc.detect(img2,kp2);

Mat outimg2;

drawKeypoints(img2,kp2,outimg2);

imshow("image2 keypoints",outimg2);

SiftDescriptorExtractor extractor;

Mat descriptor1,descriptor2;

BruteForceMatcherL2 matcher;

vector matches;

Mat img_matches;

extractor.compute(img,kp1,descriptor1);

extractor.compute(img2,kp2,descriptor2);

imshow("desc",descriptor1);

coutendldescriptor1endl;

matcher.match(descriptor1,descriptor2,matches);

drawMatches(img,kp1,img2,kp2,matches,img_matches);

imshow("matches",img_matches);

//此函數(shù)等待按鍵,按鍵盤任意鍵就返回

waitKey();

return 0;

}

關于動態(tài)實現(xiàn)

/**

根據(jù)你需要java的要求, 寫了一個實現(xiàn)。

這個是一個整數(shù)最小優(yōu)先的堆,只實現(xiàn)了加入功能。

應該還有刪除,清空等功能,但并不是必須的。

你可以自己嘗試實現(xiàn)。

測試為生成一組隨機數(shù),加入隊列,每次加入后都察看一下堆的最優(yōu)先元素是多少。

如果還有疑問 ,

至郵件:tazerkinq@163.com

*/

public class Heap {

int[] heap; //堆的儲存空間

int size; //當前的元素的數(shù)量

Heap() {

size = 0; //初始化數(shù)量為0

heap = new int[1024]; //預留空間1024,為了操作方便,0位置被棄用

}

void add(int e){ //加入新的元素,也是維護堆的主要地方之一

int i = ++size; //數(shù)量增加一, 并用臨時變量記錄此位置

while(( 1i ) ( eheap[i/2] )){ //判斷e是否小于父節(jié)點的元素, 如否,則停止

heap[i] = heap[i/2]; //如是, 則移動父節(jié)點元素當i記錄位置

i/=2; //i繼續(xù)向上迭代,指向剛才父節(jié)點的位置

}

heap[i] = e; //該位置即為元素最終位置

}

int peek(){ //返回堆頭的元素

return heap[1]; //數(shù)組下標1的元素即是

} //當然如果當前元素為空的話,返回的則是初始值

int size(){ //返回當前元素數(shù)目

return size;

}

public static void main(String[] args) {

Heap h = new Heap();

for(int i=0;i100;i++){

int k=(int)(10000*Math.random()); //隨機生成一個整數(shù)

h.add(k); //加入到堆中

System.out.printf(

"Currently adding number is %5d.\t"+

"Currently priority number is %5d.%n",k,h.peek()); //輸出生成的隨機數(shù),并且輸出該堆的優(yōu)先元素

}

}

}

網(wǎng)上找到的SIFT特征提取代碼,怎么使用

哈哈,我有一個基于opencv實現(xiàn)的sift,我把代碼貼出來,你自己看看吧~~~

void sift_detector_and_descriptors(IplImage* i_left,IplImage* i_right)

{

Mat mat_image_left=Mat(i_left,false);

Mat mat_image_right=Mat(i_right,false);

cv::SiftFeatureDetector *pDetector=new cv::SiftFeatureDetector;

pDetector-detect(mat_image_left,left_key_point);

pDetector-detect(mat_image_right,right_key_point);

Mat left_image_descriptors,right_image_descriptors;

cv::SiftDescriptorExtractor *descriptor_extractor=new cv::SiftDescriptorExtractor;

descriptor_extractor-compute(mat_image_left,left_key_point,left_image_descriptors);

descriptor_extractor-compute(mat_image_right,right_key_point,right_image_descriptors);

Mat result_l,result_r;

drawKeypoints(mat_image_left,left_key_point,result_l,Scalar::all(-1),0);

drawKeypoints(mat_image_right,right_key_point,result_r,Scalar::all(-1),0);

//imshow("result_of_left_detector_sift",result_l);

//imshow("result_of_right_detector_sift",result_r);

Mat result_of_sift_match;

BruteForceMatcherL2float matcher;

matcher.match(left_image_descriptors,right_image_descriptors,result_of_point_match);

drawMatches(mat_image_left,left_key_point,mat_image_right,right_key_point,result_of_sift_match,result_of_sift_match);

imshow("matches_of_sift",result_of_sift_match);

imwrite("matches_of_sift.jpg",result_of_sift_match);

}

void main()

{

IplImage *n_left_image=cvLoadImage("D:\\lena.jpg");

IplImage *n_right_image=cvLoadImage("D:\\lena_r.jpg");

sift_detector_and_descriptors(n_left_image,n_right_image);

cvWaitKey(0);

}

這就是核心代碼了,至于opencv所要用到的庫,你自己弄一下吧,每個人的opencv版本不一樣,這個都市不同的,希望能夠幫到你~

分享題目:包含sift算法java代碼的詞條
文章起源:http://muchs.cn/article10/ddciddo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設、App開發(fā)商城網(wǎng)站、網(wǎng)站改版、電子商務、企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設