How to fix Basler AviWriter low performance

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

Maybe someone could help with the following problem. I need to write a viewer for Basler Usb cameras which will be able to write video to avi file using the selected codec. I'm using pylon sdk for creating application. And I faced the following problem - AviWriter object provided by pylon libraries doesn't write frames to avi file as effective as standard pylon viewer does. For testing I have chosen the following code sample which has been provided with pylon SDK:

    internal static void Main()
    {

        int exitCode = 0;
        int counter = 0;

        try
        {

            using (Camera camera = new Camera())
            {

                camera.Open();

                camera.Parameters[PLCameraInstance.MaxNumBuffer].SetValue(1000);


                using (AviVideoWriter writer = new AviVideoWriter())
                {


                    byte[] ar = { };
                    writer.Create("test.avi", 35, PixelType.BGR8packed, 1280, 960, ImageOrientation.BottomUp, "msvc", 100, 0, 1, ref ar, true, (IntPtr)null);


                    camera.StreamGrabber.Start(1000); //1000 frames are to be grabbed

                    Console.WriteLine("Please wait. Images are being grabbed.");

                    while (camera.StreamGrabber.IsGrabbing)
                    {

                        IGrabResult grabResult = camera.StreamGrabber.RetrieveResult(5000, TimeoutHandling.ThrowException);


                        if (grabResult.GrabSucceeded)
                        {

                            ++counter;
                            writer.Write(grabResult);
                            Console.WriteLine("------->images written" + counter); 
                            Console.WriteLine("------->empty buffers" + camera.Parameters[PLCameraInstance.NumEmptyBuffers].GetValue()); //how many empty buffers left
                            grabResult.Dispose();
                        }
                        else
                        {
                            Console.WriteLine("Error: {0} {1}", grabResult.ErrorCode, grabResult.ErrorDescription);
                        }
                    }


                    camera.StreamGrabber.Stop();


                    writer.Close();
                }


                camera.Close();
            }
        }
        catch (Exception e)
        {
            Console.Error.WriteLine("Exception: {0}"
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community