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.

Getting duplicate frame

See original GitHub issue

I using following model of basler camera: acA1920-40uc I have connect my camera to controller which moves in a particular direction and capture images. If i move camera from A to B to C. It happens that i get similar image for all the location. I have tried camera->StartGrabbing(GrabStrategy_LatestImageOnly); but i still get duplicate frame. I have used similar logic in python and issue does not occur. I can use grabOne and software trigger but it creates an extra delay to fetch the frame which is not desirable in my case. Sharing the cpp and python code. Please let me know in case of any issues.

Cpp: Initialization:

void PrimaryCamera::initializeCamera()
{
    try
    {
        camera = new Pylon::CInstantCamera(CTlFactory::GetInstance().CreateFirstDevice());
        cout<<"Using Device"<<camera->GetDeviceInfo().GetModelName()<<endl;
        camera->MaxNumBuffer = 1;
        formatConverter.OutputPixelFormat = PixelType_BGR8packed;
        camera->Open();
        camera->StartGrabbing(GrabStrategy_LatestImageOnly);
        cout<<"\nCamera Initialized Successfully"<<endl;
    }catch(GenICam::GenericException &e) {
        cerr << "An exception occurred." << endl  << e.GetDescription() << endl;

    }

}

Capture Frame:

cv::Mat PrimaryCamera::captureBaslerFrame()
{
    if(camera->IsGrabbing()){
        camera->RetrieveResult(500, ptrGrabResult, TimeoutHandling_ThrowException);
        if (ptrGrabResult->GrabSucceeded()){
            formatConverter.Convert(pylonImage,ptrGrabResult);
            return cv::Mat(ptrGrabResult->GetHeight(),ptrGrabResult->GetWidth(), CV_8UC3,(uint8_t *)pylonImage.GetBuffer());

        }
    }else{
        cout<<"Currently camera is not grabbing frames"<<endl;
    }
}

Python:

try:
    camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
    print("Using device ", camera.GetDeviceInfo().GetModelName())
except:
    print("Oops!", sys.exc_info()[0], "occured.")
    sys.exit('no camera port found')

# Grabing Continusely (video) with minimal delay
camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly)
converter = pylon.ImageFormatConverter()
# # converting to opencv bgr format
converter.OutputPixelFormat = pylon.PixelType_BGR8packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned


def grab_img():
    grabResult = camera.RetrieveResult(1000, pylon.TimeoutHandling_ThrowException)
    if grabResult.GrabSucceeded():
        image = converter.Convert(grabResult,)
        img = image.GetArray()
        grabResult.Release()
    return img

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
HackersSpiritcommented, Jul 4, 2019

@thiesmoeller : Thanks for the help. Finally i was able to find out the issue. Actually earlier i was running a git example inorder to fetch the frame. When i went through the document i found out the problem was in initialization: camera->MaxNumBuffer = 1; The max size of the buffer the more samples can be stored. This also answers the question why i was getting no repeated frame after continuously fetching the frame.

0reactions
thiesmoellercommented, Jul 3, 2019

If you don’t won’t to synchronize with external hw trigger, but know the exakt timing of your movement use https://docs.baslerweb.com/#t=en%2Facquisition_frame_rate.htm to configure a larger spacing between your frames

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicates Frames. Cause and means? - VideoHelp Forum
So the reasons for the dupes must have been the digitizing. If I get you right, then doing that in a bad manner...
Read more >
What Causes Duplicated Frames? : r/VideoEditing - Reddit
It's called pulldown. Caused by bringing footage at a lower frame rate into a project at a higher frame rate (or during export)....
Read more >
Duplicate Frame Remover 3 - aescripts.com
Removes duplicate frames in footage. New retiming feature and 50% faster processing.
Read more >
Duplicate, Delete, Repeat an Animation Frame - Kdan Mobile
Duplicate : You can duplicate the frames and edit them individually. When you duplicate frames in row (eg. Frame A1, B1, C1), the...
Read more >
Duplicate, reorder & delete whiteboard frames - Jamboard Help
Duplicate a frame · Create or open a whiteboard. · At the top, tap or click the frame bar to expand it. ·...
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