#include <cstdio>
#include <cstdlib>
static void susan_demo(bool console) {
if (console)
img_color =
loadImage(ASSETS_DIR
"/examples/images/square.png",
true);
else
img_color =
loadImage(ASSETS_DIR
"/examples/images/man.jpg",
true);
img_color /= 255.f;
features feat =
susan(img, 3, 32.0f, 10, 0.05f, 3);
if (!(feat.getNumFeatures() > 0)) {
printf("No features found, exiting\n");
return;
}
float* h_x = feat.getX().host<float>();
float* h_y = feat.getY().host<float>();
const int draw_len = 3;
for (size_t f = 0; f < feat.getNumFeatures(); f++) {
int x = h_x[f];
int y = h_y[f];
img_color(x, seq(y - draw_len, y + draw_len), 0) = 0.f;
img_color(x, seq(y - draw_len, y + draw_len), 1) = 1.f;
img_color(x, seq(y - draw_len, y + draw_len), 2) = 0.f;
img_color(seq(x - draw_len, x + draw_len), y, 0) = 0.f;
img_color(seq(x - draw_len, x + draw_len), y, 1) = 1.f;
img_color(seq(x - draw_len, x + draw_len), y, 2) = 0.f;
}
printf("Features found: %zu\n", feat.getNumFeatures());
if (!console) {
} else {
}
}
int main(int argc, char** argv) {
int device = argc > 1 ? atoi(argv[1]) : 0;
bool console = argc > 2 ? argv[2][0] == '-' : false;
try {
printf("** ArrayFire SUSAN Feature Detector Demo **\n\n");
susan_demo(console);
fprintf(stderr,
"%s\n", ae.
what());
throw;
}
return 0;
}
Window object to render af::arrays.
An ArrayFire exception class.
virtual const char * what() const
Returns an error message for the exception in a string format.
AFAPI features susan(const array &in, const unsigned radius=3, const float diff_thr=32.0f, const float geom_thr=10.0f, const float feature_ratio=0.05f, const unsigned edge=3)
C++ Interface for SUSAN corner detector.
AFAPI void freeHost(const void *ptr)
Free memory allocated internally by ArrayFire.
AFAPI void setDevice(const int device)
Sets the current device.
void image(const array &in, const char *title=NULL)
Renders the input array as an image to the window.
bool close()
Check if window is marked for close.
AFAPI array colorSpace(const array &image, const CSpace to, const CSpace from)
C++ Interface wrapper for colorspace conversion.
AFAPI array loadImage(const char *filename, const bool is_color=false)
C++ Interface for loading an image.
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.