barcode image to Code39 conversion in C#?
Solution 1
See the CodeProject article: Reading Barcodes from an Image - II.
The author (James) improves (and credits) a previously written VB library to decode barcodes from an image using only .NET code.
There are two projects in the downloadable solution:
- The barcode library - written in C#
- The test app - written in VB
I have successfully used the C# code in VS2008 against a JPG image with an extended (includes alpha chars) code 39 barcode.
The library has the ability to scan an entire image for a barcode, where the barcode is only a portion. This has good and bad points. It is more flexible, but you may have to parse out noise. Of course, you will want to start with the cleanest image possible. Also, the scanned barcode must be fairly straight, not rotated or skewed at an angle.
If you can limit the scan to a "slice" of the actual barcode, you might get better accuracy.
In the article comments, another user submits a function that re-scans the barcode and uses a checksum digit, which is great if you control the printing of the original barcode and can include the checksum in the first place.
There are, of course some very impressive (and some very expensive) commercial solutions that have the advantage of being well-tested, more flexible, can scan more barcode formats, and are more tolerant of image quality due to improved image sampling. But this is a good (free) start!
You will need to sign up with CodeProject to download the code, but that is free also - and worth the time because there is so much good code on that site!
UPDATE: Incidentally, I just looked at the blog that Joachim Kerschbaumer mentions in another answer to your question. Definitely keep an eye on that project! It looks like a very robust solution. If it can read those skewed barcodes from those busy images, then it can do anything!
Solution 2
we've developed a c# component that reads values from barcodes of all dimension, rotation, quality etc. it's not yet release but we will release detailed information about it at http://blog.lemqi.com . it will be probably free (maybe open source). but maybe it's still 1-2 weeks till release as we have to refactor the code before.
XylemRaj
Updated on June 18, 2022Comments
-
XylemRaj almost 2 years
This is my code for selecting the date from a date picker.
import java.util.Calendar; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; public class CurrentDateActivity extends Activity { /** Called when the activity is first created. */ private EditText mDateDisplay,mDateSelect; private int mYear,mMonth,mDay; private int year,month,day; Button selectBtn = null; Calendar c = null; static final int DATE_DIALOG_ID = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.date_select); selectBtn = (Button)findViewById(R.id.BtnSubmit); mDateDisplay = (EditText) findViewById(R.id.currentDate); mDateSelect = (EditText)findViewById(R.id.dateofBirth); // add a click listener to the button mDateSelect.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(DATE_DIALOG_ID); } }); getCurrentDate();//get the current date // display the current date mDateDisplay.setText(getString(R.string.strSelectedDate, new StringBuilder() // Month is 0 based so add 1 .append(mDay).append("/") .append(mMonth + 1).append("/") .append(mYear).append(" ")) ); } private void getCurrentDate(){ // get the current date c = Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH); mDay = c.get(Calendar.DAY_OF_MONTH); } // updates the date in the EditText private void updateDisplay() { mDateSelect.setText(getString(R.string.strSelectedDate, new StringBuilder() .append(mDay).append("/") .append(mMonth + 1).append("/") .append(mYear).append(" ")) ); } // the callback received when the user "sets" the date in the dialog private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; updateDisplay(); } }; @Override protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay); } return null; } }
Everything is fine but now i want to get both the current date and the date entered by the user in another activity in order to calculate the difference between them. But how to pass the date in intent i am not able to understand.Please help
-
Prashant Borde over 10 yearsRefer to this question
-
floriangosse over 10 yearsI'm not a android pro but maybe this post can help you: [How to pass object from one activity to another in Android][1] [1]: stackoverflow.com/a/2736612/1751277
-
-
Luke Quinane about 15 yearsHi Joachim, is there any progress on releasing your project?
-
Joachim Kerschbaumer about 15 yearshi Luke, as we are both currently working on our master thesis next to work, the release of project bamby will probably suspended till the end of may. we were also asked by atalasoft for a cooperation, but as i said, due to a lack of time, release will probably be delayed till may
-
Chris about 15 yearsMake sure you post on your blog when you release it! Very interested!
-
akeem almost 15 yearsThis code works great - takes a few seconds to scan every barcode on an A4 piece of paper at 200dpi.