Created
March 16, 2016 14:01
-
-
Save nyatla/9c0d851cd4ee72747e2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FreakKeyPointTest extends AwtSketch{ | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) | |
{ | |
try { | |
new FreakKeyPointTest().run(); | |
} catch (Exception e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
@Override | |
public void setup(Frame i_frame, Canvas i_canvas) throws Exception { | |
int H=480,W=640; | |
INyARGrayscaleRaster gs=NyARGrayscaleRaster.createInstance(W,H); | |
//試験画像の準備 | |
NyARBufferedImageRaster rgb=NyARBufferedImageRaster.createFromFile("d:\\sample.jpg"); | |
INyARRgb2GsFilterRgbAve filter=(INyARRgb2GsFilterRgbAve) rgb.createInterface(INyARRgb2GsFilterRgbAve.class); | |
filter.convert(gs); | |
DogFeaturePointStack _dog_feature_points = new DogFeaturePointStack(1000); | |
FREAKExtractor mFeatureExtractor=new FREAKExtractor(); | |
int octerves=BinomialPyramid32f.octavesFromMinimumCoarsestSize(W,H,8); | |
BinomialPyramid32f _pyramid=new BinomialPyramid32f(W,H,octerves,3); | |
DoGScaleInvariantDetector _dog_detector = new DoGScaleInvariantDetector(W,H,octerves,3,3,4,300); | |
query_keypoint = new FreakFeaturePointStack(300); | |
//Freak Extract | |
// Build the pyramid | |
_pyramid.build(gs); | |
// Detect feature points | |
_dog_detector.detect(_pyramid,_dog_feature_points); | |
// Extract features | |
query_keypoint.clear(); | |
mFeatureExtractor.extract(_pyramid,_dog_feature_points,query_keypoint); | |
this._bg=rgb.getBufferedImage(); | |
} | |
FreakFeaturePointStack query_keypoint; | |
BufferedImage _bg; | |
@Override | |
public void draw(Canvas i_canvas) throws Exception { | |
Graphics g=i_canvas.getGraphics(); | |
g.drawImage(_bg,0,0,this._frame); | |
g.setColor(Color.red); | |
for(int i=0;i<query_keypoint.getLength();i++){ | |
FreakFeaturePoint p=query_keypoint.getItem(i); | |
int s=(int)p.scale*10; | |
int h=(int)p.scale*10; | |
g.drawArc((int)p.x-s/2,(int)p.y-s/2,s,s,0,360); | |
} | |
g.dispose(); | |
// TODO Auto-generated method stub | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment