예제 #1
0
        BusCardProcessingSettings GetBusCardProcessingSettings()
        {
            BusCardProcessingSettings result = new BusCardProcessingSettings();

            result.Language = getLanguages();

            return(result);
        }
예제 #2
0
        public NamecardRecognizer()
        {
            this._restClientAsync = new RestServiceClientAsync(this._restClient);
            this._restClientAsync.UploadFileCompleted     += UploadCompleted;
            this._restClientAsync.TaskProcessingCompleted += ProcessingCompleted;
            this._restClientAsync.DownloadFileCompleted   += DownloadCompleted;

            this._settings = GetBusCardProcessingSettings();
        }
        public OcrSdkTask ProcessBusinessCard(string filePath, BusCardProcessingSettings settings)
        {
            string url = String.Format("{0}/processBusinessCard?{1}", ServerUrl, settings.AsUrlParams);

            // Build post request
            WebRequest request = createPostRequest(url);

            writeFileToRequest(filePath, request);

            XDocument  response   = performRequest(request);
            OcrSdkTask serverTask = ServerXml.GetTaskStatus(response);

            return(serverTask);
        }
예제 #4
0
        void addFileTask(string filePath)
        {
            // Initialize output directory
            string outputDir = getOutputDir();

            // Different behavior for full-text recognition and business card recognition

            if (formatVCard.IsChecked == false)
            {
                ProcessingSettings settings = GetProcessingSettings();

                UserTask task = new UserTask(filePath);
                task.TaskStatus     = "Uploading";
                task.OutputFilePath = System.IO.Path.Combine(
                    outputDir,
                    System.IO.Path.GetFileNameWithoutExtension(filePath) + settings.OutputFileExt);

                _userTasks.Add(task);

                settings.Description = String.Format("{0} -> {1}",
                                                     System.IO.Path.GetFileName(filePath),
                                                     settings.OutputFileExt);

                restClientAsync.UploadFileAsync(filePath, settings, task);
            }
            else
            {
                // Business-card recognition
                BusCardProcessingSettings settings = GetBusCardProcessingSettings();

                UserTask task = new UserTask(filePath);
                task.TaskStatus     = "Uploading";
                task.OutputFilePath = System.IO.Path.Combine(
                    outputDir,
                    System.IO.Path.GetFileNameWithoutExtension(filePath) + ".vcf");

                _userTasks.Add(task);

                restClientAsync.ProcessBusinessCardAsync(filePath, settings, task);
            }
        }
예제 #5
0
        void addFileTask(string filePath)
        {
            // Initialize output directory
            string outputDir = getOutputDir();

            // Different behavior for full-text recognition and business card recognition

            if (modeGeneral.IsChecked == true)
            {
                ProcessingSettings settings = GetProcessingSettings();

                UserTask task = new UserTask(filePath);
                task.TaskStatus     = "Uploading";
                task.OutputFilePath = System.IO.Path.Combine(
                    outputDir,
                    System.IO.Path.GetFileNameWithoutExtension(filePath) + settings.GetOutputFileExt(settings.OutputFormats[0]));

                _userTasks.Add(task);

                settings.Description = String.Format("{0} -> {1}",
                                                     Path.GetFileName(filePath),
                                                     settings.GetOutputFileExt(settings.OutputFormats[0]));

                restClientAsync.ProcessImageAsync(filePath, settings, task);
            }
            else if (modeBcr.IsChecked == true)
            {
                // Business-card recognition
                BusCardProcessingSettings settings = GetBusCardProcessingSettings();
                string ext;
                if (formatVCard.IsChecked == true)
                {
                    settings.OutputFormat = BusCardProcessingSettings.OutputFormatEnum.vCard;
                    ext = ".vcf";
                }
                else
                {
                    settings.OutputFormat = BusCardProcessingSettings.OutputFormatEnum.xml;
                    ext = ".xml";
                }


                UserTask task = new UserTask(filePath);
                task.TaskStatus     = "Uploading";
                task.OutputFilePath = System.IO.Path.Combine(
                    outputDir,
                    System.IO.Path.GetFileNameWithoutExtension(filePath) + ext);

                _userTasks.Add(task);

                restClientAsync.ProcessBusinessCardAsync(filePath, settings, task);
            }
            else
            {
                // Machine-readable zone recognition

                UserTask task = new UserTask(filePath);
                task.TaskStatus     = "Uploading";
                task.OutputFilePath = System.IO.Path.Combine(
                    outputDir,
                    System.IO.Path.GetFileNameWithoutExtension(filePath) + ".xml");

                _userTasks.Add(task);
                restClientAsync.ProcessMrzAsync(filePath, task);
            }
        }