I'm trying to work with winforms c# samples, as eventually this is going in an existing winforms app.
I found a nice small example for taking input from a video camera and getting a barcode and then decoding it. Works great...
but it doesn't decode the type of barcode we are printing in-house, (i think it's code 39, but i'm not sure so i need a more general answer if possible.)
Here is the code i'm using, as my sample winform, there are several controls used but not declared here.
using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using AForge.Video; using AForge.Video.DirectShow; using ZXing;
namespace zxingTest { public partial class Form1 : Form { FilterInfoCollection filterInfoCollection; VideoCaptureDevice videoCaptureDevice; public Form1() { InitializeComponent(); }
private void button1_Click( object sender, EventArgs e )
{
videoCaptureDevice = new VideoCaptureDevice( filterInfoCollection[cboCamera.SelectedIndex].MonikerString );
videoCaptureDevice.NewFrame += FinalFrame_NewFrame;
videoCaptureDevice.Start();
}
private void Form1_Load( object sender, EventArgs e )
{
filterInfoCollection = new FilterInfoCollection( FilterCategory.VideoInputDevice );
foreach ( FilterInfo Device in filterInfoCollection )
cboCamera.Items.Add( Device.Name );
cboCamera.SelectedIndex = 0;
videoCaptureDevice = new VideoCaptureDevice();
timer1.Start();
}
private void FinalFrame_NewFrame( object sender, NewFrameEventArgs eventArgs )
{
pictureBox1.Image = ( Bitmap ) eventArgs.Frame.Clone();
}
private void timer1_Tick( object sender, EventArgs e )
{
BarcodeReader Reader = new BarcodeReader();
//BarDecoder
if (null != pictureBox1.Image)
{
Result result = Reader.Decode((Bitmap) pictureBox1.Image);
if (result != null)
{
txtResult.Text = result.ToString();
}
//Result result = Reader.((Bitmap) pictureBox1.Image);
//if ()
}
}
private void btnDecode_Click( object sender, EventArgs e )
{
//timer1.Start();
}
private void Form1_FormClosing( object sender, FormClosingEventArgs e )
{
if ( videoCaptureDevice.IsRunning == true )
videoCaptureDevice.Stop();
}
}
}
In the timer1_tick method, it decodes a UPC barcode just fine... but ours are ignored.
There are lots of examples for android, etc, but I can't find any for straight windows and I haven't found decoratively that its identical across implementations.
How do i convert the sample above to process more types, specifically code_93
I found info about using BarDecoder instead of BarReader, but it does not seem to be a declared type
Here is the barcode I'm trying to read