This project is read-only.

Error in pointgreycapture2.1.cs

Jul 11, 2012 at 1:38 PM
Edited Jul 11, 2012 at 1:44 PM

I am getting an error in the function get image texture , saying "Index was outside the bounds of the array. "

in the following lines in pointgreycapture2.1.cs .

 

 for (int i = 0; i < processedImage.rows; i++)

{

for (int j = 0; j < processedImage.stride; j += 3, rawIndex += 3, ++index) 

{                                returnImage[index] =  ((pixelData[rawIndex + R] << 16) | (pixelData[rawIndex + G] << 8) |                                        (pixelData[rawIndex + B]));                     

}

}

 

In tutorial 8.cs i changed

captureDevice = new DirectShowCapture();     to     captureDevice = new PointGreyCapture_2_1();

to use my point grey camera , also i added a app.config file which says the application can use legacy mode. 

Maybe the error is because my camera is Monochrome not colored . 

 

Can you suggest what should i do to correct this . 

Jul 11, 2012 at 1:55 PM
Edited Jul 11, 2012 at 1:56 PM

Ohk , now i changed the camera video intialization to Grayscale . 

captureDevice.InitVideoCapture(0, FrameRate._15Hz, Resolution._640x480,ImageFormat.GRAYSCALE_8, true);

Now there is no error , but the application exists as soon as it starts . 

 

PS: I am trying to use point grey monochrome camera , in tutorial 8 .

Jul 11, 2012 at 5:26 PM
Edited Jul 11, 2012 at 5:57 PM

I got the program to work with grayscale : I changed the following parts (marked in red) in pointgreycapture2.1.cs :

----------------

 

pixelData = new byte[cameraWidth * cameraHeight ];

 

-----------------

for (int i = 0; i < processedImage.rows; i++)
                        {
                            for (int j = 0; j < processedImage.stride; j += 1, rawIndex += 1, ++index)
                            {
                               
                                    
                                    returnImage[index] =
                                        ((pixelData[rawIndex] << 16) |
                                      (pixelData[rawIndex] << 8) |
                                      (pixelData[rawIndex]));
                                  
                              
                            }
                        }
-----------------

 

    private void OnImageGrabbed(ManagedImage image)
        {
            while (accessing) { }
            image.Convert(PixelFormat.PixelFormatMono8, processedImage);
            unsafe
            {
                Marshal.Copy((IntPtr)processedImage.data, pixelData, 0, pixelData.Length);
            }
        }
-----------------

 

Everything seems to work and there are no errors , but the object that should appear on the marker paper appears at random places from time to time . Please Help ! 

Also only ground marker is getting detected and not the toolbar marker .