① 求教从图片中识别文字的方法和算法,谢谢!
你的文字是扫描仪扫描的打印文本,还是用户手写的?
对于前者要用OCR技术,google提供的免费开源ocr包很厉害的(好像叫tessertocr)!现在版本都3.0支持包括中文在内的很多语言。这是个c语言的包
如果是手写线条,,可以使用微软的tablet组件,他对中文的识别,和汉王不相上下,毕竟是花了10亿美元的货。这个c++ c#都能用,,
② C语言编程如何查找字符串中指定汉字
用数组比较方便,已兔字符为基准,前移两个找到个数,后移三个找到颜色
③ c语言 如何读取中文字符串
可以使用输入输出重定向来将TXT文本中的字符内容导入程序中,或者使用标准C库函数:fopen()和fgetc();
先使用fopen()函数打开TXT文本文件,然后使用fgetc读取文本文件中的字符。读取全部文本中全部字符可以使用一个while循环加判断是否读取到文件结尾来实现:
char ch;
while((ch= fgetc(fp)) != EOF)
这样当读取到文件结尾时,while循环就会终止。
C语文编写编译如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 100000
#define BUFLEN 1024
int main()
{
FILE *file;
char buf[BUFLEN];
int len=0,i=0;
char *array[MAXLINE];
file=fopen("test.txt","r");//打开TXST.TxT文件
if(!file)return -1;
while(fgets(buf,BUFLEN,file))//读取TXT中字符
{
len=strlen(buf);
array[i]=(char*)malloc(len+1);
if(!array[i])break;
strcpy(array[i++],buf);
}
fclose(file);
i--;
while(i>=0&&array[i])
{
printf("%s\n",array[i]);//打印test文档的字符
free(array[i--]);
}
}
④ C语言如何识别图片中的数字和字母,不能使用现有的库,只能在标准C下面做
这个功能要那么容易实现,网站上的验证码就要晕了。
⑤ 哪位朋友会C语言处理中文字符串就是如何查找一段中文字符串里的特定的汉字
#include<stdio.h>
#include<string.h>
intsp(char*s,char*v,char*f)
{
inti,t,lens=strlen(s),lenv=strlen(v);
for(i=0;i<lens;++i){
if(s[i]==v[0]){
for(t=0;t<lenv;++t){
if(v[t]==s[i+t])continue;
elsebreak;
}
if(t==lenv){
intlenf=strlen(f);
if(lenf==lenv)
for(t=0;t<lenf;++t)
s[i+t]=f[t];
return1;
}
}
}return0;
}
intmain()
{
charu[7];scanf("%s",u);
sp(u,"ab","ef");
printf("%s",u);
return0;
}
附上运行图,汉字同样操作
⑥ c语言文件内查找输出汉字
#include <stdio.h>
main() {
char key[] = "110105";
FILE *fp;
char line[2][20];
fp=fopen("file.txt", "r");
while(!feof(fp)) {
fscanf(fp, "%s", line[0]);
fscanf(fp, "%s", line[1]);
if (strncmp(line[0], key, 6)==0) {
printf("Found String is %s", line[1]);
break;
}
}
fclose(fp);
return 0;
}
你自己再修改一下,把key[]="110105"改为从命令行输入;
fp=fopen(...)加上打开失败的判断。
⑦ 怎么用程序(MATLAB和C语言都可以)识别图片文字(如下图),不一定要识别到100%,识别到一半以上就OK。
做相应字符的图片表,以单个字符大小读取原图进行查表比对,黑色匹配超过%即认为是当前字符
⑧ 如何用c语言的数组,来进行文字的查找
C语言中的标准函数库中的strchr()函数可以实现查找字符串中的某个字符。头文件: #include <string.h>函数原型:char *strchr(const char *s, int c);函数说明:从左向右,在字符串s中查找字符c首次出现的位置,如果找到返回c在s中的位置(指针),否则返回NULL例:<pre t="code" l="cpp">#include <stdio.h>
#include <string.h>
void main()
{
char str[]="hello world";
char *p=strchr(str, 'w');
if ( p )
printf("find 'w'!);
else
printf("not found!");
}相关函数:char *strrchr(const char *s, int c); 从右向左,查找s中最右边的匹配字符位置char *strstr(const char *s, const char *sub); //在s中查找sub子串出现的位置
⑨ 如何用c语言读取图片
#include
using namespace std;
#define Twoto1(i,j,w) i*w+j
void createimage(unsigned char *&img, int w, int h)
{img = new unsigned char[w*h];}
void delateimage(unsigned char*img)
{delete []img;}
void readimage(unsigned char*img, int w, int h, char *fname)
{
FILE *fp;
fopen_s(&fp,fname, "rb");
if (fp == NULL){ cout << "error" << endl; return; }
size_t result;
result=fread(img , sizeof(unsigned char), w*h, fp);
if (result != w*h)
{
cout << "Reading error" << endl;
return;
}
else
cout << "Reading Ok!" << endl;
fclose(fp);
}
void mobanjuanji(unsigned char image, unsigned char*image1, int w, int h, float moban[5][5])
{
for (int i = 0; i for (int j = 0; j if (iw - 3 || j>h - 3)
image1[Twoto1(i,j,w)] = 0;
else
{
float temp = 0;
for (int m = 0; m<5; m++)
for (int n = 0; n<5; n++)
{
temp += (image[Twoto1(i-2+m,j-2+n,w)] moban[m][n]);
}
if (temp>255) image1[Twoto1(i, j, w)] = 255;
else if (temp<0) image1[Twoto1(i, j, w)] = 0;
else image1[Twoto1(i, j, w)] = temp;
}
}
void saveimage(unsigned char *img, int w, int h, char *fname)
{
FILE *fp;
fopen_s(&fp, fname, "wb");
if (fp == NULL) { cout << "error" << endl; return; }
size_t result;
result = fwrite(img, sizeof(unsigned char), w*h, fp);
if (result != w*h)
{
cout << "Write error" << endl;
return;
}
else
cout << "Write Ok!" << endl;
fclose(fp);
}
void main()
{
unsigned char *img;
unsigned char *img1;
float moban[5][5] = { {0,0,0,0,0},{0, -1, 0, 1, 0 }, { 0, -2, 0, 2, 0 }, { 0, -1, 0, 1, 0 }, { 0,0,0,0,0 } };
//float moban[5][5] = { 0 };
int w = 512, h = 512;
createimage(img, w, h);
createimage(img1, w, h);
readimage(img, w, h, "E:ss.raw");
mobanjuanji(img, img1,w, h, moban);
saveimage(img, w, h, "E:ss_1.raw");
saveimage(img1, w, h, "E:ss_2.raw");
delateimage(img);
delateimage(img1);
}
(9)c语言可以查找图片中文字扩展阅读
C语言实现一个图片的读出和写入
#include <stdlib.h>
#include <windows.h>
int file_size(char* filename)//获取文件名为filename的文件大小。
{
FILE *fp = fopen(filename, "rb");//打开文件。
int size;
if(fp == NULL) // 打开文件失败
return -1;
fseek(fp, 0, SEEK_END);//定位文件指针到文件尾。
size=ftell(fp);//获取文件指针偏移量,即文件大小。
fclose(fp);//关闭文件。
return size;
}
int main ()
{
int size=0;
size=file_size("qw");
printf("%d ",size);
FILE * pFile,*qw;
char *buffer=(char*)malloc(sizeof(char)*size);
qw =fopen("qw","r");
pFile = fopen ( "qwe" , "wb" );
printf("%d==
",pFile);
printf("%d ",size);
fread(buffer,1,size,qw);
fwrite (buffer , sizeof(byte), size , pFile );
fclose (pFile);
rename("qwe","Groot.jpg");
return 0;
}
⑩ c语言中如何用字母去检索汉字名称 谢谢
这个实现起来很麻烦,不过方法还是有的,你可以定义一个字符数组,前面第一第二个元素存汉字,后面第三个元素存首字母,当然,也可以向文件里面写入一块内容,包含汉字和首字母,如果考虑多音字的话,可以遍历链表或者文件,程序是永远没有止尽的,没有做不到,只有想不到这句话在编程中是最适合用的。