Skip to content
Snippets Groups Projects
Commit e0d6bf52 authored by Vojtěch Moravec's avatar Vojtěch Moravec
Browse files

Fix wrong name of cache file when reporting it being saved.

parent 29a97226
No related branches found
No related tags found
No related merge requests found
...@@ -114,9 +114,10 @@ public class QuantizationCacheManager { ...@@ -114,9 +114,10 @@ public class QuantizationCacheManager {
* *
* @param trainFile Image file used for training. * @param trainFile Image file used for training.
* @param codebook SQ codebook. * @param codebook SQ codebook.
* @return Path to the saved cache file.
* @throws IOException when fails to save the cache file. * @throws IOException when fails to save the cache file.
*/ */
public void saveCodebook(final String trainFile, final SQCodebook codebook) throws IOException { public String saveCodebook(final String trainFile, final SQCodebook codebook) throws IOException {
final String fileName = getCacheFilePathForSQ(trainFile, codebook.getCodebookSize()).getAbsolutePath(); final String fileName = getCacheFilePathForSQ(trainFile, codebook.getCodebookSize()).getAbsolutePath();
final CacheFileHeader header = createHeaderForSQ(new File(trainFile).getName(), codebook); final CacheFileHeader header = createHeaderForSQ(new File(trainFile).getName(), codebook);
...@@ -129,6 +130,7 @@ public class QuantizationCacheManager { ...@@ -129,6 +130,7 @@ public class QuantizationCacheManager {
} catch (IOException ex) { } catch (IOException ex) {
throw new IOException("Failed to save SQ cache file\n" + ex.getMessage()); throw new IOException("Failed to save SQ cache file\n" + ex.getMessage());
} }
return fileName;
} }
/** /**
...@@ -136,9 +138,10 @@ public class QuantizationCacheManager { ...@@ -136,9 +138,10 @@ public class QuantizationCacheManager {
* *
* @param trainFile Image file used for training. * @param trainFile Image file used for training.
* @param codebook VQ codebook. * @param codebook VQ codebook.
* @return Path to the saved cache file.
* @throws IOException when fails to save the cache file. * @throws IOException when fails to save the cache file.
*/ */
public void saveCodebook(final String trainFile, final VQCodebook codebook) throws IOException { public String saveCodebook(final String trainFile, final VQCodebook codebook) throws IOException {
final String fileName = getCacheFilePathForVQ(trainFile, final String fileName = getCacheFilePathForVQ(trainFile,
codebook.getCodebookSize(), codebook.getCodebookSize(),
codebook.getVectorDims()).getAbsolutePath(); codebook.getVectorDims()).getAbsolutePath();
...@@ -153,6 +156,7 @@ public class QuantizationCacheManager { ...@@ -153,6 +156,7 @@ public class QuantizationCacheManager {
} catch (IOException ex) { } catch (IOException ex) {
throw new IOException("Failed to save VQ cache file\n" + ex.getMessage()); throw new IOException("Failed to save VQ cache file\n" + ex.getMessage());
} }
return fileName;
} }
/** /**
......
...@@ -221,10 +221,10 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -221,10 +221,10 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
final SQCodebook codebook = lloydMax.getCodebook(); final SQCodebook codebook = lloydMax.getCodebook();
reportStatusToListeners("Finished LloydMax training."); reportStatusToListeners("Finished LloydMax training.");
reportStatusToListeners(String.format("Saving cache file to %s", options.getOutputFilePath()));
QuantizationCacheManager cacheManager = new QuantizationCacheManager(options.getCodebookCacheFolder()); QuantizationCacheManager cacheManager = new QuantizationCacheManager(options.getCodebookCacheFolder());
try { try {
cacheManager.saveCodebook(options.getInputDataInfo().getCacheFileName(), codebook); final String cacheFilePath = cacheManager.saveCodebook(options.getInputDataInfo().getCacheFileName(), codebook);
reportStatusToListeners(String.format("Saved cache file to %s", cacheFilePath));
} catch (IOException e) { } catch (IOException e) {
throw new ImageCompressionException("Unable to write cache.", e); throw new ImageCompressionException("Unable to write cache.", e);
} }
......
...@@ -281,10 +281,10 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -281,10 +281,10 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
reportStatusToListeners("Learned the optimal codebook."); reportStatusToListeners("Learned the optimal codebook.");
reportStatusToListeners("Saving cache file to %s", options.getOutputFilePath());
QuantizationCacheManager cacheManager = new QuantizationCacheManager(options.getCodebookCacheFolder()); QuantizationCacheManager cacheManager = new QuantizationCacheManager(options.getCodebookCacheFolder());
try { try {
cacheManager.saveCodebook(options.getInputDataInfo().getCacheFileName(), lbgResult.getCodebook()); final String cacheFilePath = cacheManager.saveCodebook(options.getInputDataInfo().getCacheFileName(), lbgResult.getCodebook());
reportStatusToListeners("Saved cache file to %s", cacheFilePath);
} catch (IOException e) { } catch (IOException e) {
throw new ImageCompressionException("Unable to write VQ cache.", e); throw new ImageCompressionException("Unable to write VQ cache.", e);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment