Click here to Skip to main content
15,883,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been using 2 3.0 Usb basler cameras and when I run the program to capture cameras' video its resolution is 640x480 and I want to change its resolution. How can i do it? Thank you so much! For anyone need more details here is the sample code I'm using:
#include <pylon/PylonIncludes.h>
#ifdef PYLON_WIN_BUILD
#    include <pylon/PylonGUI.h>
#endif
using namespace Pylon;
using namespace std;
static const uint32_t c_countOfImagesToGrab = 100000;
static const size_t c_maxCamerasToUse = 2;
int main(int argc, char* argv[])
{

int exitCode = 0;
PylonInitialize();

try
{
    CTlFactory& tlFactory = CTlFactory::GetInstance();
    DeviceInfoList_t devices;
    if (tlFactory.EnumerateDevices(devices) == 0)
    {
        throw RUNTIME_EXCEPTION("No camera present.");
    }
    CInstantCameraArray cameras(max(devices.size(), c_maxCamerasToUse));
    for (size_t i = 0; i < cameras.GetSize(); ++i)
    {
        cameras[i].Attach(tlFactory.CreateDevice(devices[i]));
        cout << "Using device " << cameras[i].GetDeviceInfo().GetModelName() << endl;
    }
       cameras.StartGrabbing();
    CGrabResultPtr ptrGrabResult;
    for (uint32_t i = 0; i < c_countOfImagesToGrab && cameras.IsGrabbing(); ++i)
    {
        cameras.RetrieveResult(5000, ptrGrabResult, TimeoutHandling_ThrowException);
        intptr_t cameraContextValue = ptrGrabResult->GetCameraContext();
 #ifdef PYLON_WIN_BUILD
        Pylon::DisplayImage(cameraContextValue, ptrGrabResult);
#endif
        cout << "Camera " << cameraContextValue << ": " << 
cameras[cameraContextValue].GetDeviceInfo().GetModelName() << endl;
        cout << "GrabSucceeded: " << ptrGrabResult->GrabSucceeded() << endl;
        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;
    }
}
catch (const GenericException& e)
{
    // Error handling
    cerr << "An exception occurred." << endl
        << e.GetDescription() << endl;
    exitCode = 1;
}
cerr << endl << "Press Enter to exit." << endl;
while (cin.get() != '\n');

PylonTerminate();

return exitCode;
}


What I have tried:

I've try a'set' command to solve this and it is like cameras.set(cv2::CAMERA_PROP_FRAME_WIDTH,1280); but it didn't work because i can not involve 'cv2' in my program cause I've not successfully built python linked with opencv, and my program didn't recognise the code too.
Posted
Updated 14-Nov-19 20:47pm
v2
Comments
Stefan_Lang 15-Nov-19 2:25am    
This can only be answered by someone who is familiar with the library and/or hardware you are using. You could increase the chance that someone like that spots this question if you put that info into the title, or, at the very least, add them as tags.
ZurdoDev 15-Nov-19 15:42pm    
Or contact the vendor.
AMARNATH REDDY SURAPUREDDY 10-Sep-22 5:47am    
I got it. it's not normal opencv camera it is specical case with basler(pylon) If we want to change the parameters fly we gonna reset the camera and set to normal on the fly. Check the link for how to change the parameters in python.
1) https://stackoverflow.com/questions/72795884/how-to-set-parameters-of-basler-using-python-genicam-accessexception-node-is

2) https://docs.baslerweb.com/acquisition-start-stop-and-abort

3)GenApi::INodeMap& nodemap = camera[0].GetNodeMap();
// Configure width and height and gain for all zones
Pylon::CIntegerParameter(nodemap, "Width").SetValue(property.width);
Pylon::CIntegerParameter(nodemap, "Height").SetValue(property.height);
Pylon::CFloatParameter(nodemap, "Gain").SetValue(property.gain);
Pylon::CFloatParameter(nodemap, "ExposureTime").SetValue(property.exposureTime);

Check this things and go ahead.

1 solution

Image ROI | Basler[^]

It may help you to change the parameters
 
Share this answer
 
Comments
OriginalGriff 29-Jun-22 1:33am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 3 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.
Member 14629414 29-Jun-22 1:36am    
Actually I was very surprised that my 3 years old question still receive suggestions from others and I don't think it was any kinds of abusing from people.
merano99 29-Jun-22 1:55am    
I always find it a pity when no solution is found for questions. Basler cameras, for example, are not so rare that someone will not need the solution at some point.
That a valid solution could lead to a ban would surprise me.

If the Answer does solve the problem vote and accept as solution.
OriginalGriff 29-Jun-22 2:08am    
Yes, but we get a bunch of morons who decide that posting answers to old questions is a good way to boost their rep (probably to look good on a resume).

Mostly the answers are garbage, irrelevant, or copy'n'paste but some trigger happy members will assume that any answer to an old question is "fair game" and start the banning process, particularly with a new member.
This was just a polite warning that we don't tolerate such things, rather than no comment and an abuse report!
Member 14629414 29-Jun-22 1:38am    
AMARNATH REDDY SURAPUREDDY Thank you for your suggestion. This question was for my graduate project and I've finished it. Anyways thank you ^

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900