#include "StdAfx.h"
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <vector>
#include<ppl.h>
using namespace cv;
using namespace std;
using namespace concurrency;
#define WINDOW_NAME "[程序窗口]"
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
#include <mutex>
// for filelisting
#include <stdio.h>
#include <io.h>
// for fileoutput
#include <string>
#include <fstream>
#include <sstream>
#include<iostream>
#define IMAGE_SIZE 256*256
#define IMAGE_WIDTH 256
#define IMAGE_HEIGHT 256
#define MAX_LINE 4*IMAGE_SIZE+1 //+1是因为最后一个字符不会读取
int main()
{
//生成模版集合
vector<float> scaleSet;
vector<float> angleSet;
vector<Mat> modelImageSet;
vector<int> modelPointSet;
vector<int> row, col;
vector<float> scale, angle, score;
/*
//待检测图片
Mat srcImage=imread("img/11.jpg");
Mat cannysrcImage, tempsrcImage;
blur(srcImage, srcImage,Size(3,3) );//blur的作用是对输入的图像src进行均值滤波
Canny(srcImage, cannysrcImage, 100, 200, 3, false);
imshow("原始图2", srcImage);
waitKey();
*/
char buf[MAX_LINE]; /*缓冲区*/
FILE *fp; /*文件指针*/
int len; /*行字符个数*/
if ((fp = fopen("E:\\CANNY\\CANNY\\CANNY.sim\\out_file0.txt", "r")) == NULL)
{
perror("fail to read");
exit(1);
}
if (fgets(buf, MAX_LINE, fp) != NULL)
{
len = strlen(buf); /*从指定的流 stream 读取一行,并把它存储在str所指向的字符串内。当读取(n - 1)个字符时,或者读取到换行符时,或者到达文件末尾时,它会停止*/
printf(":::::::%d\n", len);
/*for (int i = 0; i < len; i++)
{
printf("%c\n", buf[i]);
}*/
}
int image[IMAGE_SIZE];
int CombData;
for (int i = 0; i < len; i++)
{
int j = i % 4;
int k = i / 4;
int hundred, ten, unit;
if (j == 1)
{
if (buf[i] == 32) hundred = 0;//空格
else hundred = buf[i] - 48;
//printf("hundred:%d\n", hundred);
}
else if (j == 2)
{
if (buf[i] == 32) ten = 0;
else ten = buf[i] - 48;
//printf("ten:%d\n", ten);
}
else if (j == 3)
{
unit = buf[i] - 48;
//printf("unit:%d\n", unit);
CombData = hundred * 100 + ten * 10 + unit;
image[k] = CombData;
}
}
//for (int i = 0; i < 10; i++)
//{
// printf("%d\n", image[i]);
//}
#define IMAGE_WIDTH 256
#define IMAGE_HEIGHT 256
Mat ImageToShow = Mat(IMAGE_HEIGHT, IMAGE_WIDTH, CV_8UC1);
for(int i=0;i<IMAGE_HEIGHT;i++)
for (int j = 0; j < IMAGE_WIDTH; j++)
{
ImageToShow.at<uchar>(i, j) = image[i*IMAGE_WIDTH + j];
}
imshow("原始图", ImageToShow);
imwrite("E:\\CANNY\\CANNY\\CANNY.sim\\output.bmp", ImageToShow);
waitKey();
//char buf[max_line]; /*缓冲区*/
//file *fp; /*文件指针*/
//int len; /*行字符个数*/
//if ((fp = fopen("e:\\canny\\canny\\canny.sim\\out_file0.txt", "w")) == null)
//{
// perror("fail to read");
// exit(1);
//}
//char name[10] = { 55 ,56, 13 , 14 , 15 , 16 , 17 , 18 , 19 , '\0'};
//fputs(name, fp);
//return 0;
}
|