capex93

New member
Joined
Nov 26, 2021
Messages
2
Programming Experience
3-5
Hi All,
I am trying to implement an algorithm for the detection of the document presence in C# ( with .NET Framework 4.6.2). There is a document holder where the document is inserted. The document holder background is red. In front of the document holder there is a camera that takes a photo and the document presence must be detected from the image of this photo. I implemented an algorithm that calculate mean and variance of the pixels of the grayscale image bitmap. So if they are within a certain threshold, the algorithm detects the document presence. There can be several problems that cause me to return an incorrect result:
  1. possible light reflection;
  2. the document holder can be worn out;
  3. the camera may not be positioned correctly so the white or black edges cause a wrong result.

Do you have any better ideas?

Many thanks.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+
Moved over to the Components and Controls non-GUI section since the use of .NET Framework (and C# for that matter) is just incidental. The real problem is the detection approach and/or system.

Are you married to the just using a camera? Most commercial automatic document feeding systems are still dependent on a physical micro switch. Some are switching over to tiny LED/light detector pairs instead of physical switches.

What would cause poor camera placement in your system? Address that perhaps?

What does a worn out document holder cause? Too dark a baseline image pixel average? Too light? Scratches that skew the average?

Why compare average and variance? Why not just compare the absolute image values?
 
Last edited:

capex93

New member
Joined
Nov 26, 2021
Messages
2
Programming Experience
3-5
Moved over to the Components and Controls non-GUI section since the use of .NET Framework (and C# for that matter) is just incidental. The real problem is the detection approach and/or system.

Are you married to the just using a camera? Most commercial automatic document feeding systems are still dependent on a physical micro switch. Some are switching over to tiny LED/light detector pairs instead of physical switches.

What would cause poor camera placement in your system? Address that perhaps?

Thank you for reply.
Yes, I can only use the camera. The use of the camera is a constraint.
The camera is located inside a vending machine and it is often moved around. This causes poor camera placement in your system.
I would also like to improve the reliability of my algorithm with a solution based on a different idea.
Do you know .NET libraries that can help me? Or do you have a different approach in mind?

Many thanks
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+
Instead of using a plain background for the the empty document feeder, put a reference pattern that you can use so that the camera can determine how much it has shifted from the ideal alignment. When that reference pattern gets blocked by the actual document to be scanned, then you know that you have a document to be imaged.

Perhaps a simple level 1 QR code would make a good reference pattern.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+
The camera is located inside a vending machine and it is often moved around. This causes poor camera placement in your system.
Sounds like shoddy construction of the vending machine or of the camera holder. Consider that the external cameras placed on the SpaceX rockets undergo several Gs of shock and vibration and manage to stay pointed in the right direction.
 
Top Bottom