I'm trying to implement with FFI a few functions from the Darknet library:
require 'ffi'
class Image < FFI::Struct
layout :w, :int
layout :h, :int
layout :c, :int
layout :data, :pointer
end
class Darknet
extend FFI::Library
ffi_lib "./libdarknet.so"
attach_function :load_image_color, [:string, :int, :int], Image
end
image = Darknet.load_image_color("./test.jpg", 0, 0)
It seems that the filename string doesn't get through:
Cannot load image "(null)"
STB Reason: can't fopen
Here are the function and the declaration.
I'm quite new to FFI, but I've managed to implement other functions without any issue. I must be missing something obvious, if someone can give me pointers (no pun intended)...