Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've captured video from both of my basler cameras using the code below. The problem is I want to save 2 video into files in my pc but I don't know exactly what sort of code I've to.Here is my code:
C++
#include <iostream>
#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;
}

Thank you!

What I have tried:

I've try a code is cv::CreateVideoWriter FOURCC('P','I','M','1') but it doesn't work as well
It said that "CreateVideoWriter" hasn't been declared and also the comma '','' had error: " ')' are required"
Posted
Updated 24-Dec-19 7:38am
v3
Comments
Richard MacCutchan 24-Dec-19 11:00am    
"but it doesn't work as well"
Please edit your question and explain exactly what that means.
Member 14629414 24-Dec-19 11:15am    
@Richard MacCutchan I've edited the question.

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