question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: 3792764924 UX Status: Libusb error: **UNKNOWN*

See original GitHub issue

Hi, I have 4 basler ace USB3 cameras connected directly to the USB3 ports on an AMD based chipset and motherboard. I am using Ubuntu 18.04 (kernel: 5.6.7-050607-generic) and have Pylon 5.2 installed.

I can see and open all cameras in pylon Viewer in continuous streaming mode, but in the message log I occasionally find errors (especially when I have all 3 cameras running).

I am having problems with the camera occasionally with the basic sample code (grab.cpp + few lines to convert the image to OpenCV and display) below and even in pylon Viewer: The error that I get is: Error: 3792764924 UX Status: Libusb error: UNKNOWN.

// Grab.cpp
/*
    Note: Before getting started, Basler recommends reading the "Programmer's Guide" topic
    in the pylon C++ API documentation delivered with pylon.
    If you are upgrading to a higher major version of pylon, Basler also
    strongly recommends reading the "Migrating from Previous Versions" topic in the pylon C++ API documentation.
    This sample illustrates how to grab and process images using the CInstantCamera class.
    The images are grabbed and processed asynchronously, i.e.,
    while the application is processing a buffer, the acquisition of the next buffer is done
    in parallel.
    The CInstantCamera class uses a pool of buffers to retrieve image data
    from the camera device. Once a buffer is filled and ready,
    the buffer can be retrieved from the camera object for processing. The buffer
    and additional image data are collected in a grab result. The grab result is
    held by a smart pointer after retrieval. The buffer is automatically reused
    when explicitly released or when the smart pointer object is destroyed.
*/
// Include files to use the pylon API.
#include <pylon/PylonIncludes.h>
#ifdef PYLON_WIN_BUILD
#    include <pylon/PylonGUI.h>
#endif

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/video.hpp>


// Namespace for using pylon objects.
using namespace Pylon;
// Namespace for using OpenCV objects.
using namespace cv;
// Namespace for using cout.
using namespace std;
// Number of images to be grabbed.
static const uint32_t c_countOfImagesToGrab = 10000;
int main(int argc, char* argv[])
{
    // The exit code of the sample application.
    int exitCode = 0;
    // Before using any pylon methods, the pylon runtime must be initialized. 
    PylonAutoInitTerm autoInitTerm;
    try
    {
        CTlFactory& TlFactory = CTlFactory::GetInstance();
        CDeviceInfo left_cam;
        left_cam.SetSerialNumber("22822551");
        // Create an instant camera object with the camera device found first.
        CInstantCamera camera( TlFactory.CreateFirstDevice(left_cam));
        // Print the model name of the camera.
        cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;
        
        // Get camera nodemap in order to access camera parameters.
        GenApi::INodeMap& nodemap = camera.GetNodeMap();
        // Open the camera before accessing any parameters. 
        camera.Open();
        // Create pointers to access camera width and height
        GenApi::CIntegerPtr width=nodemap.GetNode("Width");
        GenApi::CIntegerPtr height=nodemap.GetNode("Height");
        // The parameter MaxNumBuffer can be used to control the count of buffers
        // allocated for grabbing. The default value of this parameter is 10.
        camera.MaxNumBuffer = 5;
        // Create a pylon ImageFormatConverter object.
        CImageFormatConverter formatConverter;
        // Specify the output pixel format
        formatConverter.OutputPixelFormat=PixelType_BGR8packed;
        // Create a PylonImage that will be used to create OpenCV images later.
        CPylonImage pylonImage;
        // Create an OpenCV image.
        Mat openCvImage;

        // Start the grabbing of c_countOfImagesToGrab images.
        // The camera device is parameterized with a default configuration which
        // sets up free-running continuous acquisition.
        camera.StartGrabbing();
        // This smart pointer will receive the grab result data.
        CGrabResultPtr ptrGrabResult;
        // Camera.StopGrabbing() is called automatically by the RetrieveResult() method
        // when c_countOfImagesToGrab images have been retrieved.
        while ( camera.IsGrabbing())
        {
            // Wait for an image and then retrieve it. A timeout of 5000 ms is used.
            camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);
            // Image grabbed successfully?
            if (ptrGrabResult->GrabSucceeded())
            {
                Access the image data.
                cout << "SizeX: " << ptrGrabResult->GetWidth() << endl;
                cout << "SizeY: " << ptrGrabResult->GetHeight() << endl;
                const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->GetBuffer();
                cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl << endl;

                // Convert the grabbed buffer to a pylon image.
                formatConverter.Convert(pylonImage, ptrGrabResult);

                // Create an OpenCV image from a pylon image.
                openCvImage = cv::Mat(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC3,(uint8_t *) pylonImage.GetBuffer());

                // Create an OpenCV display window.
                namedWindow("OpenCV Display Window", CV_WINDOW_NORMAL);
                resizeWindow("OpenCV Display Window", 2048/2,1536/2);

                // Display the current image in the OpenCV display window.
                imshow("OpenCV Display Window", openCvImage);
                waitKey(1);
            }
            else
            {
                cout << "Error: " << ptrGrabResult->GetErrorCode() << " " << ptrGrabResult->GetErrorDescription() << endl;
            }
        }
    }
    catch (const GenericException &e)
    {
        // Error handling.
        cerr << "An exception occurred." << endl
        << e.GetDescription() << endl;
        exitCode = 1;
    }
    // Comment the following two lines to disable waiting on exit.
    cerr << endl << "Press enter to exit." << endl;
    while( cin.get() != '\n');
    // // Releases all pylon resources. 
    // PylonTerminate();  
    return exitCode;
}

Hope someone can share their expertise based on previous experience with this error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
thiesmoellercommented, Jul 10, 2020

@Neel1302 , you are running out of USB memory.

You can extend the amount of RAM allocated to the usb subsystem:

In the full pylon readme, there is a section about USB tuning:

* Increasing Packet Size
  For faster USB transfers, you should increase the packet size. If you're
  working with the pylon Viewer, you can do this by changing the
  "Stream Parameters" -> "Maximum Transfer Size" value from inside the
  pylon Viewer. If you're writing your own application, use the camera API
  to set the "Maximum Transfer Size".
  After increasing the package size, you will likely run out of kernel space
  and see corresponding error messages in the console. The default value set
  by the kernel is 16 MB. To change the value (in this example to 1000 MB), you can
  execute as root:
    echo 1000 > /sys/module/usbcore/parameters/usbfs_memory_mb
  This would assign a maximum of 1000 MB to the USB stack.

1reaction
Neel1302commented, Sep 20, 2020

Hi @thiesmoeller,

I am posting for other users that might run into this issue. The root cause of the issue was that the usb bus bandwidth was a limiting factor. It is not clear whether it was the driver for the PCIe card we were using, but we have since used the Fresco FL1100, 4HC, x4, 4Ports - USB Interface Card from basler and the problem has since been resolved without any changes made to software or camera settings.

Thanks, Neel

Read more comments on GitHub >

github_iconTop Results From Across the Web

USB errors during using more than one USB 3.0 cameras
Error: 'UX Status: Libusb error: LIBUSB_ERROR_OTHER.' This occurs when my application tries to open the camera. Fortunately, if I execute ...
Read more >
Error -1074360293: Timeout With Vision Camera - NI - Support
If the camera is plugged into a USB hub, try plugging directly into a USB 3.0 port on your computer. This error can...
Read more >
Miscellaneous - libusb
Returns a constant string with a short description of the given error code, ... UNKNOWN if the value of error_code is not a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found