Skip to content

Instantly share code, notes, and snippets.

@liuchang0812
Created April 14, 2013 13:40
Show Gist options
  • Save liuchang0812/5382774 to your computer and use it in GitHub Desktop.
Save liuchang0812/5382774 to your computer and use it in GitHub Desktop.
#include <QCoreApplication>
#include "highgui.h"
#include "cv.h"
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std ;
using namespace cv ;
vector< vector<int> > f1 , f2 ; //直方图
vector<int> getHist(IplImage *img)
{
vector<int> tmp(10) ;
int h , w ;
h = img->height ;
w = img->width ;
for ( int i = 0;i < h;i ++)
for ( int j = 0;j < w;j ++)
{
CvScalar s = cvGet2D (img,i , j ) ;
tmp[s.val[0] / 26] ++ ;
}
for ( int i = 0;i < 10;i ++)
printf("%d %d\n" , i , tmp[i]) ;
return tmp ;
}
vector<vector<int> > getHistList(char* filename)
{
vector<vector<int> > tmp ;
CvCapture* capture = cvCreateFileCapture (filename) ;
IplImage* frame ;
while (1) {
frame = cvQueryFrame (capture) ;
if (!frame) break ;
tmp.push_back( getHist(frame)) ;
}
cvReleaseCapture(&capture) ;
return tmp ;
}
int main2(int argc, char *argv[])
{
//QCoreApplication a(argc, argv);
/*
char* filename1 = "D:\\Wildworld.wmv" ;
char* filename2 = "D:\\Wildworld2.wmv" ;
IplImage* img = cvLoadImage ("D:\\flag.jpg") ;
getHist(img) ;
*/
cout << "hello world!"<<endl;
//return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment