This commit is contained in:
Ivan
2022-06-14 14:17:48 +03:00
parent 6fc9ff1ae3
commit f97644b75c
4 changed files with 41 additions and 30 deletions

View File

@@ -71,12 +71,13 @@ int main(int argc, char* argv[])
NDI_video_frame.yres = 370;
NDI_video_frame.frame_rate_N = 30000;
NDI_video_frame.frame_rate_D = 1001;
NDI_video_frame.picture_aspect_ratio = 1226.0f/360.0f;
NDI_video_frame.picture_aspect_ratio = 0.0;
NDI_video_frame.timecode = 0;
NDI_video_frame.frame_format_type = NDIlib_frame_format_type_progressive;
// What is interleaved?
NDI_video_frame.frame_format_type = NDIlib_frame_format_type_interleaved;
NDI_video_frame.FourCC = NDIlib_FourCC_type_BGRX;
NDI_video_frame.line_stride_in_bytes = NDI_video_frame.xres * 4;
NDI_video_frame.p_data = (uint8_t*)malloc(NDI_video_frame.xres*NDI_video_frame.yres * 4);
NDI_video_frame.line_stride_in_bytes = NDI_video_frame.xres * 3;
NDI_video_frame.p_data = (uint8_t*)malloc(NDI_video_frame.xres*NDI_video_frame.yres * 3);
NDI_video_frame.p_metadata = "<Hello/>";
// std::cout << "The size of char: " << sizeof(uchar) << " The size of uint8_t: " << sizeof(uint8_t) << std::endl;
@@ -121,8 +122,8 @@ int main(int argc, char* argv[])
// New version
cv::Mat imLeft = cv::imread(vstrImageLeft[idx], cv::IMREAD_COLOR);
std::printf("imLeft is loaded! Width: %d, Height: %d \n", imLeft.cols, imLeft.rows);
cv::Mat imRight = cv::imread(vstrImageRight[idx], cv::IMREAD_GRAYSCALE);
cv::cvtColor(imLeft, imLeft, cv::COLOR_BGR2BGRA, 4);
cv::Mat imRight = cv::imread(vstrImageRight[idx], cv::IMREAD_COLOR);
// cv::cvtColor(imLeft, imLeft, cv::COLOR_BGR2BGRA, 4);
if (imLeft.isContinuous()){
std::cout << "The imLeft is Continuous." << std::endl;
}
@@ -131,8 +132,8 @@ int main(int argc, char* argv[])
// if (c==27){
// break;
// }
cv::cvtColor(imRight, imRight, cv::COLOR_GRAY2BGRA);
cv::Mat frame(imLeft.rows, imLeft.cols*2, CV_8UC4);
// cv::cvtColor(imRight, imRight, cv::COLOR_GRAY2BGRA);
cv::Mat frame(imLeft.rows, imLeft.cols*2, CV_8UC3);
std::printf("Frame width: %d, height: %d \n", frame.cols, frame.rows);
cv::Rect leftROI(0, 0, imLeft.cols, imLeft.rows);
cv::Rect rightROI(imLeft.cols, 0, imLeft.cols, imLeft.rows);
@@ -143,29 +144,30 @@ int main(int argc, char* argv[])
std::cout << std::endl;
for (int i = 0; i < 100; i++){
std::cout << imLeft.at<cv::Vec4b>(i, 0) << " ";
std::cout << imLeft.at<cv::Vec3b>(i, 0) << " ";
}
std::cout << std::endl;
std::cout << "From the array first elements of the rows: " << std::endl;
for (int i = 0; i < 100; i++){
std::cout << "[ " << (int)imLeft.data[i*imLeft.cols*4] << ", ";
std::cout << (int)imLeft.data[i*imLeft.cols*4 + 1] << ", ";
std::cout << (int)imLeft.data[i*imLeft.cols*4 + 2] << ", ";
std::cout << (int)imLeft.data[i*imLeft.cols*4 + 3] << " ] ";
std::cout << "[ " << (int)imLeft.data[i*imLeft.cols*3] << ", ";
std::cout << (int)imLeft.data[i*imLeft.cols*3 + 1] << ", ";
std::cout << (int)imLeft.data[i*imLeft.cols*3 + 2] << ", ";
// std::cout << (int)imLeft.data[i*imLeft.cols*4 + 3] << " ] ";
}
std::cout << std::endl;
// Fill in the buffer. It is likely that you would do something much smarter than this.
// memset((void*)NDI_video_frame.p_data, (idx & 1) ? 255 : 0, NDI_video_frame.xres*NDI_video_frame.yres * 4 * sizeof(uint8_t));
memcpy(NDI_video_frame.p_data, imLeft.ptr(0, 0), NDI_video_frame.xres * NDI_video_frame.yres * 4 * sizeof(char));
// Why used void* the guy in GitHub?
memcpy((void*)NDI_video_frame.p_data, imLeft.ptr(0, 0), NDI_video_frame.xres * NDI_video_frame.yres * 3);
std::cout << std::endl << "From the video_frame.p_data array first elements of the rows: " << std::endl;
for (int i = 0; i < 100; i++){
std::cout << "[ " << (int)NDI_video_frame.p_data[i*imLeft.cols*4] << ", ";
std::cout << (int)NDI_video_frame.p_data[i*imLeft.cols*4 + 1] << ", ";
std::cout << (int)NDI_video_frame.p_data[i*imLeft.cols*4 + 2] << ", ";
std::cout << (int)NDI_video_frame.p_data[i*imLeft.cols*4 + 3] << " ] ";
std::cout << "[ " << (int)NDI_video_frame.p_data[i*imLeft.cols*3] << ", ";
std::cout << (int)NDI_video_frame.p_data[i*imLeft.cols*3 + 1] << ", ";
std::cout << (int)NDI_video_frame.p_data[i*imLeft.cols*3 + 2] << ", ";
// std::cout << (int)NDI_video_frame.p_data[i*imLeft.cols*4 + 3] << " ] ";
}
std::cout << std::endl;