C#µ÷Óà C DLLÎÊÌ⣬¶®µÄÀ´ÇÀ·ÖÁË
//C ½Ó¿Ú
extern "C"
{
TESSDLL_API int __cdecl GetTessText(const char *imagefile, char *text);
}
//ÎÒÔÚC#ÖÐÉùÃ÷
//µ÷ÓÃC DLL Öеĺ¯Êý
[DllImport("OCRapi.dll", EntryPoint = "GetTessText", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl)]
public static extern int GetTessText(char[] imagefile, char[] text);
µ÷ÓôúÂ룺
char[] imagefile = "D:\\My Documents\\\baidu\\1.bmp".ToCharArray();
char[] textResult = new char[256];
int i = OCRAPI.GetTessText(imagefile, textResult);
³öÏÖµÄÎÊÌ⣺
textResult µÃ²»µ½·µ»ØÖµ
JF
1LÕý½â
?
OCRapi.dll,¹¦ÄÜÊÇʲô? ²ÎÊýÊÇÊäÈ룬»¹ÊÇ·µ»Ø£¬Â¥Ö÷û˵Ç壮
Èç¹ûÊäÈëÊÇͼÐÎÎļþ£¬Êä³öÊÇÎı¾£¬ÎÄ×Öʶ±ðÈí¼þ£¬·µ»ØµÄ²ÎÊýÇ°¼Ó ref string¡¡ÊäÈëÓ¦¸ÃÊÇ byte[]
ʵ¼ÊÈçºÎ£¬ÕâЩÔÚº¯ÊýÔÐ͵ÄÎĵµÖÐÓ¦¸ÃÓÐ˵Ã÷µÄ£®
Ó¦¸ÃÊÇÀàÐͶÔÓ¦²»¶Ô
幫頂£¡
C# code:
[DllImport("OCRapi.dll", EntryPoint = "GetTessText", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl)]
public static extern int GetTessText(string imagefile, string text);
{{-
Ïà¹ØÎÊ´ð£º
13¸öÈËΧ³ÉһȦ£¬´ÓµÚÒ»¸öÈË¿ªÊ¼Ë³Ðò±¨ºÅ1£¬2£¬3¡£·²±¨µ½3ÕßÍ˳öȦ×Ó£¬ÕÒ³ö×îºóÁôÔÚȦ×ÓÖеÄÈËÔÀ´µÄÐòºÅ
½á¹ûÓ¦¸ÃÊÇ13 ¿ÉÎҵijÌÐòµÄ½á¹ûÊÇ11 Ï£ÍûºÃÐÄÈË°ï¸ÄÒ»ÏÂ
#include <stdio.h>
#include < ......
ÒÔÇ°ÔÚVCÀïÃ潨һ¸ö¹¤³Ì£¬¶¼Ö»ÓÃÒ»¸ö .c Îļþ£¬×òÌìÔÚÒ»¸ö¹¤³ÌÀïÓÃÁËÁ½¸ö .cÎļþÁË£¬Óöµ½ÎÊÌâÁË£¬Çë´ó¼ÒÖ¸µã¡£±ÈÈ磺
File1.c Fil ......
µØµãÔÚÉîÛÚÄÏɽ
¡¡¡¡×öCÈí¼þ¡£ÊÔÓÃ2K£¬²»ÖªµÀתÕý¸ø¹«Ë¾Ì¸¶àÉÙºÏÊÊ°¡£¿
¡¡¡¡ÁíÍ⣬±¾ÈËС±¾£¬Ó¢ÓïÁù¼¶£¬ÊÔÓÃÈý¸öÔ±íÏÖµÃÒ²ËãÖÐÉÏˮƽ¡£µ«ÊÇÏÖÔÚ»¹²»ÄÜ×öÏîÄ¿¡£ÁíÍâ±ÏҵѧУûÓÐÃûÆø¡£
¡¡¡¡×ªÕý¸ø¹«Ë¾Ì¸¶àÉ ......
ͨ¹ýjava³ÌÐò£¬ÏȱàÒëc³ÌÐò£¬Èç³öÏÖ´íÎó£¬ÌáʾC³ÌÐòÖеĴíÎ󣬱àÒë³É¹¦¾ÍÔËÐУ¬ÏÔʾCµÄÔËÐнá¹û£¬×îºÃ°ÑCµÄÔËÐÐʱ¼äºÍÄÚ´æµÈ¶¼ÏÔʾ³öÀ´
¸÷λ´ó¸ç´ó½ã°ï°ï棬СµÜ¸Ð¼¤²»¾¡£¡
ÓÃjavaµÄ½ø³ÌÀàÊÔÊÔ
ÎÒ¸øÄãת ......
#include <stdio.h>
main()
{
int a,b,sum;
a=1;b=2;
sum=a+b;
printf("sum is %d\n");
}
½á¹ûÊÇ£º2367460
Ϊʲô£¿
printf("sum is %d\n", ......