1
Vote

missing scanned pages using the feeder

description

when I scan 2 papers using the feeder, only 1 page is processed.

I traced the code and found that when I get to the method m_scanEngine_ScanCompleted in frmAutoScan class, the second page finds the bwUpdate.IsBusy to be true and thus skips processing that page.
void m_scanEngine_ScanCompleted(object sender, ScanCompletedEventArgs e)
        {
          
            // Enqueue the data
            m_threadPool.QueueUserWorkItem(ProcessImageWorker, e.Image);
            if (!bwUpdate.IsBusy)
            {
                bwUpdate.RunWorkerAsync();
              
            }
        }
how can we solve this issue?

comments

jf03cg wrote Jan 3 at 2:24 PM

Hi,

I am unable to reproduce this issue. Looking at the previous issue you had posted (http://omrmarkengine.codeplex.com/workitem/15) if, you commented out that line then this event will never be called. Is the line in issue 15 commented out in your copy?

oTamimi wrote Jan 4 at 6:53 AM

hi,

i just forked the repo to and pushed my changes so you can see,

the line in issue 15 is not commented out, if it was, then no outcome will be generated at all.

i add an integer variable "i" before the method ProcessImageWorker
        private int i = 0;
        /// <summary>
        /// Do work
        /// </summary>
        private void ProcessImageWorker(object state)
        {
            i++;
if i increment the variable at the bigging like above, and scan two pages , and then check i value after processing is finished. i = 2

if i increment the varialble here
lock (m_lockObject)
                            {
                                
                                m_executionQueue.Enqueue(new KeyValuePair<OmrTemplate, OmrPageOutput>(template, pageData));
                            }
then i = 1

oTamimi wrote Jan 4 at 8:48 AM

update:

It is always n-1 and it is always the last page.

the last page is processed through ProcessImageWorker but is added to the queue after data is exported to the CSV file.

oTamimi wrote Jan 4 at 8:53 AM

adding Trace.WriteLine
here
private void ProcessImageWorker(object state)
        {
            Trace.WriteLine("entered ProcessImageWorker");
            ScannedImage scannedImage = null;
and here
                            lock (m_lockObject)
                            {
                                Trace.WriteLine("adding to queue");
                                m_executionQueue.Enqueue(new KeyValuePair<OmrTemplate, OmrPageOutput>                                                          (template, pageData));
                            }
and here
 private void bwUpdate_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {

            Trace.WriteLine("entering run worker compeleted");
            // Execute
            while (m_executionQueue.Count > 0)
            {
generates this output
entered ProcessImageWorker
entered ProcessImageWorker
adding to queue
adding to queue
entered ProcessImageWorker
entering run worker compeleted
OmrScannerApplication.exe Information: 0 : Saving to E:\temp\censusData.csv
OmrScannerApplication.exe Information: 0 : Saving to E:\temp\censusData.csv
adding to queue
The thread 0x5b68 has exited with code 0 (0x0).
The thread 0x5ac8 has exited with code 0 (0x0).

oTamimi wrote Jan 4 at 8:54 AM

the last comment was for 3 pages scan

oTamimi wrote Jan 5 at 1:27 PM

Update:

I made a new fork, OMR2

this fork is almost identical to the original except of some minor changes that are irrelivant to this issue.

the problem still exists. I scan 40 pages, i get 39 in the outcome.
I scan 3 pages, i get 2 in the outcome.