Caffe源码中各种依赖库的作用及简单使用(6)

/*
 * Define memory hyperslab.
 */
 offset_out[0] = 3;
 offset_out[1] = 0;
 offset_out[2] = 0;
 count_out[0] = NX_SUB;
 count_out[1] = NY_SUB;
 count_out[2] = 1;
 status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL,
  count_out, NULL);

/*
 * Read data from hyperslab in the file into the hyperslab in
 * memory and display.
 */
 status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace,
  H5P_DEFAULT, data_out);
 for (j = 0; j < NX; j++) {
  for (i = 0; i < NY; i++) printf("%d ", data_out[j][i][0]);
  printf("\n");
 }
 /*
 * 0 0 0 0 0 0 0
 * 0 0 0 0 0 0 0
 * 0 0 0 0 0 0 0
 * 3 4 5 6 0 0 0
 * 4 5 6 7 0 0 0
 * 5 6 7 8 0 0 0
 * 0 0 0 0 0 0 0
 */

/*
 * Close/release resources.
 */
 H5Tclose(datatype);
 H5Dclose(dataset);
 H5Sclose(dataspace);
 H5Sclose(memspace);
 H5Fclose(file);

return 0;
}

int test_HDF5()
{
 //http://wenku.baidu.com/link?url=HDnqbrqqJ27GSvVGTcCbfM-bn5K2QCYxSlqTEtY_jwFvBVi3B97DK6s9qBUwXDjVgMHFQq-MLGSKcMKeGJkq87GF_8vchhsleRWISq9PwO3
 //http://baike.baidu.com/link?url=TqYZDUzu_XFMYa9XswMS1OVSyboWzu3RtK6L-DiOFZT6zugtXjBUIFa4QHerxZcSbPNuTO84BomEGgxpchWojK
 //http://www.docin.com/p-608918978.html
 // 1-->./examples/h5_write.c:This example writes data to the HDF5 file
 test_HDF5_write_HDF5_Data();
 // 2-->./examples/h5_read.c:This example reads hyperslab from the SDS.h5 file
 test_HDF5_read_HDF5_data();

return 0;
}

int test_Snappy()
{
 //http://baike.baidu.com/link?url=X8PCUvwS0MFJF5xS2DdzMrVDj9hNV8VsXL40W_jgiI1DeGNW5q5PsfEbL9RwUSrIilseenbFiulT1ceONYL5E_
 //exaples:./snappy_unittest.cc、snappy-test.cc
 //https://snappy.angeloflogic.com/cpp-tutorial/

char* filename = "E:/tmp/snappy/fireworks.jpeg";
 size_t input_length = 200;
 snappy_status status;
 size_t output_length = snappy_max_compressed_length(input_length);
 char* output = (char*)malloc(output_length);
 status = snappy_compress(filename, input_length, output, &output_length);
 if (status != SNAPPY_OK) {
  std::cout << "snappy compress fail!" << std::endl;
 }
 free(output);

size_t output_length1;
 snappy_status status1;
 status1 = snappy_uncompressed_length(filename, input_length, &output_length1);
 if (status != SNAPPY_OK) {
  std::cout << "get snappy uncompress length fail!" << std::endl;
 }
 char* output1 = (char*)malloc(output_length1);
 status1 = snappy_uncompress(filename, input_length, output1, &output_length1);
 if (status != SNAPPY_OK) {
  std::cout << "snappy uncompress fail!" << std::endl;
 }
 free(output1);

return 0;
}

Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明 

Caffe在Ubuntu 14.04 64bit 下的安装 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b4757544dc3cf42f4c437584fa8527cf.html