victorprad / InfiniTAM

A Framework for the Volumetric Integration of Depth Images
http://www.infinitam.org
Other
941 stars 353 forks source link

Cannot save images to file #129

Closed sabrinazuraimi closed 5 years ago

sabrinazuraimi commented 5 years ago

I've built InfiniTAM with FFMPEG support on and I wanted to save the images captured while running the app by using the button 's'. However, the output image was not saved.

From FileUtils.cpp, this is the code that gets run when pressing the 's' button. It looks like it need to read pnm files but since I already have FFMPEG support on, that should not be a problem right??

void SaveImageToFile(const ORUtils::Image<short>* image, const char* fileName)
{
    short *data = (short*)malloc(sizeof(short) * image->dataSize);
    const short *dataSource = image->GetData(MEMORYDEVICE_CPU);
    for (size_t i = 0; i < image->dataSize; i++) data[i] = (dataSource[i] << 8) | ((dataSource[i] >> 8) & 255);

    FILE *f = fopen(fileName, "wb");
    if (!pnm_writeheader(f, image->noDims.x, image->noDims.y, MONO_16u)) {
        fclose(f); return;
    }
    pnm_writedata(f, image->noDims.x, image->noDims.y, MONO_16u, data);
    fclose(f);

    delete data;
}

This is the output I get when I run the app btw

using calibration file: trying OpenNI device: - calibration: internal Calibration filename not specified. Using default parameters. [Info] [Freenect2Impl] enumerating devices... [Info] [Freenect2Impl] 7 usb devices connected [Info] [Freenect2Impl] found valid Kinect v2 @2:3 with serial [Info] [Freenect2Impl] found 1 devices OpenNI: Initialization ...

[Info] [Freenect2DeviceImpl] opening... [Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 2016384 ir: 608*33792 [Info] [Freenect2DeviceImpl] opened [Info] [Freenect2DeviceImpl] starting... [Info] [Freenect2DeviceImpl] submitting rgb transfers... [Info] [Freenect2DeviceImpl] submitting depth transfers... [Info] [Freenect2DeviceImpl] started Initialised OpenNI depth camera with resolution: 640 x 480 Initialised OpenNI color camera with resolution: 512 x 424 fx=1081.37,fy=1081.37,cx=959.5,cy=539.5 fx=366.847,fy=366.847,ix=255.482,iy=208.108,k1=0.08986,k2=-0.27364,k3=0.099035,p1=0,p2=0 initialised. [Info] [DepthPacketStreamParser] 10 packets were lost processing one frame ... [Info] [OpenGLDepthPacketProcessor] avg. time: 4.43119ms -> ~225.673Hz processing one frame ... [Info] [TurboJpegRgbPacketProcessor] avg. time: 11.5867ms -> ~86.3057Hz processing one frame ... processing one frame ... processing one frame ... processing one frame ... started recoding disk ... [Info] [OpenGLDepthPacketProcessor] avg. time: 2.72679ms -> ~366.732Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 11.0848ms -> ~90.2134Hz stopped recoding disk ... [Info] [OpenGLDepthPacketProcessor] avg. time: 2.71005ms -> ~368.997Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 11.0711ms -> ~90.3253Hz exiting ... [Info] [Freenect2DeviceImpl] stopping... [Info] [Freenect2DeviceImpl] canceling rgb transfers... [Info] [Freenect2DeviceImpl] canceling depth transfers... [Info] [Freenect2DeviceImpl] stopped [Info] [Freenect2DeviceImpl] closing... [Info] [Freenect2DeviceImpl] releasing usb interfaces... [Info] [Freenect2DeviceImpl] deallocating usb transfer pools... [Info] [Freenect2DeviceImpl] closing usb device... [Info] [Freenect2DeviceImpl] closed [Info] [Freenect2DeviceImpl] closing... [Info] [Freenect2DeviceImpl] already closed, doing nothing

sgolodetz commented 5 years ago

In InfiniTAM.cpp, the UI engine is initialised like this:

UIEngine::Instance()->Initialise(argc, argv, imageSource, imuSource, mainEngine, "./Files/Out", internalSettings->deviceType);

This means that the output files will be saved to ./Files/Out. If that directory doesn't exist, they won't be saved - try creating the directory and see if that works.

sabrinazuraimi commented 5 years ago

When I created the folder, it works!