forked from yhlleo/imageBinaryDataset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryDataset.h
68 lines (56 loc) · 1.74 KB
/
BinaryDataset.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Generate a binary format dataset of images for the
* convolutional neural network(CNN) based on tensorflow.
*
* dataform:
* - data: a nx3072 array of uint8s. Each row of the
* array stores a 32x32 colour image. The first 1024
* entries contain the red channel values, the next 1024
* the green, and the final 1024 the blue. The image is
* stored in row-major order, so that the first 32 entries
* of the array are the red channel values of the first
* row of the image.
* - labels: a list of n numbers in the range 0-9. The
* number at index i indicates the label of the ith image
* in the array data.
* Each file contains n such 3073-byte.
*
* Editor: Yahui Liu.
* Data: 2016-03-03
* Email: [email protected]
* Address: Computer Vision and Remote Sensing(CVRS) Lab, Wuhan University.
*/
#ifndef BINARY_DATASET_H
#define BINARY_DATASET_H
#pragma once
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include "cv.h"
#include "highgui.h"
using namespace std;
using namespace cv;
class BinaDataset
{
public:
BinaDataset()
{
_iHeight = 32;
_iWidth = 32;
}
~CrackBinaDataset(){}
public:
void images2BinaryFile( std::string filefolder, std::vector<std::string>& img_list,
std::vector<int>& img_labels, std::string filename );
void mat2Binary( std::string& image_file, int label, FILE*& fp );
void convertMat2Bin( cv::Mat& image, int label, FILE*& fp );
// cv::Mat imageReshape( cv::Mat& input );
std::string getFileName( std::string & filename );
std::vector<std::string> getFileLists( std::string file_folder );
public:
int _iHeight;
int _iWidth;
};
#endif // BINARY_DATASET_H