Skip to content

Commit

Permalink
Fix exportation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnes committed May 19, 2017
1 parent 893688b commit 3ef0e7d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions svo recording/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ IF(WIN32) # Windows
message(FATAL_ERROR "You've selected the 32bit version of ${CMAKE_GENERATOR}. \n Please delete the cache (file->Delete Cache) and use the 64bit version. (${CMAKE_GENERATOR} Win64)")
endif()
ELSE() # Linux
find_package(ZED 2.0 REQUIRED)
find_package(ZED 2 REQUIRED)

##For Jetson, OpenCV4Tegra is based on OpenCV2.4
exec_program(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_NAME2)
Expand All @@ -40,7 +40,7 @@ ELSE() # Linux
SET(SPECIAL_OS_LIBS "pthread" "X11")
ENDIF(WIN32)

find_package(OpenCV ${VERSION_REQ_OCV} REQUIRED)
find_package(OpenCV REQUIRED)
find_package(CUDA ${VERSION_REQ_CUDA} REQUIRED)

include_directories(${CUDA_INCLUDE_DIRS})
Expand Down
4 changes: 2 additions & 2 deletions svo recording/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Open a terminal in build directory and execute the following command:

Example :

./ZED_SVO_Recording -f="./mysvo.svo" -v="./mysvo_converted.avi" -z
./ZED_SVO_Recording -f="./mysvo.svo" -o="./mysvo_converted.avi" -z

**NOTE :** Make sure you put a '=' between the option and the argument.

Expand All @@ -41,7 +41,7 @@ Option | Descriptions |
-----------------------------------------|----------------------------------------|-----------------------------------------------------
--help | Display help message. |
-f, --filename | SVO input filename | Path to an input SVO file
-v, --video | Name of the output file, Left+Disparity with -z option, Left+Right otherwise | filename with ".avi" extension for a video file, if no extension is given a sequence of images is then recorded (png file)
-o, --output | Name of the output file, Left+Disparity with -z option, Left+Right otherwise | filename with ".avi" extension for a video file, if no extension is given a sequence of images is then recorded (png file)
-z, --disparity | Compute disparity |

## Troubleshooting
Expand Down
4 changes: 3 additions & 1 deletion svo recording/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ int main(int argc, char **argv) {
sl::InitParameters initParameters;
if (!modes.recordingMode) initParameters.svo_input_filename = modes.svo_path.c_str();
else initParameters.camera_fps = 30;
initParameters.svo_real_time_mode = true;

if (!modes.computeDisparity) initParameters.depth_mode = sl::DEPTH_MODE_NONE;

Expand Down Expand Up @@ -80,7 +81,7 @@ int main(int argc, char **argv) {

// Enter main loop
while (key != 'q') {
if (!zed.grab()) {
if (zed.grab() == sl::SUCCESS) {

// Get the side by side image
zed.retrieveImage(view, sl::VIEW_SIDE_BY_SIDE);
Expand All @@ -102,6 +103,7 @@ int main(int argc, char **argv) {
//Check if we are at the end of the svo file, then close the actions (close the avi file for example) and exit the while loop
if (zed.getSVOPosition() >= (zed.getSVONumberOfFrames() - 2)) { // end of SVO
exitActions();
std::cout<<"Finished... exiting now"<<std::endl;
break;
}
}
Expand Down
25 changes: 21 additions & 4 deletions svo recording/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,36 @@ void parse_args(int argc, char **argv, InfoOption &info) {
}

void initActions(sl::Camera *zed, InfoOption &modes) {
if (modes.videoMode && !video_writer) video_writer = new cv::VideoWriter(modes.output_path, CV_FOURCC('M', '4', 'S', '2'), 25,
if (!zed->isOpened())
return;

//get SVO FPS to have the same in opencv video file.
int svo_fps = (int)zed->getCameraFPS();

//security
if (svo_fps<=0)
svo_fps = 25;

int fourcc = CV_FOURCC('M', '4', 'S', '2');

if (modes.videoMode && !video_writer) video_writer = new cv::VideoWriter(modes.output_path, fourcc, svo_fps,
cv::Size(zed->getResolution().width * 2, zed->getResolution().height));
else image_name = modes.output_path;

buff.alloc(zed->getResolution().width * 2, zed->getResolution().height, sl::MAT_TYPE_8U_C3);
}

void exitActions() {
if (video_writer) delete video_writer;
if (video_writer)
{
video_writer->release();
delete video_writer;
}
}

void recordVideo(sl::Mat &image) {

video_writer->write(cv::Mat(image.getHeight(), image.getWidth(), CV_8UC4, image.getPtr<sl::uchar1>(sl::MEM_CPU)));
video_writer->write(cv::Mat(image.getHeight(), image.getWidth(), CV_8UC3, image.getPtr<sl::uchar1>(sl::MEM_CPU)));
}

void recordImages(sl::Mat &image) {
Expand All @@ -122,8 +138,9 @@ void generateImageToRecord(sl::Camera *zed, InfoOption &modes, sl::Mat &out) {
tmp_cv.copyTo(sbsIm(cv::Rect(0, 0, zed->getResolution().width, zed->getResolution().height)));
tmp_cv = cv::Mat(rightIm.getHeight(), rightIm.getWidth(), CV_8UC4, rightIm.getPtr<sl::uchar1>(sl::MEM_CPU));
tmp_cv.copyTo(sbsIm(cv::Rect(zed->getResolution().width, 0, zed->getResolution().width, zed->getResolution().height)));
tmp_cv = cv::Mat(out.getHeight(), out.getWidth(), CV_8UC4, out.getPtr<sl::uchar1>(sl::MEM_CPU));
tmp_cv = cv::Mat(out.getHeight(), out.getWidth(), CV_8UC3, out.getPtr<sl::uchar1>(sl::MEM_CPU));
cv::cvtColor(sbsIm, tmp_cv, CV_RGBA2RGB);

}

void manageActions(sl::Camera *zed, char &key, InfoOption &modes) {
Expand Down

0 comments on commit 3ef0e7d

Please sign in to comment.