Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature.write frames #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PROJECT (CaroloCup-CameraPlayback)
###########################################################################
# Set the search path for .cmake files.
SET (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake.Modules" ${CMAKE_MODULE_PATH})
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11)

###########################################################################
# Find OpenDaVINCI.
Expand Down
23 changes: 19 additions & 4 deletions CaroloCup-CameraPlayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <fstream>
#include <string>
#include <sstream>
#include <iomanip>

#include <opencv/cv.h>
#include <opencv/highgui.h>
Expand Down Expand Up @@ -111,6 +112,7 @@ int32_t main(int32_t argc, char **argv)
uint32_t retVal = 0;
int recIndex=1;
bool log=false;
bool writeFrames = true;

if((argc != 2 && argc != 3 && argc != 4) || (argc==4 && string(argv[1]).compare("-l")!=0))
{
Expand Down Expand Up @@ -182,7 +184,7 @@ int32_t main(int32_t argc, char **argv)
frameMessage.str(string());
VPMessage.str(string());
bool fbf=false;

// Main data processing loop.
while (player.hasMoreData()) {
// Read next entry from recording.
Expand Down Expand Up @@ -216,6 +218,19 @@ int32_t main(int32_t argc, char **argv)
}
}

// write image to file
if(writeFrames) {
std::ostringstream filename;
filename << std::setfill('0') << std::setw(8) << frameNumber << ".png";

std::cerr << "Writing to: " << filename.str() << std::endl;

cv::Mat img = cvarrToMat(image);

// write with maximum png compression
cv::imwrite(filename.str(), img, std::vector<int>{CV_IMWRITE_PNG_COMPRESSION, 9});
}

// Show the image using OpenCV.

// if csv parameter is set
Expand All @@ -226,12 +241,12 @@ int32_t main(int32_t argc, char **argv)
if(! row.readNextRow(file)) break;

sscanf(row[0].c_str(), "%d", &csvFN);

if(frameNumber==csvFN)
{
Mat img = cvarrToMat(image);


frameMessage.str(string());
VPMessage.str(string());
sscanf(row[9].c_str(), "%d", &VPx);
Expand Down