- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, please let me know if I should post this in a different topic, but I cannot save video at 60 fps through opencv-libsense with an intel realsense D435. It simply saves the video at twice the speed. I originally tried only using opencv's videocapture method, but now I use the librealsense sdk to pass through opencv, but the videocapture method does not save video at 60 fps. Below is my code. Please ignore the several includes and comments, I have been working on this issue for a few weeks and have tried a variety of different methods:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include "opencv2/videoio.hpp"
#include <opencv2/video.hpp>
#include "opencv2/imgcodecs.hpp"
#include "opencv2/opencv.hpp"
#include <iostream>
#include <string.h>
#include <limits.h>
#include <chrono>
#include <opencv2/core/utils/logger.
#include <librealsense2/rs.hpp>
#include <vector>
//#include <opencv2/videoio/registry.hpp>
using namespace cv;
using namespace std;
using namespace utils;
using namespace logging;
using namespace rs2;
LogLevel setLogLevel(LogLevel LOG_LEVEL_SILENT);
//LogLevel(LOG_LEVEL_SILENT);
chrono::high_resolution_clock:
int main(int argc, char** argv)
{
//rs2::log_to_console(RS2_LOG_
rs2::context ctx;
rs2::device_list devices_list = ctx.query_devices();
rs2::device device;
for (auto&& dev : devices_list)
{
device = dev;
}
rs2::sensor sensor = device.query_sensors().front()
//auto sensor = prof.get_device().first<
//cout << sensor.get_option(RS2_OPTION_
//sensor.set_option(RS2_
config cfg;
cfg.enable_stream(RS2_STREAM_
rs2::pipeline pipe;
auto prof = pipe.start(cfg);
rs2::pipeline_profile profile = pipe.get_active_profile();
auto colorSensor = profile.get_device().query_
colorSensor.set_option(RS2_
cout << colorSensor.get_option(RS2_
const auto window_name = "Display Image";
namedWindow(window_name, WINDOW_AUTOSIZE);
//VideoCapture cap(1);
VideoWriter video;
string vidname = "trial.avi";
//cap.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G'));
video.open(vidname, codec, 60, Size(640, 480));
std::cout << " test for post camera load" << endl;
//make sure it opens, if not exit
/*if (!cap.isOpened()) {
std::cout << "COULDN'T OPEN CAMERA.\n" << endl;
return -1;
}
int fps = cap.get(CAP_PROP_FPS);
int frameheight = cap.get(CAP_PROP_FRAME_HEIGHT)
int framewidth = cap.get(CAP_PROP_FRAME_WIDTH);
cap.set(CAP_PROP_FPS, fps);
cap.set(CAP_PROP_FRAME_HEIGHT, frameheight);
cap.set(CAP_PROP_FRAME_WIDTH, framewidth);
video.open(vidname, codec, 60, Size(framewidth, frameheight));
//int framewidth = 640;
//int frameheight = 480;
std::cout << "Width: " << framewidth << endl;
std::cout << "Height: " << frameheight << endl;
//double fps = cap.get(CAP_PROP_FPS);
std::cout << "Frames per second: " << cap.get(CAP_PROP_FPS) << endl; //records at 60 fps
Mat frame;
int framecount = 0;
*/
Mat imagetemp2;
while (true) {
rs2::frameset data = pipe.wait_for_frames();
rs2::frame color = data.get_color_frame();
const int w = color.as<rs2::video_frame>().
const int h = color.as<rs2::video_frame>().
Mat imagetemp(Size(w, h), CV_8UC3, (void*)color.get_data(), Mat::AUTO_STEP);
cvtColor(imagetemp, imagetemp2, cv::COLOR_BGR2RGB);
Mat image = imagetemp2.clone();
video.write(image);
imshow(window_name, image);
//27 is ASCII for esc key
if (waitKey(1) == 27)
{
std::cout << "Esc key was pressed. Video is being stopped." << endl;
break;
}
}
video.release();
return 0;
}
Any help would be immensely appreciated. I feel as if I have exhausted all avenues to achieve 60 fps.
Link Copied
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page