diff --git a/CMakeLists.txt b/CMakeLists.txt index 469a3097193526c33f1ae1f7e93c73ec8988d564..376b06b36dcaa0450f21629f4ac17046fa1b3f56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,7 +377,11 @@ add_subdirectory(components/calibration) #add_subdirectory(applications/recorder) #add_subdirectory(applications/merger) add_subdirectory(applications/tools) -add_subdirectory(SDK/C) + +# SDK only compiles on linux currently +if (NOT WIN32) + add_subdirectory(SDK/C) +endif() if (HAVE_AVFORMAT) add_subdirectory(applications/ftl2mkv) diff --git a/SDK/C/CMakeLists.txt b/SDK/C/CMakeLists.txt index 7d6e3d6c055b7625f36ee4e4a86f00efc2068a52..e34a99214a897f32ef913c48750bad392e5400cc 100644 --- a/SDK/C/CMakeLists.txt +++ b/SDK/C/CMakeLists.txt @@ -19,3 +19,4 @@ install(TARGETS ftl-dev PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) add_subdirectory(examples/image_write) +add_subdirectory(examples/video_write) diff --git a/SDK/C/examples/video_write/CMakeLists.txt b/SDK/C/examples/video_write/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b0048d762a858ef7779df5a71f40774eb1bf3d60 --- /dev/null +++ b/SDK/C/examples/video_write/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(video_write main.cpp) +target_link_libraries(video_write ftl-dev) diff --git a/SDK/C/examples/video_write/main.cpp b/SDK/C/examples/video_write/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..94cd6fa72f8b6ff30ecf4e46ee1ed52b1309aaa7 --- /dev/null +++ b/SDK/C/examples/video_write/main.cpp @@ -0,0 +1,42 @@ +#include <ftl/ftl.h> +#include <opencv2/core/mat.hpp> +#define LOGURU_REPLACE_GLOG 1 +#include <loguru.hpp> + +#include <Eigen/Eigen> + +static void ftlCheck(ftlError_t err) { + if (err != FTLERROR_OK) { + LOG(ERROR) << "FTL Stream Error: " << err; + exit(-1); + } +} + +int main(int argc, char **argv) { + ftlStream_t s = ftlCreateWriteStream("./out.ftl"); + if (!s) ftlCheck(ftlGetLastStreamError(s)); + + ftlCheck(ftlSetFrameRate(s, 20.0f)); + + // Two test frames, red and green + cv::Mat test_image1(720, 1280, CV_8UC4, cv::Scalar(0,0,255,255)); + cv::Mat test_image2(720, 1280, CV_8UC4, cv::Scalar(0,255,0,255)); + + ftlCheck(ftlIntrinsicsWriteLeft(s, 0, 1280, 720, 300.0f, -1280.0f/2.0f, -720.0f/2.0f, 0.1f, 0.1f, 8.0f)); + + // Write a number of frames, alternating images + for (int i=0; i<100; ++i) { + if (i&1) { + ftlCheck(ftlImageWrite(s, 0, FTLCHANNEL_Colour, FTLIMAGE_BGRA, test_image2.step, test_image2.data)); + } else { + ftlCheck(ftlImageWrite(s, 0, FTLCHANNEL_Colour, FTLIMAGE_BGRA, test_image1.step, test_image1.data)); + } + + ftlCheck(ftlNextFrame(s)); + } + + + ftlCheck(ftlDestroyStream(s)); + + return 0; +} diff --git a/SDK/C/src/streams.cpp b/SDK/C/src/streams.cpp index 9eae26243c15d8be61ab4a1d8f0555506bbe0fe6..e9dc6ff0791491889619d3eb113201a10d0343fd 100644 --- a/SDK/C/src/streams.cpp +++ b/SDK/C/src/streams.cpp @@ -241,9 +241,12 @@ ftlError_t ftlNextFrame(ftlStream_t stream) { f.reset(); f.setOrigin(&stream->video_states[i]); } - stream->video_fs.count = 0; - stream->video_fs.mask = 0; + + // FIXME: These should be reset each time + //stream->video_fs.count = 0; + //stream->video_fs.mask = 0; stream->video_fs.timestamp += stream->interval; + stream->has_fresh_data = false; return FTLERROR_OK; }