AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Extracting Datamatrix Code for Decoding

The forum is to discuss topics related to different areas of image processing and computer vision.

Re: Extracting Datamatrix Code for Decoding

Postby andrew.kirillov » Thu Mar 15, 2012 10:51 am

With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2571
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Extracting Datamatrix Code for Decoding

Postby Cocco17 » Thu Mar 15, 2012 1:33 pm

yeah already tried this too.. But what exactly could it do for me? the doc says that there is no chance to get an information about the row or column in the picture..

hmm.. when I started, I thought it would be easier.. :lol: really gettin tired on that project.. but there are so many softwares where it works so great with any angle and rotation..

maybe you could try something.. I think barcode,qrcode and datamatrix recognition would be a great part of aforge.net ;)
Cocco17
 
Posts: 11
Joined: Thu Feb 23, 2012 12:49 pm

Re: Extracting Datamatrix Code for Decoding

Postby andrew.kirillov » Thu Mar 15, 2012 1:46 pm

Cocco17 wrote: But what exactly could it do for me? the doc says that there is no chance to get an information about the row or column in the picture..

If you analyse histogram, then you can find on which row/column something interesting starts/ends. At least try using these classes and then display these histograms to have a look on them and think how to interpret them.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2571
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Extracting Datamatrix Code for Decoding

Postby Cocco17 » Thu Mar 15, 2012 1:56 pm

andrew.kirillov wrote:If you analyse histogram, then you can find on which row/column something interesting starts/ends. At least try using these classes and then display these histograms to have a look on them and think how to interpret them.


Okay will try next week again. How can I get the Row or Column information from the Histogram?
Cocco17
 
Posts: 11
Joined: Thu Feb 23, 2012 12:49 pm

Re: Extracting Datamatrix Code for Decoding

Postby andrew.kirillov » Thu Mar 15, 2012 2:03 pm

1) You can check Min/Max properties of histogram, which tell you where values of histogram start/end (first/last none zero value in histogram). For vertical/horizontal histograms it will be row/column.
2) You can also check values of histograms and see how they change. In one of my quite old articles, I showed how histograms could be useful in detecting some objects.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2571
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Extracting Datamatrix Code for Decoding

Postby Cocco17 » Wed Mar 28, 2012 11:03 am

Okay Thanks Andrew :) now im getting this far:

Image

Next Problem: I have no clue how to fix the region. I see that now im getting the 18 peaks of my code in horizontal and vertical direction.

But scratches on the material could lead into wrong coordinates, like you can see on the picture... I am thinking about the width of the peaks.. they could be an indicator for a row or column, belonging to the code..

any helpful support or other idea ?
Cocco17
 
Posts: 11
Joined: Thu Feb 23, 2012 12:49 pm

Re: Extracting Datamatrix Code for Decoding

Postby andrew.kirillov » Wed Mar 28, 2012 11:44 am

There are few ideas to try:
1) You can filter those regions, which have thin (or very small) spikes on the histogram;
2) If you have data matrix, where every brick is separated from all others, then you may assume that data matrix bricks have certain size. If so, then you can remove everything else which is bigger than this (bigger then certain threshold).
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2571
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Extracting Datamatrix Code for Decoding

Postby Cocco17 » Wed Mar 28, 2012 12:58 pm

Oh boy! So Easy! Nobody told me that the Dilatation can be used more times. Thats the key for this problem.. used Dilatation 3 Times an now my Datamatrix code can be found as one big blob :) Finally! :D

Now another question:
I would like to do this whole this in real time on the webcampicture, like you always do in your programms... unfortunately my webcam picture slows extremely.. I copied the important steps into the Event New Video Frame:

Code: Select all
Public Sub video_NewFrame(sender As System.Object, e As NewFrameEventArgs)
        Dim img As Bitmap = DirectCast(e.Frame.Clone(), Bitmap)

        'Filteranwendungen
        Dim img_process = img
        Dim seq = New FiltersSequence

        seq.Add(Grayscale.CommonAlgorithms.BT709)
        seq.Apply(img_process)
        seq.Add(New OtsuThreshold)
        seq.Apply(img_process)
        seq.Add(New Dilatation)
        seq.Apply(img_process)
        seq.Add(New Dilatation)
        seq.Apply(img_process)
        seq.Add(New Dilatation)
        seq.Apply(img_process)
        PictureBox_Edge.Image = img_process

        'Erkennung
        Dim extractor = New BlobCounter
        extractor.FilterBlobs = True
        extractor.MinHeight = 50 'TrackBar_Minimum.Value
        extractor.MinWidth = 50 'TrackBar_Minimum.Value
        extractor.MaxHeight = 400 'TrackBar_Maximum.Value
        extractor.MaxWidth = 400 'TrackBar_Maximum.Value
        extractor.ProcessImage(img_process)

        Dim corners As List(Of IntPoint)
        Dim quadTransformer = New QuadrilateralTransformation

        For Each blob In extractor.GetObjectsInformation()
            Try
                ' Get Edge points of card
                edgepoints = extractor.GetBlobsEdgePoints(blob)
                corners = PointsCloud.FindQuadrilateralCorners(edgepoints)
                quadTransformer.SourceQuadrilateral = corners

                Dim Shape As New SimpleShapeChecker

                If Shape.IsQuadrilateral(corners) Then

                    PictureBox_DetectionReference.Image = quadTransformer.Apply(img)

                    '            'Einrahmen
                    Dim data As BitmapData = img.LockBits(New Rectangle(0, 0, Image_Clone.Width, Image_Clone.Height), ImageLockMode.ReadWrite, Image_Clone.PixelFormat)



                    Drawing.Polygon(data, corners, Color.Red)
                    For i As Integer = 0 To corners.Count - 1
                        Drawing.FillRectangle(data, New Rectangle(corners(i).X - 2, corners(i).Y - 2, 5, 5), Color.FromArgb(i * 32 + 127 + 32, i * 64, i * 64))
                    Next

                    img.UnlockBits(data)

                End If
            Catch ex As Exception
            End Try

        Next

        PictureBox_Webcam.Image = img
        Form1.Refresh()
    End Sub
Cocco17
 
Posts: 11
Joined: Thu Feb 23, 2012 12:49 pm



Previous

Return to Image Processing and Computer Vision

cron