Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

private class Correspond extends AsyncTask<Integer, Integer, Bitmap> { amru idnColl = new amru(); long a=0; double thresh;

protected Bitmap doInBackground(Integer... id) { String imgPath = new String(Environment.getExternalStorageDirectory() +"/images/make_machine_example.jpg"); SurfInfo info01 = surflib.surfify(imgPath, OpenASURF.this,false); SurfInfo info02 = surflib.surfify(R.drawable.testcorrelation02, OpenASURF.this,false); SurfInfo info03 = surflib.surfify(R.drawable.testcorrelation03, OpenASURF.this,false); idnColl = surflib.findMatchs(imgPath, info02.id, info03.id); IpointVector points; if(idnColl.getImgId(2) == info02.id) { points = info02.surf.getIpts(); } else if(idnColl.getImgId(2) == info03.id) { points = info03.surf.getIpts(); } else {points = null;} a = points.size(); thresh = (double) idnColl.getImgMatch().size() / (double) points.size(); return info01.outputBitmap; }

class amru { int inpid1,inpid2; String matchedURL; IpPairVector match; public int getImgId(int idImg) { if(idImg == 1) return inpid1; else if(idImg==2) return inpid2; else return -1; } public IpPairVector getImgMatch() { return match; } amru(int inpImg2,IpPairVector inpMatch, String maURL) { this.inpid2 = inpImg2; this.match = inpMatch; this.matchedURL = maURL; } public String getmaURL() { return matchedURL; } amru(){} }

public amru findMatchs(String memcard, int id2,int id3){ if(!surfmap2.containsKey(memcard)|| !surfmap.containsKey(id2)|| ! surfmap.containsKey(id3)){ return null; } IpointVector ipts1 = surfmap2.get(memcard).surf.getIpts(); IpointVector ipts2 = surfmap.get(id2).surf.getIpts(); IpointVector ipts3 = surfmap.get(id3).surf.getIpts(); IpPairVector matches = new IpPairVector(); IpPairVector matches2 = new IpPairVector(); surfjnimodule.getMatches(ipts1, ipts2, matches); surfjnimodule.getMatches(ipts1, ipts3, matches2); if(matches.size() > matches2.size()) {amru result1 = new amru(id2,matches,"/conf2/index.html"); return result1;} else {amru result1 = new amru(id3,matches2,"/ak2.html"); return result1;} } }

public SurfInfo surfify(int rid, Context ctx){ return surfify(rid, ctx, true); } public SurfInfo surfify(String memcard, Context ctx){ return surfify(memcard, ctx, true); } public SurfInfo surfify(String memcard, Context ctx, boolean draw){ // Bitmap bmp = loadBitmapFromResource(rid,ctx); String entirePath = new String(Environment.getExternalStorageDirectory() +"/images/make_machine_example.jpg"); Bitmap bmp = BitmapFactory.decodeFile(entirePath); int width = bmp.getWidth(); int height = bmp.getHeight(); int[] pixels = new int[width * height]; bmp.getPixels(pixels, 0, width, 0, 0, width, height); SURFjni surf = new SURFjni(pixels, width, height); surf.surfDetDes(false, 4, 4, 2, 0.0002f); SurfInfo info = new SurfInfo(surf, bmp, entirePath); if(draw) DrawSurfPoints(info,0,null); surfmap2.put(entirePath, info); return info;

You might also like