"Cable", "Classroom1", "Couch", "Flowers", "Mask", "Shopvac",
"Sticks", "Storage", "Sword1", "Sword2", "Umbrella" };
-enum DistanceMode { DISTANCE_DEPTH, DISTANCE_DISPARITY };
+enum DistanceMode { DISTANCE_DISPARITY = 1, DISTANCE_DEPT };
+enum StereoFormat { STEREO_DECOUPLE = 1, STEREO_COUPLE_SBS, STEREO_COUPLE_TB };
class StopWatch
{
char *remote_url = NULL;
int err = MEDIA_VISION_ERROR_NONE;
mv_engine_config_h engine_config = NULL;
- mv_source_h left_source = NULL;
- mv_source_h right_source = NULL;
+ mv_source_h base_source = NULL;
+ mv_source_h extra_source = NULL;
mv_3d_h mv3d_handle = NULL;
size_t datasize = ARRAY_SIZE(dataset);
- cv::Mat left_frame, right_frame;
+ cv::Mat base_frame, extra_frame;
while (input_string("root path including dataset:", 1024, &path_to_dataset) == -1) {
printf("Incorrect! Try again.\n");
}
}
+ const char *stereo_format[] = { "Stereo Decouple", "Stereo Couple SBS", "Stereo Copule TB" };
+ int st_format = -1;
+ while (st_format <= 0 || st_format > static_cast<int>(ARRAY_SIZE(stereo_format))) {
+ st_format = show_menu_linear("Select Action", stereo_format, ARRAY_SIZE(stereo_format));
+ }
+
err = mv_create_engine_config(&engine_config);
if (err != MEDIA_VISION_ERROR_NONE) {
printf("Failed to create engine config\n");
goto _err;
}
- err = mv_create_source(&left_source);
+ err = mv_create_source(&base_source);
if (err != MEDIA_VISION_ERROR_NONE) {
- printf("Failed to create left source\n");
+ printf("Failed to create base source\n");
goto _err;
}
- err = mv_create_source(&right_source);
- if (err != MEDIA_VISION_ERROR_NONE) {
- printf("Failed to create right source\n");
- goto _err;
+ if (st_format == STEREO_DECOUPLE) {
+ err = mv_create_source(&extra_source);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Failed to create extra source\n");
+ goto _err;
+ }
}
for (size_t data = 0; data < datasize; ++data) {
}
// left_source, right_source
- left_frame = cv::imread(leftFilename, cv::IMREAD_GRAYSCALE);
- right_frame = cv::imread(rightFilename, cv::IMREAD_GRAYSCALE);
-
- err = mv_source_fill_by_buffer(left_source, left_frame.ptr<unsigned char>(),
- left_frame.elemSize() * left_frame.size().width * left_frame.size().height,
- left_frame.size().width, left_frame.size().height, MEDIA_VISION_COLORSPACE_Y800);
- if (err != MEDIA_VISION_ERROR_NONE) {
- printf("Failed to fill left_source\n");
- goto _err;
- }
+ cv::Mat left_frame = cv::imread(leftFilename, cv::IMREAD_GRAYSCALE);
+ cv::Mat right_frame = cv::imread(rightFilename, cv::IMREAD_GRAYSCALE);
+
+ if (st_format == STEREO_COUPLE_SBS) {
+ cv::hconcat(left_frame, right_frame, base_frame);
+ err = mv_source_fill_by_buffer(base_source, base_frame.ptr<unsigned char>(),
+ base_frame.elemSize() * base_frame.size().width * base_frame.size().height,
+ base_frame.size().width, base_frame.size().height,
+ MEDIA_VISION_COLORSPACE_Y800);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Failed to fill base_source\n");
+ goto _err;
+ }
+ } else if (st_format == STEREO_COUPLE_TB) {
+ cv::vconcat(left_frame, right_frame, base_frame);
+ err = mv_source_fill_by_buffer(base_source, base_frame.ptr<unsigned char>(),
+ base_frame.elemSize() * base_frame.size().width * base_frame.size().height,
+ base_frame.size().width, base_frame.size().height,
+ MEDIA_VISION_COLORSPACE_Y800);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Failed to fill base_source\n");
+ goto _err;
+ }
+ } else {
+ err = mv_source_fill_by_buffer(base_source, left_frame.ptr<unsigned char>(),
+ left_frame.elemSize() * left_frame.size().width * left_frame.size().height,
+ left_frame.size().width, left_frame.size().height,
+ MEDIA_VISION_COLORSPACE_Y800);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Failed to fill left_source\n");
+ goto _err;
+ }
- err = mv_source_fill_by_buffer(right_source, right_frame.ptr<unsigned char>(),
- right_frame.elemSize() * right_frame.size().width * right_frame.size().height,
- right_frame.size().width, right_frame.size().height,
- MEDIA_VISION_COLORSPACE_Y800);
- if (err != MEDIA_VISION_ERROR_NONE) {
- printf("Failed to fill right_source\n");
- goto _err;
+ err = mv_source_fill_by_buffer(
+ extra_source, right_frame.ptr<unsigned char>(),
+ right_frame.elemSize() * right_frame.size().width * right_frame.size().height,
+ right_frame.size().width, right_frame.size().height, MEDIA_VISION_COLORSPACE_Y800);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Failed to fill right_source\n");
+ goto _err;
+ }
}
// depth_handle
sel_fmt,
std::string(dataset[data]),
static_cast<DistanceMode>(sel_distance),
- std::string(remote_url),
+ remote_url != NULL ? std::string(remote_url) : std::string(),
nullptr,
nullptr };
printf("fx:%f, baseline:%f, d2d: %f\n", fx, baseline, dump.depth2Disp);
}
StopWatch stopWatch;
- err = mv_3d_run(mv3d_handle, left_source, right_source, NULL);
+ err = mv_3d_run(mv3d_handle, base_source, extra_source, NULL);
/* time to save a file is excluded */
std::chrono::milliseconds diffMs = stopWatch.elapsedTime() - dump.diffMs;
if (engine_config)
mv_destroy_engine_config(engine_config);
- if (left_source)
- mv_destroy_source(left_source);
+ if (base_source)
+ mv_destroy_source(base_source);
- if (right_source)
- mv_destroy_source(right_source);
+ if (extra_source)
+ mv_destroy_source(extra_source);
if (mv3d_handle)
mv_3d_destroy(mv3d_handle);