Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#



After saving certain no of images for chameleon point grey camera error is coming.Please help how this error can be solved.
Error:
An unhandled exception of type System.AccessViolationException' occurred in FlyCapture2Managedd_v140.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
error is
JavaScript
FlyCapture2Managedd_v140.pdb not loaded
'FlyCapture2Managedd_v140.pdb contains the debug information required to find the source for the module FlyCaptue2Managedd_v140.dll'


What I have tried:

C#
   const Mode Format7Mode = Mode.Mode0;
    const PixelFormat Format7PixelFormat = PixelFormat.PixelFormatMono8;

    FileStream fileStream;
    try
    {
        fileStream = new FileStream(@"test.txt", FileMode.Create);
        fileStream.Close();
        File.Delete("test.txt");
    }
    catch
    {

        return;
    }

    ManagedBusManager busMgr = new ManagedBusManager();
    uint numCameras = busMgr.GetNumOfCameras();


    if (numCameras == 0)
    {

        return;
    }

    ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0);

    ManagedCamera cam = new ManagedCamera();

    cam.Connect(guid);

    bool supported = false;
    Format7Info fmt7Info = cam.GetFormat7Info(Format7Mode, ref supported);

    PrintFormat7Capabilities(fmt7Info);

    if ((Format7PixelFormat & (PixelFormat)fmt7Info.pixelFormatBitField) == 0)
    {
        return;
    }

    Format7ImageSettings fmt7ImageSettings = new Format7ImageSettings();
    fmt7ImageSettings.mode = Format7Mode;
    fmt7ImageSettings.offsetX = 0;
    fmt7ImageSettings.offsetY = 0;
    fmt7ImageSettings.width = fmt7Info.maxWidth;
    fmt7ImageSettings.height = fmt7Info.maxHeight;
    fmt7ImageSettings.pixelFormat = Format7PixelFormat;

    // Validate the settings to make sure that they are valid
    bool settingsValid = false;
    Format7PacketInfo fmt7PacketInfo = cam.ValidateFormat7Settings(
        fmt7ImageSettings,
        ref settingsValid);

    if (settingsValid != true)
    {
        
        return;
    }

    // Set the settings to the camera
    cam.SetFormat7Configuration(
       fmt7ImageSettings,
       fmt7PacketInfo.recommendedBytesPerPacket);

    // Get embedded image info from camera
    EmbeddedImageInfo embeddedInfo = cam.GetEmbeddedImageInfo();

    // Enable timestamp collection
    if (embeddedInfo.timestamp.available == true)
    {
        embeddedInfo.timestamp.onOff = true;
    }

    // Set embedded image info to camera
    cam.SetEmbeddedImageInfo(embeddedInfo);
    GC.Collect();
    // Start capturing images
    cam.StartCapture();

    // Retrieve frame rate property
    CameraProperty frmRate = cam.GetProperty(PropertyType.FrameRate);

    ManagedImage rawImage = new ManagedImage();
 
    cam.RetrieveBuffer(rawImage);



    // Create a converted image
    ManagedImage convertedImage = new ManagedImage();

    // Convert the raw image
    rawImage.Convert(PixelFormat.PixelFormatBgr, convertedImage);

    // Create a unique filename
    string file = DateTime.Now.ToString("HH.mm.ss");

    string filename = String.Format(file + ".jpeg");

    System.Drawing.Bitmap bitmap = convertedImage.bitmap;

    // Save the image
    bitmap.Save(@"C:\\Users\\ITREAT\\Desktop\\" + filename, System.Drawing.Imaging.ImageFormat.Jpeg);



    cam.StopCapture();


    cam.Disconnect();

    Application.DoEvents();

}
Posted
Updated 14-Dec-16 0:35am
v2
Comments
Member 12210939 14-Dec-16 6:11am    
FlyCapture2Managedd_v140.pdb not loaded
'FlyCapture2Managedd_v140.pdb contains the debug information required to find the source for the module FlyCaptue2Managedd_v140.dll'

1 solution

It can be solved by using the debugger to know when and where the exception occurs.

Alternatively insert try - catch blocks around code that may contain the call that throws the exception until you narrowed it down.

Because the exception occurs in a 3rd party DLL, check which functions of this DLL are called and check the parameters passed to these functions.
 
Share this answer
 

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