int main(int argc, char **argv) { get_args(argc, argv); get_files_name(); do_tests(); FILE *output = fopen(global_args.output_name, "w"); if (output == NULL) die(NULL); struct stat input_stat; stat(global_args.input_name, &input_stat); size_t st_size = input_stat.st_size; if (global_args.isdecompress) { reader_t *reader; init_reader(&reader); inflate(reader); delete_reader(&reader); } else { int rc1, rc2; pthread_t thread_static, thread_dynamic; size_t last_size, size = 0; size_t size_static, size_dynamic; io *io_static, *io_dynamic, *io_nocom; init_io(&io_static); init_io(&io_dynamic); init_io(&io_nocom); io_nocom->output_file = output; int k = 1; while (size < st_size) { printf("k = %d\n", k++); if (st_size - size >= BLOCK_SIZE) { last_size = BLOCK_SIZE; } else { last_size = st_size - size; io_static->isfinal = true; io_dynamic->isfinal = true; io_nocom->isfinal = true; } io_static->offset = size; io_static->block_size = last_size; io_dynamic->offset = size; io_dynamic->block_size = last_size; io_nocom->offset = size; io_nocom->block_size = last_size; rc1 = pthread_create(&thread_static, NULL, &static_deflate, io_static); rc2 = pthread_create(&thread_dynamic, NULL, &dynamic_deflate, io_dynamic); if (rc1 || rc2) die("thread creation failed"); pthread_join(thread_static, NULL); pthread_join(thread_dynamic, NULL); size_static = io_static->result; size_dynamic = io_dynamic->result; printf("ss = %d, sd = %d, sn = %d\n", size_static, size_dynamic, last_size); if (size_dynamic <= size_static && size_dynamic < last_size) { write_to_output(io_dynamic, output); copy_last_byte(io_static, io_dynamic); copy_last_byte(io_nocom, io_dynamic); size += io_dynamic->block_size; printf("block_size = %d, size = %d\n", io_dynamic->block_size, size); } else if (size_static <= size_dynamic && size_static < last_size) { write_to_output(io_static, output); copy_last_byte(io_dynamic, io_static); copy_last_byte(io_nocom, io_static); size += io_static->block_size; printf("block_size = %d, size = %d\n", io_static->block_size, size); } else { nocompress_deflate(io_nocom); copy_last_byte(io_static, io_nocom); copy_last_byte(io_dynamic, io_nocom); size += io_nocom->block_size; printf("block_size = %d, size = %d\n", io_nocom->block_size, size); } } delete_io(&io_static); delete_io(&io_dynamic); delete_io(&io_nocom); } free(global_args.output_name); fclose(output); exit(0); }
void main() { //vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Desktop\\송란이폴더\\랩세미나\\201603\\MunjaDB_IMG20160323\\*.bmp"); //vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Desktop\\송란이폴더\\랩세미나\\201603\\test\\*.bmp"); vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\character recognition\\*.bmp"); //char *str; //sprintf(str, "%ls", vFileNames[0].c_str()); //wcout << vFileNames.size() << endl; //for (int i = 0; i < vFileNames.size(); i++) //{ // wcout << vFileNames[i] << endl; //} //int width, height; CHARACTER *Database_Char=(CHARACTER *)calloc(vFileNames.size(), sizeof(CHARACTER)); CHARACTER charname[50]; int a,b; string nameout; string test; vector<vector< string> > featureArr(600, vector<string>(600)); int file_count = vFileNames.size(); for (int i = 0; i < vFileNames.size(); i++) { test = CW2A(vFileNames[i].c_str());//wstring->string Mat A = imread(test, IMREAD_GRAYSCALE); // 파일명에서 알파벳 추출 a = test.find('['); b = test.find(']'); nameout = test.substr(a + 1, b-a-1); Database_Char[i].shape = nameout; Char_Feature(A,A.rows,A.cols, Database_Char[i]);//샘플특징 //int y = (int)(Database_Char[i].ratey * 100); //int x = (int)(Database_Char[i].ratex * 100); //featureArr[y][x] = Database_Char[i].shape; } Filename(file_count, Database_Char, charname); //중복되는 문자 하나로 Char_Feature_avg(charname, file_count, Database_Char);// 특징평균값 for (int i = 0; i < 50; i++) { cout << charname[i].shape<<" "<< charname[i].ratex << " " << charname[i].ratey <<" / "<< charname[i].avg1<< " / "<< charname[i].avg2<<" / "<< charname[i].avg3<<" / "<< charname[i].avg4<<endl; } int Optnum; CHARACTER input_Char; //string temp; //vector<wstring> inputfilenames = get_files_name(L"C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\character recognition\\*.bmp"); char dbname[200]; for (int i = 1; i <89; i++) { //sprintf(dbname, "C:\\Users\\김송란\\Documents\\카카오톡 받은 파일\\문자추출\\test%03d.bmp", i); sprintf(dbname, "C:\\Users\\김송란\\Documents\\카카오톡 받은 파일\\문자추출리사이즈\\resize%03d.bmp", i); Mat B = imread(dbname, IMREAD_GRAYSCALE); Char_Feature(B, B.rows, B.cols, input_Char); OptSample(charname, input_Char, &Optnum); cout << i << " 입력문자는 " << charname[Optnum].shape << "특징 - "<<charname[Optnum].avg1<< " / "<< charname[Optnum].avg2<<" / "<< charname[Optnum].avg3<<" / "<< charname[Optnum].avg4<<endl; } //CHARACTER input_Char; //Mat B = imread("C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\lineImg.bmp", IMREAD_GRAYSCALE); //입력 이미지 //Binary(B); ////imshow("input", B); ////waitKey(0); // ////라벨링 //Mat labelImage(B.rows, B.cols, CV_16UC1); //int label_count=connectedComponents(B, labelImage, 8); // 0까지 포함된 갯수임 ////imwrite("label.bmp", labelImage); // //int y_max[255] = { 0 }, x_max[255] = { 0 }; //int y_min[255], x_min[255]; //for (int i = 0; i < 255; i++) //{ // y_min[i] = B.rows; // x_min[i] = B.cols; //} // //Mat C(B.rows, B.cols, CV_8UC1); //for (int i = 0; i < B.rows; i++) // for (int j = 0; j < B.cols; j++) // { // C.at<unsigned char>(i, j) = B.at<unsigned char>(i, j); // } // //Find_MaxMin(labelImage, y_max, x_max, y_min, x_min); //MakingBox(labelImage, C,B, y_max, x_max, y_min, x_min, label_count); //imwrite("abc.bmp", C); //imshow("output", B); //waitKey(0); /* Char_Feature(B, B.rows, B.cols, input_Char); int y = (int)(input_Char.ratey * 100); int x = (int)(input_Char.ratex * 100); double err1, err2; double min_err1 = 100.0, min_err2 = 100.0; int c, d; for (int i = y - 10; i <= y + 10; i++) for (int j = x - 10; j <= x + 10; j++) { if (featureArr[i][j] != NULL) { err1 = abs(y - i); if (err1 < min_err1) { min_err1 = err1; err2 = abs(x - j); if (err2 < min_err2) { min_err2 = err2; c= i; d = j; } } } else cout << "없음" << endl; } cout << featureArr[c][d] << endl; */ //구조체 전달 확인 //opt_num=OptSample(Database_Char, input_Char,min_err,file_count); }