start of feature 01 repo

This commit is contained in:
PodmogilnyjIvan
2022-01-11 08:20:09 -08:00
parent 682ca7160b
commit f43b9c4732
4 changed files with 1258 additions and 285 deletions

View File

@@ -45,15 +45,29 @@ int main(int argc, char* argv[]) {
int64_t total_frames_counter = 0;
// Let's open the video with OpenCV and read it
// std::string path_to_file = "C:\\Users\\ivan\\Source\\Repos\\cv_networking_pipeline\\gstreamer_receive_video\\videos\\camera1-2020-10-14---19-38-42---093390448_scaled.mp4";
std::string path_to_file;
std::cout << "Please, enter the path to the video_file" << std::endl;
std::cin >> path_to_file;
std::string path_to_file = "C:\\Users\\ivan\\Source\\Repos\\cv_networking_pipeline\\gstreamer_receive_video\\videos\\camera1-2020-10-14---19-38-42---093390448_scaled.mp4";
//std::string path_to_file;
//std::cout << "Please, enter the path to the video_file" << std::endl;
//std::cin >> path_to_file;
std::string confirmation;
while (true) {
std::cout << "Please, write key y or yes to continue" << std::endl;
std::cin >> confirmation;
if ( (confirmation == "y") || (confirmation == "yes") ) {
break;
}
confirmation = "";
}
cv::VideoCapture video_file(path_to_file);
std::cout << "Video File opened" << std::endl;
cv::Mat frame;
int cnt = 0;
while (!is_terminated) {
// Get the current time
const auto start_send = high_resolution_clock::now();
@@ -62,9 +76,9 @@ int main(int argc, char* argv[]) {
for (int idx = 200; idx; idx--) {
// Fill in the buffer. It is likely that you would do something much smarter than this.
video_file.read(frame);
std::cout << "Successfully read video_file" << std::endl;
std::cout << "Frame channels is: " << frame.channels() << " " << frame.rows << " " << frame.cols << std::endl;
std::cout << frame.total() * frame.channels() << std::endl;
//std::cout << "Successfully read video_file" << std::endl;
//std::cout << "Frame channels is: " << frame.channels() << " " << frame.rows << " " << frame.cols << std::endl;
//std::cout << frame.total() * frame.channels() << std::endl;
// from https://stackoverflow.com/questions/26681713/convert-mat-to-array-vector-in-opencv
// TODO: Seems that the conversion was unseccesful. Understand what really happens when you set the frame.ptr<uint8_t>(0) and what happens when
// TODO: you make (uint8_t*)malloc(xres * yres * 4)
@@ -73,7 +87,7 @@ int main(int argc, char* argv[]) {
cv::cvtColor(frame, continiousRGBA, CV_BGR2RGBA, 4);
//uchar* p_data = (uchar*)frame.clone().data;
//uchar* p_data = (uchar*)frame.ptr(0);
std::cout << "Successfully converted frame." << std::endl;
//std::cout << "Successfully converted frame." << std::endl;
//std::cout << &p_data[50] << std::endl;
//for (int i = 0; i < frame.total() * frame.channels(); i++) {
@@ -82,11 +96,11 @@ int main(int argc, char* argv[]) {
// We are going to create a 1920x1080 interlaced frame at 29.97Hz.
int xres = 480;
int yres = 270;
std::string metadata_string = "<metadata_string " + std::to_string(total_frames_counter) + ">";
std::string metadata_string = "<metadata_string " + std::to_string(total_frames_counter) + std::to_string(cnt) + ">";
// (uint8_t*)malloc(xres * yres * 4) is the frame itself.
NDIlib_video_frame_v2_t ndi_video_frame(
xres, yres, NDIlib_FourCC_type_BGRX,
xres, yres, NDIlib_FourCC_type_RGBA,
30000, 1001, 2,
NDIlib_frame_format_type_progressive,
0,
@@ -94,7 +108,8 @@ int main(int argc, char* argv[]) {
0,
metadata_string.c_str()
);
std::cout << "Successfully created ndi_video_frame" << std::endl;
//std::cout << "Successfully created ndi_video_frame" << std::endl;
//
// std::cout << "hi there" << std::endl;
// std::cout << "xres = " << ndi_video_frame.xres << std::endl;
// std::cout << "yres = " << ndi_video_frame.yres << std::endl;
@@ -126,6 +141,7 @@ int main(int argc, char* argv[]) {
// Just display something helpful
printf("200 frames sent, at %1.2ffps\n", 200.0f / duration_cast<duration<float>>(high_resolution_clock::now() - start_send).count());
cnt++;
}
// Destroy the NDI sender