Hi,
I’ve attached two files: dummy1.cpp and dummy2.cpp. The only difference between the two files is in the fixedGuidArray[] definition at the top. I have 4 cameras connected to my computer, all of which have been activated. I’m running the CLEyeMulticam.dll in the redist directory. I have version 4.0.2.1017 of the driver, and version 1.2.0.1008 of the SDK.
If I run dummy1 first, and then run dummy2, I get the following outputs:
dummy1.exe output:
Found 4 cameras
PSeye[0]: 295315e9-6975-5ef4-7c85-6b216c45ddbd
PSeye[1]: 1a2c87e1-3cce-c320-eee0-c4bc80fd0c55
PSeye[2]: dbfef392-249c-7f50-eaf2-277e1f37d47c
PSeye[3]: 79445588-fcef-5c20-2822-fc3ea210877c
PSeye[0]: create success
PSeye[1]: create success
PSeye[0]: start success
PSeye[1]: start success
PSeye[0]: buffer allocated
PSeye[1]: buffer allocated
Hit a key to quit
dummy2.exe output:
Found 1 camera
PSeye[0]: 295315e9-6975-5ef4-7c85-6b216c45ddbd
PSeye[0]: create success
PSeye[1]: creation failed
If I run dummy2 first, and then dummy1, I get the following:
dummy2.exe output:
Found 4 cameras
PSeye[0]: 295315e9-6975-5ef4-7c85-6b216c45ddbd
PSeye[1]: 1a2c87e1-3cce-c320-eee0-c4bc80fd0c55
PSeye[2]: dbfef392-249c-7f50-eaf2-277e1f37d47c
PSeye[3]: 79445588-fcef-5c20-2822-fc3ea210877c
PSeye[0]: create success
PSeye[1]: create success
PSeye[0]: start success
PSeye[1]: start success
PSeye[0]: buffer allocated
PSeye[1]: buffer allocated
Hit a key to quit
dummy1.exe output:
No cameras found
Am I doing something wrong?
Here’s dummy1.cpp:
#include <stdio.h>
#include <iostream>
#include <conio.h>
#include "CLEyeMulticam.h"
#define NUM_FIXED_CAMS 2
/************************************************************************/
int
main(int argc, char **argv)
{
GUID fixedGuidArray[NUM_FIXED_CAMS] = {
// { 0x295315e9, 0x6975, 0x5ef4,
// { 0x7c, 0x85, 0x6b, 0x21, 0x6c, 0x45, 0xdd, 0xbd } },
{ 0x1a2c87e1, 0x3cce, 0xc320,
{ 0xee, 0xe0, 0xc4, 0xbc, 0x80, 0xfd, 0x0c, 0x55 } },
{ 0xdbfef392, 0x249c, 0x7f50,
{ 0xea, 0xf2, 0x27, 0x7e, 0x1f, 0x37, 0xd4, 0x7c } },
// { 0x79445588, 0xfcef, 0x5c20,
// { 0x28, 0x22, 0xfc, 0x3e, 0xa2, 0x10, 0x87, 0x7c } },
};
// camera count
int numCams = CLEyeGetCameraCount();
if (numCams <= 0)
{
printf("No cameras found\n");
return -1;
}
else
{
printf("Found %d camera%s\n", numCams, numCams == 1 ? "" : "s");
}
// get and print GUIDs
GUID *guidArray = new GUID[numCams];
for (int idx = 0; idx < numCams; idx++)
{
guidArray[idx] = CLEyeGetCameraUUID(idx);
GUID *g = &guidArray;[idx];
printf("PSeye[%d]: lx-hx-hx-xx-xxxxxx\n",
idx,
g->Data1, g->Data2, g->Data3,
g->Data4[0], g->Data4[1], g->Data4[2], g->Data4[3],
g->Data4[4], g->Data4[5], g->Data4[6], g->Data4[7]);
}
// create fixed cameras
CLEyeCameraInstance cam[NUM_FIXED_CAMS];
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
cam[idx] = CLEyeCreateCamera(fixedGuidArray[idx],
CLEYE_MONO_PROCESSED,
CLEYE_VGA,
30);
if (cam[idx] == NULL)
{
for (int idx2 = 0; idx2 < idx; idx2++)
{
CLEyeDestroyCamera(cam[idx2]);
}
printf("PSeye[%d]: creation failed\n", idx);
return -1;
}
printf("PSeye[%d]: create success\n", idx);
}
// start fixed cameras
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
bool success = CLEyeCameraStart(cam[idx]);
if (! success)
{
for (int idx2 = 0; idx2 < idx; idx2++)
{
CLEyeCameraStop(cam[idx2]);
CLEyeDestroyCamera(cam[idx2]);
}
printf("PSeye[%d]: start failed\n", idx);
return -1;
}
printf("PSeye[%d]: start success\n", idx);
}
// allocate memory for buffers
PBYTE buf[NUM_FIXED_CAMS];
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
buf[idx] = new BYTE[640*480];
printf("PSeye[%d]: buffer allocated\n", idx);
}
// sit in a loop getting frames from each camera
printf("Hit a key to quit\n");
while (1)
{
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
CLEyeCameraGetFrame(cam[idx], buf[idx]);
}
if (_kbhit())
{
break;
}
}
// free memory
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
delete buf[idx];
printf("PSeye[%d], buffer deleted\n", idx);
}
// stop cameras
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
CLEyeCameraStop(cam[idx]);
printf("PSeye[%d]: stopped\n", idx);
}
// destroy cameras
for (int idx = 0; idx < NUM_FIXED_CAMS; idx++)
{
CLEyeDestroyCamera(cam[idx]);
printf("PSeye[%d]: destroyed\n", idx);
}
return 0;
}
dummy2.cpp is the same except the definition of fixedGuidArray is as follows:
GUID fixedGuidArray[NUM_FIXED_CAMS] = {
{ 0x295315e9, 0x6975, 0x5ef4,
{ 0x7c, 0x85, 0x6b, 0x21, 0x6c, 0x45, 0xdd, 0xbd } },
// { 0x1a2c87e1, 0x3cce, 0xc320,
// { 0xee, 0xe0, 0xc4, 0xbc, 0x80, 0xfd, 0x0c, 0x55 } },
// { 0xdbfef392, 0x249c, 0x7f50,
// { 0xea, 0xf2, 0x27, 0x7e, 0x1f, 0x37, 0xd4, 0x7c } },
{ 0x79445588, 0xfcef, 0x5c20,
{ 0x28, 0x22, 0xfc, 0x3e, 0xa2, 0x10, 0x87, 0x7c } },
};
Thanks,
MP