Skip to content
Snippets Groups Projects
Commit 2b114eab authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Add working video example

parent 4ceb8a27
No related branches found
No related tags found
1 merge request!289C SDK for writing FTL files
Pipeline #22986 passed
......@@ -377,7 +377,11 @@ add_subdirectory(components/calibration)
#add_subdirectory(applications/recorder)
#add_subdirectory(applications/merger)
add_subdirectory(applications/tools)
# SDK only compiles on linux currently
if (NOT WIN32)
add_subdirectory(SDK/C)
endif()
if (HAVE_AVFORMAT)
add_subdirectory(applications/ftl2mkv)
......
......
......@@ -19,3 +19,4 @@ install(TARGETS ftl-dev
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
add_subdirectory(examples/image_write)
add_subdirectory(examples/video_write)
add_executable(video_write main.cpp)
target_link_libraries(video_write ftl-dev)
#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;
}
......@@ -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;
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment