Git Product home page Git Product logo

Comments (4)

micjahn avatar micjahn commented on August 15, 2024

I committed some changes to the repository which are introducing Kinect V2 a a new binding.
But I don't have a Kinect device. I can't test the assembly. I think the color conversion to luminance values which are done in the class ColorFrameLuminanceSource isn't working at all or only for some ColorImageFormats. I really need someone who are willing to build the assembly and check it against all ColorImageFormats.

from zxing.net.

maxime-beck avatar maxime-beck commented on August 15, 2024

Thanks for your answer! I did a quick little project to test it out but I get an IndexOutOfRangeException when invoking the Decode() method.

Code :

public partial class MainWindow : Window
{
    KinectSensor sensor;
    ColorFrameReader cfReader;
    byte[] cfDataConverted;
    WriteableBitmap cfBitmap;
    ZXing.Kinect.BarcodeReader reader;

    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += MainWindow_Loaded;
    }        

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        sensor = KinectSensor.GetDefault();
        cfReader = sensor.ColorFrameSource.OpenReader();
        FrameDescription fd = sensor.ColorFrameSource.FrameDescription;
        cfDataConverted = new byte[fd.LengthInPixels * 4];
        cfBitmap = new WriteableBitmap(fd.Width, fd.Height, 96, 96, PixelFormats.Pbgra32, null);            
        reader = new ZXing.Kinect.BarcodeReader();

        image.Source = cfBitmap;
        sensor.Open();

        cfReader.FrameArrived += CfReader_FrameArrived;
    }

    private void CfReader_FrameArrived(object sender, ColorFrameArrivedEventArgs e)
    {
        using (ColorFrame cfFrame = e.FrameReference.AcquireFrame())
        {
            if (cfFrame != null)
            {
                cfFrame.CopyConvertedFrameDataToArray(cfDataConverted, ColorImageFormat.Bgra);
                Int32Rect rect = new Int32Rect(0, 0, (int)cfBitmap.Width, (int)cfBitmap.Height);
                int stride = (int)cfBitmap.Width * 4;
                cfBitmap.WritePixels(rect, cfDataConverted, stride, 0);

                var result = reader.Decode(cfFrame); // Exception thrown here
                if (result != null)
                {
                    MessageBox.Show("Barcode is :" + result.Text);
                }
            }
        }
    }
}

TraceStack :
System.IndexOutOfRangeException :
at ZXing.RGBLuminanceSource.CalculateLuminanceYUYV(Byte[] yuyvRawBytes) line:359
at ZXing.RGBLuminanceSource.CalculateLuminance(Byte[] rgbRawBytes, BitmapFormat bitmapFormat)
at ZXing.Kinect.ColorFrameLuminanceSource..ctor(ColorFrame bitmap, Boolean flipTheImage)
at ZXing.Kinect.ColorFrameLuminanceSource..ctor(ColorFrame bitmap)
at ZXing.Kinect.BarcodeReader.<>c.<.cctor>b__4_0(ColorFrame bitmap)
at ZXing.BarcodeReader`1.Decode(T barcodeBitmap)
at ColorFrameTest.MainWindow.CfReader_FrameArrived(Object sender, ColorFrameArrivedEventArgs e)
With values :
uyvyIndex = 4147200
luminanceIndex = 2073598

from zxing.net.

micjahn avatar micjahn commented on August 15, 2024

Please try again with the newest sources.

from zxing.net.

maxime-beck avatar maxime-beck commented on August 15, 2024

I tried all ColorImageFormats and they all work fine!
Thank you for your help.

Best Regards,
Maxime Beck.

from zxing.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.