computer-vision-2/assignments/assignment_3/src/Frame3D/Frame3D.cpp
/* Save 3D frame to file. 2 options are available:
 *   - version 0.5		: Frame is saved without any compression, a simple memory dump
 *   - version 1		: Frame is saved using JPG compression (90%) on the rgb_image, and PNG compression(type 3) on the depth_image.
 *   					  This compression comes at a cost, since it is about 5 times slower to load than simple memory dump
 *   - version 1.2		: In addition to version 1, in version 1.2 the rotation and translation matrices are stored in 1 4x4 matrix
 *   - version 1.3		: Device name is added
 */
Save 3D frame to file. 2 options are available:
- version 0.5              : Frame is saved without any compression, a simple memory dump
- version 1                : Frame is saved using JPG compression (90%) on the rgb_image, and PNG compression(type 3) on the depth_image.
This compression comes at a cost, since it is about 5 times slower to load than simple memory dump
- version 1.2              : In addition to version 1, in version 1.2 the rotation and translation matrices are stored in 1 4x4 matrix
- version 1.3              : Device name is added
Save 3D frame to file . 2 options are available : - version 0 . 5 : Frame is saved without any compression a simple memory dump - version 1 : Frame is saved using JPG compression ( 90% ) on the rgb_image and PNG compression ( type 3 ) on the depth_image . This compression comes at a cost since it is about 5 times slower to load than simple memory dump - version 1 . 2 : In addition to version 1 in version 1 . 2 the rotation and translation matrices are stored in 1 4x4 matrix - version 1 . 3 : Device name is added
void Frame3D::save(string path, double version) {
	if (version != 0.5 && version != 1 && version != 1.2 && version != 1.3)
		throw(runtime_error("Frame3D::save : invalid version number!, currently only version 0.5, 1, 1.2 and 1.3 are supported"));
	FileWriter writer(path);
	writer.appendDouble(version);
	if (version >= 1) {
		writer.appendImage(rgb_image_, ".jpg", paramsJPG);
		writer.appendImage(depth_image_, ".png", paramsPNG);
	} else {
		writer.appendMat(rgb_image_);
		writer.appendMat(depth_image_);
	}
	if (version >= 1.2) {
		writer.appendMat(transformation_);
	} else {
		Mat temp1 = rotation_.clone();
		Mat temp2 = translation_.clone();
		writer.appendMat(temp1);
		writer.appendMat(temp2);
	}
	writer.appendDouble(focal_length_);
	if (version >= 1.3)
		writer.appendString(device_name_);
}
void Frame3D :: save ( string path , double version ) { if ( version != 0.5 && version != 1 && version != 1.2 && version != 1.3 ) throw ( runtime_error ( " " ) ) ; FileWriter writer ( path ) ; writer . appendDouble ( version ) ; if ( version >= 1 ) { writer . appendImage ( rgb_image_ , " " , paramsJPG ) ; writer . appendImage ( depth_image_ , " " , paramsPNG ) ; } else { writer . appendMat ( rgb_image_ ) ; writer . appendMat ( depth_image_ ) ; } if ( version >= 1.2 ) { writer . appendMat ( transformation_ ) ; } else { Mat temp1 = rotation_ . clone ( ) ; Mat temp2 = translation_ . clone ( ) ; writer . appendMat ( temp1 ) ; writer . appendMat ( temp2 ) ; } writer . appendDouble ( focal_length_ ) ; if ( version >= 1.3 ) writer . appendString ( device_name_ ) ; }
Save 3D frame to file.
Save 3D frame to file .
/*=1.3*/