MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / susan_demo

Function susan_demo

examples/computer_vision/susan.cpp:16–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace af;
15
16static void susan_demo(bool console) {
17 // Load image
18 array img_color;
19 if (console)
20 img_color = loadImage(ASSETS_DIR "/examples/images/square.png", true);
21 else
22 img_color = loadImage(ASSETS_DIR "/examples/images/man.jpg", true);
23 // Convert the image from RGB to gray-scale
24 array img = colorSpace(img_color, AF_GRAY, AF_RGB);
25 // For visualization in ArrayFire, color images must be in the [0.0f-1.0f]
26 // interval
27 img_color /= 255.f;
28
29 features feat = susan(img, 3, 32.0f, 10, 0.05f, 3);
30
31 if (!(feat.getNumFeatures() > 0)) {
32 printf("No features found, exiting\n");
33 return;
34 }
35
36 float* h_x = feat.getX().host<float>();
37 float* h_y = feat.getY().host<float>();
38
39 // Draw draw_len x draw_len crosshairs where the corners are
40 const int draw_len = 3;
41 for (size_t f = 0; f < feat.getNumFeatures(); f++) {
42 int x = h_x[f];
43 int y = h_y[f];
44 img_color(x, seq(y - draw_len, y + draw_len), 0) = 0.f;
45 img_color(x, seq(y - draw_len, y + draw_len), 1) = 1.f;
46 img_color(x, seq(y - draw_len, y + draw_len), 2) = 0.f;
47
48 // Draw vertical line of (draw_len * 2 + 1) pixels centered on the
49 // corner Set only the first channel to 1 (green lines)
50 img_color(seq(x - draw_len, x + draw_len), y, 0) = 0.f;
51 img_color(seq(x - draw_len, x + draw_len), y, 1) = 1.f;
52 img_color(seq(x - draw_len, x + draw_len), y, 2) = 0.f;
53 }
54 freeHost(h_x);
55 freeHost(h_y);
56
57 printf("Features found: %zu\n", feat.getNumFeatures());
58
59 if (!console) {
60 af::Window wnd("FAST Feature Detector");
61
62 // Previews color image with green crosshairs
63 while (!wnd.close()) wnd.image(img_color);
64 } else {
65 af_print(feat.getX());
66 af_print(feat.getY());
67 af_print(feat.getScore());
68 }
69}
70
71int main(int argc, char** argv) {
72 int device = argc > 1 ? atoi(argv[1]) : 0;

Callers 1

mainFunction · 0.85

Calls 11

loadImageFunction · 0.85
colorSpaceFunction · 0.85
seqClass · 0.85
freeHostFunction · 0.85
getNumFeaturesMethod · 0.80
getXMethod · 0.80
getYMethod · 0.80
closeMethod · 0.80
imageMethod · 0.80
getScoreMethod · 0.80
susanFunction · 0.50

Tested by

no test coverage detected