#define MEDIA_FILE_PATH "/opt/usr/home/owner/media/Images"
#ifdef BUILD_VISUALIZER
+#include "mv_util_visualizer_2d.h"
#include "mv_util_visualizer_3d.h"
#endif
int fmt;
std::string dataset;
DistanceMode distanceMode;
+ std::string remoteUrl;
+ mv_source_h remoteSource;
+ unsigned char *remoteDataBuffer;
} appdata;
enum
{
FMT_PFM = 1,
- FMT_PNG
+ FMT_PNG,
+ FMT_REMOTE
};
static int littleendian()
fclose(stream);
}
+static void SendDataToRemoteUrl(unsigned short *data, int width, int height, float minDisp, float maxDips, float depth2Disp,
+ std::string url, mv_source_h source, unsigned char *buffer)
+{
+#if BUILD_VISUALIZER
+ int r, g, b;
+ for (int y = 0; y < height; y++) {
+ unsigned short* src = data + y * width;
+ unsigned char* dst = buffer + y * (width * 4);
+ for (int x = 0; x < width; x++) {
+ jet((depth2Disp / static_cast<float>(src[x]) - minDisp) / (maxDips - minDisp), r, g, b);
+ dst[x*4] = r;
+ dst[x*4 + 1] = g;
+ dst[x*4 + 2] = b;
+ dst[x*4 + 3] = 255;
+ }
+ }
+
+ mv_source_fill_by_buffer(source, buffer, width * height * 4, width, height, MEDIA_VISION_COLORSPACE_RGBA);
+
+ mv_util_visualizer_2d(source, url.c_str());
+
+ mv_source_clear(source);
+
+ sleep(3);
+#endif
+}
+
static void WritePLY(double *data, int size, const char *filename)
{
std::ofstream stream(filename, std::ofstream::out);
if (udata->fmt == FMT_PFM) {
WriteFilePFM(depth, width, height, udata->datasetName.c_str(),
udata->minDisp, udata->maxDisp, udata->depth2Disp, udata->distanceMode);
- } else {
+ } else if (udata->fmt == FMT_PNG) {
WriteFilePNG(depth, width, height, udata->datasetName.c_str(),
udata->minDisp, udata->maxDisp, udata->depth2Disp, udata->distanceMode);
+ } else {
+ SendDataToRemoteUrl(depth, width, height, udata->minDisp, udata->maxDisp, udata->depth2Disp,
+ udata->remoteUrl, udata->remoteSource, udata->remoteDataBuffer);
}
udata->diffMs = stopWatch.elapsedTime();
{
char *path_to_dataset = NULL;
char *suffix_for_algo = NULL;
+ char *remote_url = NULL;
int err = MEDIA_VISION_ERROR_NONE;
mv_engine_config_h engine_config = NULL;
mv_source_h left_source = NULL;
printf("Incorrect! Try again.\n");
}
+#if BUILD_VISUALIZER
+ const char *formats[] = { "pfm", "png", "remote display" };
+#else
const char *formats[] = { "pfm", "png" };
+#endif
+
int sel_fmt = -1;
while (sel_fmt <= 0 || sel_fmt > static_cast<int>(ARRAY_SIZE(formats))) {
sel_fmt = show_menu_linear("Select Action", formats, ARRAY_SIZE(formats));
const char* distances[] = {"disparty", "depth"};
int sel_distance = -1;
- while (sel_distance <= 0 || sel_distance > ARRAY_SIZE(distances)) {
- sel_distance = show_menu_linear("Select Action", distances, ARRAY_SIZE(distances));
+ if (sel_fmt == FMT_REMOTE) {
+ while (input_string("remote url where you send:", 1024, &remote_url) == -1) {
+ printf("Incorrect! Try again.\n");
+ }
+ } else {
+ while (sel_distance <= 0 || sel_distance > ARRAY_SIZE(distances)) {
+ sel_distance = show_menu_linear("Select Action", distances, ARRAY_SIZE(distances));
+ }
}
err = mv_create_engine_config(&engine_config);
fx * baseline,
sel_fmt,
std::string(dataset[data]),
- static_cast<DistanceMode>(sel_distance) };
+ static_cast<DistanceMode>(sel_distance),
+ std::string(remote_url),
+ nullptr,
+ nullptr };
printf("fx:%f, baseline:%f, d2d: %f\n", fx, baseline, dump.depth2Disp);
dump.datasetName += sel_fmt == FMT_PFM ? std::string(".pfm") : std::string(".png");
+ if (sel_fmt == FMT_REMOTE) {
+ err = mv_create_source(&dump.remoteSource);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+
+ printf("Failed to create remote source handle\n");
+ if (dump.remoteSource) {
+ mv_destroy_source(dump.remoteSource);
+ }
+ goto _err;
+ }
+
+ dump.remoteDataBuffer = new(std::nothrow)unsigned char[width * height * 4];
+ if (!dump.remoteDataBuffer) {
+ printf("Failed to allocate remote data buffer\nn");
+
+ if (dump.remoteSource) {
+ mv_destroy_source(dump.remoteSource);
+ }
+
+ if (dump.remoteDataBuffer) {
+ delete [] dump.remoteDataBuffer;
+ }
+ goto _err;
+ }
+ }
+
err = mv_3d_set_depth_cb(mv3d_handle, _depth_middlebury_cb, static_cast<void *>(&dump));
if (err != MEDIA_VISION_ERROR_NONE) {
printf("Failed to set depth callback to handle\n");
}
err = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_middlebury_cb, static_cast<void *>(&dump));
- if (err != MEDIA_VISION_ERROR_NONE) {
+ if (err != MEDIA_VISION_ERROR_NONE && err != MEDIA_VISION_ERROR_NOT_SUPPORTED) {
printf("Failed to set pointcloud callback to handle\n");
goto _err;
}