Changed variable name: iscolor to is_color.
authorJerod Weinman <jerod@acm.org>
Sun, 8 Jun 2014 20:46:23 +0000 (15:46 -0500)
committerJerod Weinman <jerod@acm.org>
Sun, 8 Jun 2014 20:46:23 +0000 (15:46 -0500)
include/caffe/util/io.hpp
src/caffe/util/io.cpp
tools/convert_imageset.cpp

index 829293e..4458096 100644 (file)
@@ -61,7 +61,7 @@ inline void WriteProtoToBinaryFile(
 }
 
 bool ReadImageToDatum(const string& filename, const int label,
-    const int height, const int width, const bool iscolor, Datum* datum);
+    const int height, const int width, const bool is_color, Datum* datum);
 
 inline bool ReadImageToDatum(const string& filename, const int label,
     const int height, const int width, Datum* datum) {
index f2650e9..65f8254 100644 (file)
@@ -72,9 +72,10 @@ void WriteProtoToBinaryFile(const Message& proto, const char* filename) {
 }
 
 bool ReadImageToDatum(const string& filename, const int label,
-    const int height, const int width, const bool iscolor, Datum* datum) {
+    const int height, const int width, const bool is_color, Datum* datum) {
   cv::Mat cv_img;
-  int cv_read_flag = (iscolor ? CV_LOAD_IMAGE_COLOR : CV_LOAD_IMAGE_GRAYSCALE);
+  int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR :
+    CV_LOAD_IMAGE_GRAYSCALE);
   if (height > 0 && width > 0) {
     cv::Mat cv_img_origin = cv::imread(filename, cv_read_flag);
     cv::resize(cv_img_origin, cv_img, cv::Size(height, width));
@@ -85,7 +86,7 @@ bool ReadImageToDatum(const string& filename, const int label,
     LOG(ERROR) << "Could not open or find file " << filename;
     return false;
   }
-  int num_channels = (iscolor ? 3 : 1);
+  int num_channels = (is_color ? 3 : 1);
   datum->set_channels(num_channels);
   datum->set_height(cv_img.rows);
   datum->set_width(cv_img.cols);
@@ -93,7 +94,7 @@ bool ReadImageToDatum(const string& filename, const int label,
   datum->clear_data();
   datum->clear_float_data();
   string* datum_string = datum->mutable_data();
-  if (iscolor) {
+  if (is_color) {
     for (int c = 0; c < num_channels; ++c) {
       for (int h = 0; h < cv_img.rows; ++h) {
         for (int w = 0; w < cv_img.cols; ++w) {
@@ -102,7 +103,7 @@ bool ReadImageToDatum(const string& filename, const int label,
         }
       }
     }
-  } else {  // Faster than repeatedly testing iscolor for each pixel w/i loop
+  } else {  // Faster than repeatedly testing is_color for each pixel w/i loop
     for (int h = 0; h < cv_img.rows; ++h) {
       for (int w = 0; w < cv_img.cols; ++w) {
         datum_string->push_back(
index bbf848a..524d195 100644 (file)
@@ -45,8 +45,8 @@ int main(int argc, char** argv) {
   }
 
   // Test whether argv[1] == "-g"
-  bool iscolor= !(string("-g") == string(argv[1]));
-  int  arg_offset = (iscolor ? 0 : 1);
+  bool is_color= !(string("-g") == string(argv[1]));
+  int  arg_offset = (is_color ? 0 : 1);
   std::ifstream infile(argv[arg_offset+2]);
   std::vector<std::pair<string, int> > lines;
   string filename;
@@ -89,7 +89,7 @@ int main(int argc, char** argv) {
   bool data_size_initialized = false;
   for (int line_id = 0; line_id < lines.size(); ++line_id) {
     if (!ReadImageToDatum(root_folder + lines[line_id].first,
-         lines[line_id].second, resize_height, resize_width, iscolor, &datum)) {
+        lines[line_id].second, resize_height, resize_width, is_color, &datum)) {
       continue;
     }
     if (!data_size_initialized) {