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

Function fast_demo

examples/computer_vision/fast.cpp:16–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace af;
15
16static void fast_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 = fast(img, 20.0f, 9, true, 0.05);
30
31 float* h_x = feat.getX().host<float>();
32 float* h_y = feat.getY().host<float>();
33
34 // Draw draw_len x draw_len crosshairs where the corners are
35 const int draw_len = 3;
36 for (size_t f = 0; f < feat.getNumFeatures(); f++) {
37 int x = h_x[f];
38 int y = h_y[f];
39 img_color(y, seq(x - draw_len, x + draw_len), 0) = 0.f;
40 img_color(y, seq(x - draw_len, x + draw_len), 1) = 1.f;
41 img_color(y, seq(x - draw_len, x + draw_len), 2) = 0.f;
42
43 // Draw vertical line of (draw_len * 2 + 1) pixels centered on the
44 // corner Set only the first channel to 1 (green lines)
45 img_color(seq(y - draw_len, y + draw_len), x, 0) = 0.f;
46 img_color(seq(y - draw_len, y + draw_len), x, 1) = 1.f;
47 img_color(seq(y - draw_len, y + draw_len), x, 2) = 0.f;
48 }
49
50 freeHost(h_x);
51 freeHost(h_y);
52
53 printf("Features found: %zu\n", feat.getNumFeatures());
54
55 if (!console) {
56 af::Window wnd("FAST Feature Detector");
57
58 // Previews color image with green crosshairs
59 while (!wnd.close()) wnd.image(img_color);
60 } else {
61 af_print(feat.getX());
62 af_print(feat.getY());
63 }
64}
65
66int main(int argc, char** argv) {
67 int device = argc > 1 ? atoi(argv[1]) : 0;

Callers 1

mainFunction · 0.85

Calls 10

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

Tested by

no test coverage detected