v2
This commit is contained in:
@@ -30,9 +30,8 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// We now have at least one source, so we create a receiver to look at it.
|
||||
NDIlib_recv_create_v3_t pNDI_recv_parameters;
|
||||
pNDI_recv_parameters.color_format = NDIlib_recv_color_format_BGRX_BGRA;
|
||||
NDIlib_recv_instance_t pNDI_recv = NDIlib_recv_create_v3(&pNDI_recv_parameters);
|
||||
NDIlib_recv_create_t pNDI_recv_parameters = { *p_sources, NDIlib_recv_color_format_e_BGRX_BGRA, NDIlib_recv_bandwidth_highest, true };
|
||||
NDIlib_recv_instance_t pNDI_recv = NDIlib_recv_create_v2(&pNDI_recv_parameters);
|
||||
if (!pNDI_recv) return 0;
|
||||
|
||||
// Connect to our sources
|
||||
@@ -47,9 +46,9 @@ int main(int argc, char* argv[])
|
||||
for (const auto start = high_resolution_clock::now(); high_resolution_clock::now() - start < minutes(5);)
|
||||
{ // The descriptors
|
||||
NDIlib_video_frame_v2_t video_frame;
|
||||
NDIlib_audio_frame_v2_t audio_frame;
|
||||
// NDIlib_audio_frame_v2_t audio_frame;
|
||||
|
||||
switch (NDIlib_recv_capture_v2(pNDI_recv, &video_frame, &audio_frame, nullptr, 5000))
|
||||
switch (NDIlib_recv_capture_v2(pNDI_recv, &video_frame, NULL, NULL, 1000))
|
||||
{ // No data
|
||||
case NDIlib_frame_type_none:
|
||||
printf("No data received.\n");
|
||||
@@ -60,17 +59,27 @@ int main(int argc, char* argv[])
|
||||
printf("Video data received (%dx%d).\n", video_frame.xres, video_frame.yres);
|
||||
if (video_frame.p_data != nullptr){
|
||||
// memcpy(p_data, (uchar*)video_frame.p_data, video_frame.xres * video_frame.yres * 2 * sizeof(uchar));
|
||||
|
||||
// A bit of testing of the received data.
|
||||
std::cout << "The first 100 elements received: " << std::endl;
|
||||
for (int i = 0; i < 100; i++){
|
||||
std::cout << "[ " << (int)video_frame.p_data[i*video_frame.xres*4] << " ";
|
||||
std::cout << (int)video_frame.p_data[i*video_frame.xres*4 + 1] << " ";
|
||||
std::cout << (int)video_frame.p_data[i*video_frame.xres*4 + 2] << " ";
|
||||
std::cout << (int)video_frame.p_data[i*video_frame.xres*4 + 3] << " ] ";
|
||||
std::cout << (int)video_frame.p_data[i] << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
cv::Mat frame(video_frame.yres, video_frame.xres, CV_8UC4, video_frame.p_data, cv::Mat::AUTO_STEP);
|
||||
// A bit of testing of the received data.
|
||||
for (int i = 0; i < 100; i++){
|
||||
std::cout << "[ " << (int)video_frame.p_data[i*video_frame.xres*3] << " ";
|
||||
std::cout << (int)video_frame.p_data[i*video_frame.xres*3 + 1] << " ";
|
||||
std::cout << (int)video_frame.p_data[i*video_frame.xres*3 + 2] << " ] ";
|
||||
// std::cout << (int)video_frame.p_data[i*video_frame.xres*4 + 3] << " ] ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// cv::Mat frame(video_frame.yres, video_frame.xres, CV_8UC4, video_frame.p_data);
|
||||
cv::Mat frame = cv::Mat::zeros(cv::Size(video_frame.xres, video_frame.yres), CV_8UC4);
|
||||
std::cout << std::endl;
|
||||
memcpy(frame.data, video_frame.p_data, video_frame.xres * video_frame.yres * 4);
|
||||
for (int i = 0; i < 100; i++){
|
||||
std::cout << frame.at<cv::Vec4b>(0, i) << " ";
|
||||
}
|
||||
@@ -89,8 +98,8 @@ int main(int argc, char* argv[])
|
||||
break;
|
||||
// Audio data
|
||||
case NDIlib_frame_type_audio:
|
||||
printf("Audio data received (%d samples).\n", audio_frame.no_samples);
|
||||
NDIlib_recv_free_audio_v2(pNDI_recv, &audio_frame);
|
||||
// printf("Audio data received (%d samples).\n", audio_frame.no_samples);
|
||||
// NDIlib_recv_free_audio_v2(pNDI_recv, &audio_frame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user