<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ?本文來自[http://blog.csdn.net/hellogv/](http://blog.csdn.net/hellogv/) ,引用必須注明出處! 今晚是平安夜,跟眾多四眼技術宅一樣,這個時候還是跟電腦過節![](https://box.kancloud.cn/2016-06-24_576cb0a29f6c3.gif) ...... 上次講解了在[Android上通過NDK把彩圖轉換為灰度圖](http://blog.csdn.net/hellogv/archive/2010/12/23/6094127.aspx),現在可以把[WindowsMobile版的ASIFT 例子](http://blog.csdn.net/hellogv/archive/2010/12/20/6087937.aspx)移植到Android上了.......在這里還是要再次感謝Jean-Michel Morel和Guoshen Yu兩位大牛的無私奉獻,尊重知識尊重開源精神。 先來看看本文程序運行截圖: ![](https://box.kancloud.cn/2016-06-24_576cb0a2b3fc6.gif) ?![](https://box.kancloud.cn/2016-06-24_576cb0a2d2335.gif) 左圖是設定識別率為最低的結果,右圖是設定識別率為較低的結果。 本文的代碼可以到這里下載:[http://www.pudn.com/downloads314/sourcecode/comm/android/detail1391871.html](http://www.pudn.com/downloads314/sourcecode/comm/android/detail1391871.html) 這里ASIFT的NDK代碼(C++)跟WM篇的DLL代碼大體一樣,不過也存在一些不同: 1、JNI不支持引用傳遞,所以有些值必須通過函數返回,例如: ~~~ /** * 取得放大/縮小之后的圖像大小 */JNIEXPORT jintArray JNICALL Java_com_testASIFT_LibASIFT_GetZoomSize( JNIEnv* env, jobject obj) { jint arrint[2]; arrint[0] = IM_X; arrint[1] = IM_Y; jintArray result = env->NewIntArray(2); env->SetIntArrayRegion(result, 0, 2, arrint); return result;}/** * 返回匹配后圖像的大小 jintArray[0]為width, jintArray[1]為height */JNIEXPORT jintArray JNICALL Java_com_testASIFT_LibASIFT_GetMatchedImageSize( JNIEnv* env, jobject obj) { jint arrint[2]; arrint[0] = wo; arrint[1] = ho; jintArray result = env->NewIntArray(2); env->SetIntArrayRegion(result, 0, 2, arrint); return result;} ~~~ 2、ASIFT接受的是8bit的灰度圖,使用前要轉換為8bit的灰度圖: ~~~ void PixelToVector(jint *cbuf, int w, int h, std::vector<float> *ipixels) { for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { // 獲得像素的顏色 int color = cbuf[w * i + j]; int red = ((color & 0x00FF0000) >> 16); int green = ((color & 0x0000FF00) >> 8); int blue = color & 0x000000FF; color = (red + green + blue) / 3; ipixels->push_back(color);//保存灰度值 } }} ~~~ 使用后要把8bit灰度圖轉為RGB565: ~~~ jintArray result = env->NewIntArray(wo * ho); jint *cResult; cResult = env->GetIntArrayElements(result, false); int alpha = 0xFF << 24; for (int i = 0; i < ho; i++) { for (int j = 0; j < wo; j++) { // 獲得像素的顏色 int color = (int) opixelsASIFT[wo * i + j]; color = alpha | (color << 16) | (color << 8) | color; cResult[wo * i + j] = color; } } env->ReleaseIntArrayElements(result, cResult, 0); ~~~ 主類testASIFT.java的邏輯代碼如下: ~~~ public class testASIFT extends Activity { /** Called when the activity is first created. */ ImageView imgView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.setTitle("Android上使用ASIFT---hellogv"); imgView=(ImageView)this.findViewById(R.id.ImageView01); LibASIFT.initZoomSize(320, 480);//縮放目標的大小 int []size=LibASIFT.GetZoomSize();//判斷是否設置成功 Log.e(String.valueOf(size[0]),String.valueOf(size[1])); Bitmap img1=((BitmapDrawable) getResources().getDrawable(R.drawable.adam1)).getBitmap(); int w1=img1.getWidth(),h1=img1.getHeight(); int[] pix1 = new int[w1 * h1]; img1.getPixels(pix1, 0, w1, 0, 0, w1, h1); //提取第一張圖片的特征點 LibASIFT.initImage1(pix1, w1, h1, 2); Bitmap img2=((BitmapDrawable) getResources().getDrawable(R.drawable.adam2)).getBitmap(); int w2=img2.getWidth(),h2=img2.getHeight(); int[] pix2 = new int[w2 * h2]; img2.getPixels(pix2, 0, w2, 0, 0, w2, h2); int[] imgPixels=LibASIFT.Match2ImageForImg(pix2, w2, h2, 2);//兩圖匹配 int[] imgSize=LibASIFT.GetMatchedImageSize();//匹配結果圖的大小 Bitmap imgResult=Bitmap.createBitmap(imgSize[0], imgSize[1], Config.RGB_565); imgResult.setPixels(imgPixels, 0, imgResult.getWidth(), 0, 0, imgResult.getWidth(), imgResult.getHeight()); imgView.setImageBitmap(imgResult);//顯示結果 }} ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看