Skip to content

Instantly share code, notes, and snippets.

@masazdream
Created February 16, 2014 05:01
Show Gist options
  • Select an option

  • Save masazdream/9029554 to your computer and use it in GitHub Desktop.

Select an option

Save masazdream/9029554 to your computer and use it in GitHub Desktop.
opencvを使った画像の入出力
/*
* ImageStream.cpp
*
* Created on: 2013/05/14
* Author: root
*/
#include "SprixImageStream.h"
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
/**
* ファイルに書き出す
*/
int cv_output_file(InputArray src, string fileName) {
const string file = string(fileName);
//const string file_name_str = "/home/recognize/validation/" + file + ".jpg";
vector<int> params(2);
// 品質(0-100) defalt:95
params[0] = CV_IMWRITE_JPEG_QUALITY;
params[1] = 100;
imwrite(fileName, src, params);
return 0;
}
void output_keypoints_on_image(Mat img, vector<KeyPoint> key_points,
string name) {
vector<KeyPoint>::iterator itk;
for (itk = key_points.begin(); itk != key_points.end(); ++itk) {
//cout << itk->pt << endl;
circle(img, itk->pt, 2, Scalar(0, 200, 0), 1);
}
cv_output_file(img, name);
//namedWindow(name, CV_WINDOW_AUTOSIZE);
//imshow(name, img);
//waitKey(0);
}
string int_to_string(int number) {
stringstream ss;
ss << number;
return ss.str();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment