Précédent   Forum du club des développeurs et IT Pro > Dotnet > Général Dotnet > Contribuez
Contribuez Proposez vos articles, cours, tutoriels, faq, sources pour .NET
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 02/01/2012, 17h10   #1
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
Par défaut IFilter pour images : Indexation des images sous Windows et SQL Server avec reconnaissance OCR

Bonjour,

Alors que je suis en train de travailler sur un projet perso de petite GED, j'ai eu besoin d'un filtre pour l'indexation de SQL Server, afin de reconnaître et indexer le texte contenu dans des images.

Voici donc le source de mon IFilter.

Il est en version initiale, et est certainement perfectible.

Il utilise Tesseract (Google projet d'un OCR open source). Je dois notamment améliorer l'utilisation de cet outil, afin de mieux l'intégrer à mon projet.

N'hésitez pas à me contacter si vous avez des questions/suggestions, ou si vous désirez m'aider à l'améliorer !

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
 
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
 
/*
 * To use the tagging of data types, the Chunk type (PropID) is the
 * propid from the schema.txt file; e.g. 
 * "D5CDD505-2E9C-101B-9397-08002B2CF9AE/PerceivedType" for
 * "Perceived Type".
 * Then GetValue() returns one string from the list of:
 * contact communications communications/e-mail communications/calendar communications/task
 * communications/im document/note document document/text document/spreadsheet document/presentation
 * music images images/picture images/video folder favorite program
 * 
 * Note also that the acceptable attributes (FULLPROPSPEC property sets)
 * are passed into aAttributes via Init(), if cAttributes is non-zero.
*/
 
namespace IFilterPicture
{
    /// <summary>
    /// The IFilter and IPersistFile interfaces, and some support structure
    /// for the File Filter (Extractor)
    /// </summary>
    [ComVisible(true), Guid("78BD7653-D16A-43ad-B119-7080D635F27E")]
    public class IFilterPicture : IPersistFile, IFilter
    {
        private static string myGuid = "78BD7653-D16A-43ad-B119-7080D635F27E"; /// <summary>For convenience, GUID in a string</summary>
        //private static string myHandlerGUID = "{60995D18-5F02-4196-B618-5D9C2A6ABC9D}"; /// <summary>We don't use this here, but it's needed for the registry.</summary>
 
        private bool bApplyIndexAttributes = false;
        private bool bCrawlAttributes = false;
        private bool bApplyOther = false;
 
        private bool doneFirstChunk = false;
 
        private string currentFileName = string.Empty;
        private int iChunkCount = 0;
 
        private const uint LANGUAGE_FR = 0x040C;
 
        private string text;
 
        public IFilterPicture()
        {
#if DEBUG
            _writeLog("On construit IFilterPicture()");
#endif
        }
 
        //	IFilter Methods
        /// <summary>Initializes a filtering session.</summary>
        /// <param name="grfFlags">What processing to perform</param>
        /// <param name="cAttributes">How many Attribute elements are in the aAttributes array, may be 0</param>
        /// <param name="aAttributes">Attributes to process</param>
        /// <param name="pdwFlags"></param>
        public void Init([MarshalAs(UnmanagedType.U4)] IFILTER_INIT grfFlags, uint cAttributes, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] FULLPROPSPEC[] aAttributes, ref uint pdwFlags)
        {
#if DEBUG
            _writeLog("On entre dans Init()");
#endif
            bApplyIndexAttributes = ((grfFlags & IFILTER_INIT.APPLY_INDEX_ATTRIBUTES) == IFILTER_INIT.APPLY_INDEX_ATTRIBUTES);
            bCrawlAttributes = ((grfFlags & IFILTER_INIT.APPLY_CRAWL_ATTRIBUTES) == IFILTER_INIT.APPLY_CRAWL_ATTRIBUTES);
            bApplyOther = ((grfFlags & IFILTER_INIT.APPLY_OTHER_ATTRIBUTES) == IFILTER_INIT.APPLY_OTHER_ATTRIBUTES);
#if DEBUG
            _writeLog("On sort de Init()");
#endif
        }
 
        /// <summary>
        /// Loads the first chunk or sets the pointers to zero on fail
        /// </summary>
        /// <returns></returns>
        private bool getFirstChunk()
        {
#if DEBUG
            _writeLog("On entre dans getFirstChunk()");
#endif
 
            if ((currentFileName == null) || (File.Exists(currentFileName) == false))
            {
                currentFileName = "";
#if DEBUG
                _writeLog("On n'a pas de fichier Ã* indexer (?)");
                _writeLog("On sort de getFirstChunk()");
#endif
                return false;
            }
 
#if DEBUG
            _writeLog(string.Format("On index le fichier {0}", currentFileName));
#endif
            try
            {
                TesseractOCR tess = new TesseractOCR(Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(IFilterPicture)).Location) + @"\tesseract.exe");
                text = tess.OCRFromFile(currentFileName);
            }
            catch (Exception e)
            {
#if DEBUG
                _writeLog(string.Format("Erreur : {0}", e.Message));
#endif
                text = "crashed";
            }
 
#if DEBUG
            _writeLog("On sort de getFirstChunk()");
#endif
 
            return true;
        }
 
        /// <summary>The IFilter::GetChunk method positions the filter at the beginning of the next chunk, or at the first chunk if this is the first call to the GetChunk method, and returns a description of the current chunk.</summary>
        /// <remarks>Each chunk might be tiny; the file extractor (filter) decides.
        /// Note that Chunk ID 0 is invalid; must start at 1.</remarks>
        /// <param name="pStat">STAT_CHUNK pointer</param>
        [PreserveSig]
        public int GetChunk(out STAT_CHUNK pStat)
        {
#if DEBUG
            _writeLog("On entre dans GetChunk()");
#endif
 
            bool bSuccess = true;
            STAT_CHUNK myStat = new STAT_CHUNK();
            pStat = myStat;
            pStat.locale = LANGUAGE_FR;
            iChunkCount++;
            pStat.idChunk = (uint)iChunkCount;
 
            if (iChunkCount == 2)
            {
#if DEBUG
                _writeLog("On sort de GetChunk()");
#endif
                return Constants.FILTER_E_END_OF_CHUNKS;
            }
 
            if (!doneFirstChunk)
            {
#if DEBUG
                _writeLog("!doneFirstChunk");
#endif
                doneFirstChunk = true;
                bSuccess = getFirstChunk();
            }
 
            if (!bSuccess)
            {
#if DEBUG
                _writeLog("!bSuccess");
                _writeLog("On sort de GetChunk() avec le message Constants.FILTER_E_END_OF_CHUNKS");
#endif
                return Constants.FILTER_E_END_OF_CHUNKS;
            }
            pStat.flags = CHUNKSTATE.CHUNK_TEXT;
 
            pStat.attribute.guidPropSet = new Guid(0xb725f130, 0x47ef, 0x101a, 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac);
            pStat.attribute.psProperty.ulKind = (int)PSKIND.PROPID;
            pStat.attribute.psProperty.propid = Constants.PID_STG_CONTENTS;
            pStat.idChunkSource = pStat.idChunk;
            pStat.breakType = CHUNK_BREAKTYPE.CHUNK_EOC;
            pStat.cwcStartSource = 0;
#if DEBUG
            _writeLog("On sort de GetChunk() avec le message Constants.FILTER_E_END_OF_CHUNKS");
#endif
            return Constants.S_OK;
        }
 
        /// <summary>Gets the text from this chunk of type CHUNK_TEXT</summary>
        /// <param name="pcwcBuffer">Size of input buffer in UNICODE characters; fill with output size in CHARACTERS</param>
        /// <param name="buffer">Null-terminated UNICODE string of the text.</param>
        /// <returns></returns>
        /// <remarks>This is called repeatedly INSIDE THE ONE CHUNK until all the text 
        /// is delivered.</remarks>
        [PreserveSig]
        public int GetText(ref int pcwcBuffer, IntPtr buffer)
        {
#if DEBUG
            _writeLog("On entre dans GetText()");
#endif
            pcwcBuffer = text.Length;
            Marshal.Copy(text.ToCharArray(), 0, buffer, text.Length);
#if DEBUG
            _writeLog("On sort de GetText()");
#endif            
            return Constants.FILTER_S_LAST_TEXT;
        }
 
        /// <summary>Retrieves a value (internal value-type property) from a chunk, which must have a CHUNKSTATE enumeration value of CHUNK_VALUE.</summary>
        /// <param name="ppPropValue"></param>
        /// <remarks>According to the blog, the most important ones are:
        /// DocAuthor, PrimaryDate, PercievedType and DocTitle.
        /// PerceivedTypes include contact, communications/calendar
        ///		document/note and communications/task</remarks>
        ///		
        [PreserveSig]
        public int GetValue(UIntPtr ppPropValue)
        {
#if DEBUG
            _writeLog("On entre (et sort) de GetValue()"); 
#endif
            return Constants.FILTER_E_NO_VALUES;
        }
 
        /// <summary>Returns the class identifier (CLSID) for the component object. In the case 
        /// of a filter, this is the file type identifier.</summary>
        /// <param name="pClassID"></param>
        public void GetClassID(out Guid pClassID)
        {
#if DEBUG
            _writeLog("On entre (et sort) de GetClassID()");
#endif
            pClassID = new Guid(myGuid);
        }
        public void BindRegion([MarshalAs(UnmanagedType.Struct)]FILTERREGION origPos, ref Guid riid, ref UIntPtr ppunk)
        {
#if DEBUG
            _writeLog("On entre (et sort) de BindRegion()");
#endif
            return;
        }
 
 
        /// <summary>Open and initialize the file</summary>
        /// <param name="pszFileName">Absolute file path to open/initialize</param>
        /// <param name="dwMode">STGM flags for how to open</param>
        /// <remarks>The STGM Flags provide 18 options and additional combinations for how to open
        /// and process the file.  Since IFilters are inherently read-only to the IPersist:: file, 
        /// most of these are irrelevant.  So we're ignoring it.</remarks>
        public void Load(string pszFileName, int dwMode)
        {
#if DEBUG
            _writeLog("On entre dans Load()");
            _writeLog(string.Format("On indexe {0}", pszFileName));
#endif
            currentFileName = pszFileName;
#if DEBUG
            _writeLog("On sort de Load()");
#endif
        }
 
#if DEBUG
        static public void _writeLog(string text)
        {
            string logFileName = "c:\\in\\logfile.txt";
            StreamWriter mylog = new StreamWriter(logFileName, true);
            if (mylog != null)
                mylog.WriteLine(DateTime.Now.ToLongTimeString() + " " + text);
            mylog.Close();
 
        }
#endif
 
        //	These are stubs needed for the interface but never called for Read-Only Access
        public void GetCurFile(out string ppszFileName) { ppszFileName = currentFileName; }
        public int IsDirty() { return Constants.E_NOTIMPL; }
        public void Save(string pszFileName, bool fRemember) { }
        public void SaveCompleted(string pszFileName) { }
    }
 
 
 
    [Flags]
    public enum IFILTER_INIT
    {
        NONE = 0,
        CANON_PARAGRAPHS = 1,
        HARD_LINE_BREAKS = 2,
        CANON_HYPHENS = 4,
        CANON_SPACES = 8,
        APPLY_INDEX_ATTRIBUTES = 16,
        APPLY_CRAWL_ATTRIBUTES = 256,
        APPLY_OTHER_ATTRIBUTES = 32,
        INDEXING_ONLY = 64,
        SEARCH_LINKS = 128,
        FILTER_OWNED_VALUE_OK = 512
    }
 
    [Flags]
    public enum IFILTER_FLAGS
    {
        OLE_PROPERTIES = 1
    }
 
    /// <summary>Describes what separates the CURRENT chunk from the PREVIOUS chunk with the same Attribute.
    /// Used by IFilter::GetChunk() in the return.</summary>
    public enum CHUNK_BREAKTYPE
    {
        CHUNK_NO_BREAK = 0,	/// <summary>No Break from previous and doesn't get flags/attributes; glue them </summary>
        CHUNK_EOW = 1,		/// <summary>Reached the End-Of-Word.  Don't use it; language dependent.</summary>
        CHUNK_EOS = 2,		/// <summary>Sentence Break</summary>
        CHUNK_EOP = 3,		///	<summary>Paragraph Break</summary>
        CHUNK_EOC = 4		///	<summary>Chapter Break</summary>
    }
 
    [Flags]
    public enum CHUNKSTATE
    {
        CHUNK_TEXT = 0x1,
        CHUNK_VALUE = 0x2,
        CHUNK_FILTER_OWNED_VALUE = 0x4
    }
 
    public enum PSKIND
    {
        LPWSTR = 0,
        PROPID = 1
    }
 
    // [StructLayout(LayoutKind.Sequential)]
    [StructLayout(LayoutKind.Explicit)]
    public struct PROPSPEC
    {
        [FieldOffset(0)]
        public uint ulKind;
        [FieldOffset(4)]
        public uint propid;
 
        //	NOTE: The real structure uses a Union.  C# doesn't support unions.  So I've commented
        //		  out this element to make the correct size.  Other samples don't do this.  TMcN
        [FieldOffset(4)]
        public IntPtr lpwstr;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct FULLPROPSPEC
    {
        public Guid guidPropSet;
        public PROPSPEC psProperty;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct STAT_CHUNK
    {
        public uint idChunk;
        [MarshalAs(UnmanagedType.U4)]
        public CHUNK_BREAKTYPE breakType;
        [MarshalAs(UnmanagedType.U4)]
        public CHUNKSTATE flags;
        public uint locale;
        [MarshalAs(UnmanagedType.Struct)]
        public FULLPROPSPEC attribute;
        public uint idChunkSource;
        public uint cwcStartSource;
        public uint cwcLenSource;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct FILTERREGION
    {
        public uint idChunk;
        public uint cwcStart;
        public uint cwcExtent;
    }
 
 
    [StructLayout(LayoutKind.Sequential)]
    public struct PROPVARIANT
    {
        public short vt;			/// <summary>Variant Type</summary>
        public short reserved1;
        public short reserved2;
        public short reserved3;
        unsafe
        public char* pwszVal;
    }
 
 
    [ComImport]
    [Guid("89BCB740-6119-101A-BCB7-00DD010655AF")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IFilter
    {
        void Init([MarshalAs(UnmanagedType.U4)] IFILTER_INIT grfFlags, uint cAttributes,
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] FULLPROPSPEC[] aAttributes,
            ref uint pdwFlags);
        [PreserveSig]
        int GetChunk(out STAT_CHUNK pStat);
 
 
        [PreserveSig]
        int GetText(ref int pcwcBuffer, IntPtr buffer);
        [PreserveSig]
        int GetValue(UIntPtr ppPropValue);
 
        void BindRegion([MarshalAs(UnmanagedType.Struct)]FILTERREGION origPos, ref Guid riid, ref UIntPtr ppunk);
    }
 
    [ComImport]
    [Guid("f07f3920-7b8c-11cf-9be8-00aa004b9986")]
    public class CFilter
    {
    }
 
    public class Constants
    {
        public const uint PID_STG_DIRECTORY = 0x00000002;
        public const uint PID_STG_CLASSID = 0x00000003;
        public const uint PID_STG_STORAGETYPE = 0x00000004;
        public const uint PID_STG_VOLUME_ID = 0x00000005;
        public const uint PID_STG_PARENT_WORKID = 0x00000006;
        public const uint PID_STG_SECONDARYSTORE = 0x00000007;
        public const uint PID_STG_FILEINDEX = 0x00000008;
        public const uint PID_STG_LASTCHANGEUSN = 0x00000009;
        public const uint PID_STG_NAME = 0x0000000a;
        public const uint PID_STG_PATH = 0x0000000b;
        public const uint PID_STG_SIZE = 0x0000000c;
        public const uint PID_STG_ATTRIBUTES = 0x0000000d;
        public const uint PID_STG_WRITETIME = 0x0000000e;
        public const uint PID_STG_CREATETIME = 0x0000000f;
        public const uint PID_STG_ACCESSTIME = 0x00000010;
        public const uint PID_STG_CHANGETIME = 0x00000011;
        public const uint PID_STG_CONTENTS = 0x00000013;
        public const uint PID_STG_SHORTNAME = 0x00000014;
        public const int FILTER_E_END_OF_CHUNKS = (unchecked((int)0x80041700));
        public const int FILTER_E_NO_MORE_TEXT = (unchecked((int)0x80041701));
        public const int FILTER_E_NO_MORE_VALUES = (unchecked((int)0x80041702));
        public const int FILTER_E_NO_TEXT = (unchecked((int)0x80041705));
        public const int FILTER_E_NO_VALUES = (unchecked((int)0x80041706));
        public const int FILTER_S_LAST_TEXT = (unchecked((int)0x00041709));
        public const int S_OK = (unchecked((int)0x00000000L));
        public const int S_FALSE = (unchecked((int)0x00000001L));
        public const int E_NOTIMPL = (unchecked((int)0x80004001L));
        public const int E_ABORT = (unchecked((int)0x80004004L));
 
    }
 
    public class TesseractOCR
    {
        private string commandpath;
        private string outpath;
 
        public TesseractOCR(string commandpath)
        {
#if DEBUG
            _writeLog("TesseractOCR()");
#endif
            this.commandpath = commandpath;
            outpath = Path.ChangeExtension(Path.GetTempFileName(), ".txt");
 
#if DEBUG
            _writeLog(string.Format("commandpath : {0}", commandpath));
            _writeLog(string.Format("outpath : {0}", outpath));
#endif
        }
        private string analyze(string filename)
        {
#if DEBUG
            _writeLog("analyze()");
#endif
            string args = string.Format("\"{0}\" \"{1}\" -l fra", filename, outpath.Replace(".txt", string.Empty));
#if DEBUG
            _writeLog(string.Format("args : {0}", args));
#endif
            ProcessStartInfo startinfo = new ProcessStartInfo(commandpath, args);
            startinfo.CreateNoWindow = true;
            startinfo.UseShellExecute = false;
#if DEBUG
            _writeLog(string.Format("commandpath : {0}", commandpath));
            if (!File.Exists(filename))
            {
                _writeLog(string.Format("Le fichier {0} n'existe pas !", filename));
            }
            _writeLog("Lancement de la reconnaissance OCR");
#endif
 
            Process.Start(startinfo).WaitForExit();
 
            string ret = "";
#if DEBUG
            if (!File.Exists(outpath))
            {
                _writeLog(string.Format("Le fichier {0} n'existe pas !", outpath));
            }
#endif            
            using (StreamReader r = new StreamReader(outpath))
            {
#if DEBUG
                _writeLog("lecture du fichier de sortie");
#endif
                string content = r.ReadToEnd();
                ret = content;
            }
#if DEBUG
            _writeLog(string.Format("ret : {0}", ret));
#endif
            File.Delete(outpath);
            return ret;
        }
 
        public string OCRFromFile(string filename)
        {
#if DEBUG
            _writeLog("OCRFromFile()");
#endif
            return analyze(filename);
        }
 
#if DEBUG
        static public void _writeLog(string text)
        {
            string logFileName = "c:\\in\\logfile2.txt";
            StreamWriter mylog = new StreamWriter(logFileName, true);
            if (mylog != null)
                mylog.WriteLine(DateTime.Now.ToLongTimeString() + " " + text);
            mylog.Close();
 
        }
#endif
    }
}
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2012, 17h20   #2
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
Par défaut Exemple

Voici en pièce jointe une image que j'ai indexé dans une table de SQL Server (je suis sous XP, je n'ai donc pas pu valider que l'indexation de Windows Search fonctionnait, même si en toute logique, elle doit).

Image indexée :
mcd2.PNG

Contenu de la table :
Code :
1
2
3
4
5
6
 
id                                   doc_id               user_id     title                                                                                                                                                                                                                                                            extension  doc
------------------------------------ -------------------- ----------- ------------------------- ---------- --------------------
32E78E7E-5C35-E111-B8EA-002197045CD6 8001                 260         mcd2.PNG                 .png       0x89504E470D0A1A0A00
2AA72F99-5C35-E111-B8EA-002197045CD6 8002                 260         test.doc                  .doc       0xD0CF11E0A1B11AE100
(2*ligne(s) affectée(s))
Recherche dans la table :
Code :
1
2
3
select *
from document
where contains(doc, '"verre" and "monture"');
Code :
1
2
3
4
id                                   doc_id               user_id     title                                                                                                                                                                                                                                                            extension  doc
------------------------------------ -------------------- ----------- ------------------------- ---------- --------------------
32E78E7E-5C35-E111-B8EA-002197045CD6 8001                 260         mcd2.PNG                 .png       0x89504E470D0A1A0A00
(1*ligne(s) affectée(s))
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 03/01/2012, 09h50   #3
chrisdot
Membre éprouvé
 
Homme Christophe
Développeur .NET
Inscription : juillet 2009
Messages : 412
Détails du profil
Informations personnelles :
Nom : Homme Christophe
Localisation : France

Informations professionnelles :
Activité : Développeur .NET

Informations forums :
Inscription : juillet 2009
Messages : 412
Points : 498
Points : 498
Salut,

Merci c'est très intéressant !

Juste une question (suis nul en BDD): le texté extrait est stocké par le système réellement comme index comme une clé primaire par exemple?

Merci,
A+

PS: Sinon, une remarque: il me semble que dans notre GED, les fichiers sont stockés sur un filesystem et ce sont uniquement les métadonnées (ce qui est extrait du document) qui sont stockées dans la BDD pour gérer les recherches. Apparemment pr une question de perfs...
chrisdot est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 10h06   #4
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
La DLL que je propose est un IFilter, c'est à dire un module utilisé par Index Server / Windows Search (et donc SQL Server) pour indexer les données textuelles d'un document.

Cela ne s'applique donc pas uniquement à SQL Server, mais le moteur de recherche de Windows aussi.

Ensuite, dans SQL Server, il s'agit d'allimenter un index fulltext. Ca ne ressemble en rien à un index classique, et son utilisation est toute autre.

Pour interroger un index fulltext, on utilise les fonctions CONTAINS ou FREETEXT (ou CONTAINSTABLE et FREETEXTTABLE).

Dans l'implémentation que j'ai choisi (qui est indépendante du sujet de ce topic), je stocke le document dans un FileStream aussi.
Je ne lis pas les méta-données du fichier (j'ajouterai peut-être cette fonctionnalité dans le future, mais ce n'est pas ce que je cherchais à faire au départ).
Je ne stocke rien d'autre dans la base de données. En revanche, lorsque le service d'indexation fulltext va analyser l'image, il va récupérer le texte retourné par l'OCR. Et c'est ça qu'il va mettre dans son index. En revanche, il est impossible de retrouver ce texte, j'ai pris la décision de ne pas le stocker, de la même façon qu'on ne s'amuse pas à recopier le texte contenu dans un document Word ou PDF dans la base de la GED.

Le IFilter se contente juste de faire une reconnaissance des caractères sur le fichier, puis de renvoyer au moteur d'indexation le texte détecté. Il n'y a aucune modification du fichier source, ni création d'un autre fichier/donnée.
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 10h45   #5
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
Pour lire les méta, je pense me baser sur ces liens :

http://msdn.microsoft.com/fr-fr/library/xddt0dz7.aspx
http://www.switchonthecode.com/tutor...ta-with-csharp

Le truc chiant, c'est que je vais devoir m'amuser avec les GetChunk(), GetValue() et tout le tralala, que j'avais gentillement esquivé dans le code actuel
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 13h27   #6
Nathanael Marchand
Rédacteur/Modérateur

 
Avatar de Nathanael Marchand
 
Homme Nathanael Marchand
Expert .Net So@t
Inscription : octobre 2008
Messages : 3 520
Détails du profil
Informations personnelles :
Nom : Homme Nathanael Marchand
Âge : 26
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Expert .Net So@t
Secteur : Conseil

Informations forums :
Inscription : octobre 2008
Messages : 3 520
Points : 7 962
Points : 7 962
C'est intéressant comme truc ca
N'hésite pas à en faire un article sur Developpez si ca te tente
Nathanael Marchand est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 15h27   #7
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
Je vais essayer de le compléter avant de faire un tel article.

Il faut absolument que j'ajoute la gestion des méta-données, et si possible, l'interfaçage à une DLL pour l'OCR, plutôt que la méthode actuelle (qui marche, certes).
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 15h29   #8
chrisdot
Membre éprouvé
 
Homme Christophe
Développeur .NET
Inscription : juillet 2009
Messages : 412
Détails du profil
Informations personnelles :
Nom : Homme Christophe
Localisation : France

Informations professionnelles :
Activité : Développeur .NET

Informations forums :
Inscription : juillet 2009
Messages : 412
Points : 498
Points : 498
Citation:
Envoyé par Nathanael Marchand Voir le message
N'hésite pas à en faire un article sur Developpez si ca te tente
++ !!

chrisdot est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2012, 12h11   #9
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
Un petit UP pour vous indiquer que j'ai fini par trouver une DLL permettant d'utiliser Tesseract 3 avec C#.
http://code.google.com/p/tesseractdotnet/

Je ne l'ai pas compilée moi-même, car je n'ai pas VC++ sur mon poste.
Ce n'est pas non plus la version qu'on trouve dans le lien ci-dessus, car elle ne fonctionne pas sur mon PC.

Il s'agit donc de la version que j'ai trouvé ici :
http://code.google.com/p/tesseractdo...es/detail?id=1
(Lien direct : http://tesseractdotnet.googlecode.co...A1327575785561)

J'en ai profité aussi pour supprimer les logs de DEBUG.

Je n'ai pas ajouté de nouvelle fonctionnalité au programme, en revanche ses performances et sa stabilité doivent être largement améliorées par l'utilisation directe d'une DLL pour faire le travail plutôt qu'un EXE avec génération d'un fichier texte temporaire sur le disque... Cela devrait aussi résoudre d'éventuels problèmes de droits d'accès (le service d'indexation n'a pas forcément accès en écriture/suppression au dossier où se trouve la DLL).

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
 
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using OCR.TesseractWrapper;
 
namespace IFilterPicture
{
    /// <summary>
    /// The IFilter and IPersistFile interfaces, and some support structure
    /// for the File Filter (Extractor)
    /// </summary>
    [ComVisible(true), Guid("78BD7653-D16A-43ad-B119-7080D635F27E")]
    public class IFilterPicture : IPersistFile, IFilter
    {
        private static string myGuid = "78BD7653-D16A-43ad-B119-7080D635F27E"; /// <summary>For convenience, GUID in a string</summary>
 
        private bool bApplyIndexAttributes = false;
        private bool bCrawlAttributes = false;
        private bool bApplyOther = false;
 
        private bool doneFirstChunk = false;
 
        private string currentFileName = string.Empty;
        private int iChunkCount = 0;
 
        private const uint LANGUAGE_FR = 0x040C;
 
        private string text;
 
        public IFilterPicture()
        {
        }
 
        //	IFilter Methods
        /// <summary>Initializes a filtering session.</summary>
        /// <param name="grfFlags">What processing to perform</param>
        /// <param name="cAttributes">How many Attribute elements are in the aAttributes array, may be 0</param>
        /// <param name="aAttributes">Attributes to process</param>
        /// <param name="pdwFlags"></param>
        public void Init([MarshalAs(UnmanagedType.U4)] IFILTER_INIT grfFlags, uint cAttributes, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] FULLPROPSPEC[] aAttributes, ref uint pdwFlags)
        {
            bApplyIndexAttributes = ((grfFlags & IFILTER_INIT.APPLY_INDEX_ATTRIBUTES) == IFILTER_INIT.APPLY_INDEX_ATTRIBUTES);
            bCrawlAttributes = ((grfFlags & IFILTER_INIT.APPLY_CRAWL_ATTRIBUTES) == IFILTER_INIT.APPLY_CRAWL_ATTRIBUTES);
            bApplyOther = ((grfFlags & IFILTER_INIT.APPLY_OTHER_ATTRIBUTES) == IFILTER_INIT.APPLY_OTHER_ATTRIBUTES);
        }
 
        /// <summary>
        /// Loads the first chunk or sets the pointers to zero on fail
        /// </summary>
        /// <returns></returns>
        private bool getFirstChunk()
        {
            if ((currentFileName == null) || (File.Exists(currentFileName) == false))
            {
                currentFileName = "";
                return false;
            }
 
            try
            {
                TesseractProcessor p = new TesseractProcessor();
                if (p.Init(Path.GetDirectoryName(Assembly.GetAssembly(typeof(IFilterPicture)).Location) + @"\fra.traineddata", "fra", (int)eOcrEngineMode.OEM_DEFAULT))
                {
                    text = p.Recognize(currentFileName);
                }
                else
                {
                    text = string.Empty;
                }
            }
            catch (Exception e)
            {
                text = string.Empty;
            }
 
            return true;
        }
 
        /// <summary>The IFilter::GetChunk method positions the filter at the beginning of the next chunk, or at the first chunk if this is the first call to the GetChunk method, and returns a description of the current chunk.</summary>
        /// <remarks>Each chunk might be tiny; the file extractor (filter) decides.
        /// Note that Chunk ID 0 is invalid; must start at 1.</remarks>
        /// <param name="pStat">STAT_CHUNK pointer</param>
        [PreserveSig]
        public int GetChunk(out STAT_CHUNK pStat)
        {
            bool bSuccess = true;
            STAT_CHUNK myStat = new STAT_CHUNK();
            pStat = myStat;
            pStat.locale = LANGUAGE_FR;
            iChunkCount++;
            pStat.idChunk = (uint)iChunkCount;
 
            if (iChunkCount == 2)
            {
                return Constants.FILTER_E_END_OF_CHUNKS;
            }
 
            if (!doneFirstChunk)
            {
                doneFirstChunk = true;
                bSuccess = getFirstChunk();
            }
 
            if (!bSuccess)
            {
                return Constants.FILTER_E_END_OF_CHUNKS;
            }
            pStat.flags = CHUNKSTATE.CHUNK_TEXT;
 
            pStat.attribute.guidPropSet = new Guid(0xb725f130, 0x47ef, 0x101a, 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac);
            pStat.attribute.psProperty.ulKind = (int)PSKIND.PROPID;
            pStat.attribute.psProperty.propid = Constants.PID_STG_CONTENTS;
            pStat.idChunkSource = pStat.idChunk;
            pStat.breakType = CHUNK_BREAKTYPE.CHUNK_EOC;
            pStat.cwcStartSource = 0;
            return Constants.S_OK;
        }
 
        /// <summary>Gets the text from this chunk of type CHUNK_TEXT</summary>
        /// <param name="pcwcBuffer">Size of input buffer in UNICODE characters; fill with output size in CHARACTERS</param>
        /// <param name="buffer">Null-terminated UNICODE string of the text.</param>
        /// <returns></returns>
        /// <remarks>This is called repeatedly INSIDE THE ONE CHUNK until all the text 
        /// is delivered.</remarks>
        [PreserveSig]
        public int GetText(ref int pcwcBuffer, IntPtr buffer)
        {
            pcwcBuffer = text.Length;
            Marshal.Copy(text.ToCharArray(), 0, buffer, text.Length);
            return Constants.FILTER_S_LAST_TEXT;
        }
 
        /// <summary>Retrieves a value (internal value-type property) from a chunk, which must have a CHUNKSTATE enumeration value of CHUNK_VALUE.</summary>
        /// <param name="ppPropValue"></param>
        /// <remarks>According to the blog, the most important ones are:
        /// DocAuthor, PrimaryDate, PercievedType and DocTitle.
        /// PerceivedTypes include contact, communications/calendar
        ///		document/note and communications/task</remarks>
        ///		
        [PreserveSig]
        public int GetValue(UIntPtr ppPropValue)
        {
            return Constants.FILTER_E_NO_VALUES;
        }
 
        /// <summary>Returns the class identifier (CLSID) for the component object. In the case 
        /// of a filter, this is the file type identifier.</summary>
        /// <param name="pClassID"></param>
        public void GetClassID(out Guid pClassID)
        {
            pClassID = new Guid(myGuid);
        }
 
        public void BindRegion([MarshalAs(UnmanagedType.Struct)]FILTERREGION origPos, ref Guid riid, ref UIntPtr ppunk)
        {
            return;
        }
 
 
        /// <summary>Open and initialize the file</summary>
        /// <param name="pszFileName">Absolute file path to open/initialize</param>
        /// <param name="dwMode">STGM flags for how to open</param>
        /// <remarks>The STGM Flags provide 18 options and additional combinations for how to open
        /// and process the file.  Since IFilters are inherently read-only to the IPersist:: file, 
        /// most of these are irrelevant.  So we're ignoring it.</remarks>
        public void Load(string pszFileName, int dwMode)
        {
            currentFileName = pszFileName;
        }
 
        //	These are stubs needed for the interface but never called for Read-Only Access
        public void GetCurFile(out string ppszFileName) { ppszFileName = currentFileName; }
        public int IsDirty() { return Constants.E_NOTIMPL; }
        public void Save(string pszFileName, bool fRemember) { }
        public void SaveCompleted(string pszFileName) { }
    }
 
    [Flags]
    public enum IFILTER_INIT
    {
        NONE = 0,
        CANON_PARAGRAPHS = 1,
        HARD_LINE_BREAKS = 2,
        CANON_HYPHENS = 4,
        CANON_SPACES = 8,
        APPLY_INDEX_ATTRIBUTES = 16,
        APPLY_CRAWL_ATTRIBUTES = 256,
        APPLY_OTHER_ATTRIBUTES = 32,
        INDEXING_ONLY = 64,
        SEARCH_LINKS = 128,
        FILTER_OWNED_VALUE_OK = 512
    }
 
    [Flags]
    public enum IFILTER_FLAGS
    {
        OLE_PROPERTIES = 1
    }
 
    /// <summary>Describes what separates the CURRENT chunk from the PREVIOUS chunk with the same Attribute.
    /// Used by IFilter::GetChunk() in the return.</summary>
    public enum CHUNK_BREAKTYPE
    {
        CHUNK_NO_BREAK = 0,	/// <summary>No Break from previous and doesn't get flags/attributes; glue them </summary>
        CHUNK_EOW = 1,		/// <summary>Reached the End-Of-Word.  Don't use it; language dependent.</summary>
        CHUNK_EOS = 2,		/// <summary>Sentence Break</summary>
        CHUNK_EOP = 3,		///	<summary>Paragraph Break</summary>
        CHUNK_EOC = 4		///	<summary>Chapter Break</summary>
    }
 
    [Flags]
    public enum CHUNKSTATE
    {
        CHUNK_TEXT = 0x1,
        CHUNK_VALUE = 0x2,
        CHUNK_FILTER_OWNED_VALUE = 0x4
    }
 
    public enum PSKIND
    {
        LPWSTR = 0,
        PROPID = 1
    }
 
    // [StructLayout(LayoutKind.Sequential)]
    [StructLayout(LayoutKind.Explicit)]
    public struct PROPSPEC
    {
        [FieldOffset(0)]
        public uint ulKind;
        [FieldOffset(4)]
        public uint propid;
 
        //	NOTE: The real structure uses a Union.  C# doesn't support unions.  So I've commented
        //		  out this element to make the correct size.  Other samples don't do this.  TMcN
        [FieldOffset(4)]
        public IntPtr lpwstr;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct FULLPROPSPEC
    {
        public Guid guidPropSet;
        public PROPSPEC psProperty;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct STAT_CHUNK
    {
        public uint idChunk;
        [MarshalAs(UnmanagedType.U4)]
        public CHUNK_BREAKTYPE breakType;
        [MarshalAs(UnmanagedType.U4)]
        public CHUNKSTATE flags;
        public uint locale;
        [MarshalAs(UnmanagedType.Struct)]
        public FULLPROPSPEC attribute;
        public uint idChunkSource;
        public uint cwcStartSource;
        public uint cwcLenSource;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct FILTERREGION
    {
        public uint idChunk;
        public uint cwcStart;
        public uint cwcExtent;
    }
 
 
    [StructLayout(LayoutKind.Sequential)]
    public struct PROPVARIANT
    {
        public short vt;			/// <summary>Variant Type</summary>
        public short reserved1;
        public short reserved2;
        public short reserved3;
        unsafe
        public char* pwszVal;
    }
 
 
    [ComImport]
    [Guid("89BCB740-6119-101A-BCB7-00DD010655AF")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IFilter
    {
        void Init([MarshalAs(UnmanagedType.U4)] IFILTER_INIT grfFlags, uint cAttributes,
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] FULLPROPSPEC[] aAttributes,
            ref uint pdwFlags);
        [PreserveSig]
        int GetChunk(out STAT_CHUNK pStat);
 
 
        [PreserveSig]
        int GetText(ref int pcwcBuffer, IntPtr buffer);
        [PreserveSig]
        int GetValue(UIntPtr ppPropValue);
 
        void BindRegion([MarshalAs(UnmanagedType.Struct)]FILTERREGION origPos, ref Guid riid, ref UIntPtr ppunk);
    }
 
    [ComImport]
    [Guid("f07f3920-7b8c-11cf-9be8-00aa004b9986")]
    public class CFilter
    {
    }
 
    public class Constants
    {
        public const uint PID_STG_DIRECTORY = 0x00000002;
        public const uint PID_STG_CLASSID = 0x00000003;
        public const uint PID_STG_STORAGETYPE = 0x00000004;
        public const uint PID_STG_VOLUME_ID = 0x00000005;
        public const uint PID_STG_PARENT_WORKID = 0x00000006;
        public const uint PID_STG_SECONDARYSTORE = 0x00000007;
        public const uint PID_STG_FILEINDEX = 0x00000008;
        public const uint PID_STG_LASTCHANGEUSN = 0x00000009;
        public const uint PID_STG_NAME = 0x0000000a;
        public const uint PID_STG_PATH = 0x0000000b;
        public const uint PID_STG_SIZE = 0x0000000c;
        public const uint PID_STG_ATTRIBUTES = 0x0000000d;
        public const uint PID_STG_WRITETIME = 0x0000000e;
        public const uint PID_STG_CREATETIME = 0x0000000f;
        public const uint PID_STG_ACCESSTIME = 0x00000010;
        public const uint PID_STG_CHANGETIME = 0x00000011;
        public const uint PID_STG_CONTENTS = 0x00000013;
        public const uint PID_STG_SHORTNAME = 0x00000014;
        public const int FILTER_E_END_OF_CHUNKS = (unchecked((int)0x80041700));
        public const int FILTER_E_NO_MORE_TEXT = (unchecked((int)0x80041701));
        public const int FILTER_E_NO_MORE_VALUES = (unchecked((int)0x80041702));
        public const int FILTER_E_NO_TEXT = (unchecked((int)0x80041705));
        public const int FILTER_E_NO_VALUES = (unchecked((int)0x80041706));
        public const int FILTER_S_LAST_TEXT = (unchecked((int)0x00041709));
        public const int S_OK = (unchecked((int)0x00000000L));
        public const int S_FALSE = (unchecked((int)0x00000001L));
        public const int E_NOTIMPL = (unchecked((int)0x80004001L));
        public const int E_ABORT = (unchecked((int)0x80004004L));
    }
}
En pièce jointe, le fichier de dictionnaire français nécessaire.

Si vous ne désirez pas l'utiliser, vous pouvez tenter de supprimer la ligne
Code :
1
2
 
p.Init(Path.GetDirectoryName(Assembly.GetAssembly(typeof(IFilterPicture)).Location) + @"\fra.traineddata", "fra", (int)eOcrEngineMode.OEM_DEFAULT)
Cependant, je ne sais pas si ça peut fonctionner sans... (j'en doute).
Si vous voulez utiliser une autre langue, il suffit de vous rendre sur le site du projet TesserAct et télécharger un autre dictionnaire.
http://code.google.com/p/tesseract-ocr/
Fichiers attachés
Type de fichier : 7z fra.7z (668,3 Ko, 11 affichages)
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/03/2012, 18h01   #10
kbz
Invité de passage
 
Inscription : mars 2005
Messages : 15
Détails du profil
Informations forums :
Inscription : mars 2005
Messages : 15
Points : 4
Points : 4
Salut,

Serai-t-il possible d'avoir un exemple d’implémentation ?

Merci beaucoup !
kbz est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/03/2012, 10h11   #11
StringBuilder
Membre Expert
 
Homme Sylvain Devidal
Chef de projets Générix
Inscription : février 2010
Messages : 1 517
Détails du profil
Informations personnelles :
Nom : Homme Sylvain Devidal
Âge : 34
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projets Générix
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : février 2010
Messages : 1 517
Points : 2 381
Points : 2 381
Bonjour,

Le code ci-dessus compile.

Ensuite tu n'as plus qu'à enregistrer convenablement la DLL produite (c'est un peu complexe à faire, il y a des tas de références croisées dans tous les sens) et ensuite ça marche tout seul.

En pièce jointe, tu trouveras le projet complet que j'ai créé.
Fichiers attachés
Type de fichier : 7z IFilterPicture.7z (1,56 Mo, 5 affichages)
StringBuilder est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/06/2012, 15h55   #12
tortuegenie
Membre expérimenté
 
Inscription : septembre 2007
Messages : 1 107
Détails du profil
Informations personnelles :
Âge : 29

Informations forums :
Inscription : septembre 2007
Messages : 1 107
Points : 591
Points : 591
Bonjour,

j'utilise actuellement un logiciel OCR et je stocke son contenu dans un ficher .txt.
Puis á l'aide d'un streamreader, je stocke le contenu du fichier texte dans ma base sqlserver.(VARCHAR(MAX)), seulement voila, la base étant limité en taille je me demade si l'indexation ne serait pas une solution.

Par contre je ne comprends pas ce que vous stocker dans la base, ni comment, Avez-vous un exemple pour faire cela.

Merci d'avance
tortuegenie est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 22h53.


 
 
 
 
Partenaires

Hébergement Web