Esempio n. 1
0
DirectShowCaptureInterface::CapErrorCode DirectShowCaptureInterface::getDeviceName(int num, QString &name)
{
    if (num < 0 || num >= 2)
    {
        return ImageCaptureInterface::FAILURE;
    }
    //     Group Number                   1       2 3        4 5      6       7 8       9       10     11        1213     14
    QRegExp deviceStringPattern(QString("^([^,:]*)(,([^:]*))?(:(\\d*)/(\\d*))?((:mjpeg)|(:yuyv)|(:rgb)|(:fjpeg))?(:(\\d*)x(\\d*))?$"));
    static const int Device1Group     = 1;
    static const int Device2Group     = 3;
    QString qdevname(mDevname.c_str());
    int result = deviceStringPattern.indexIn(qdevname);
    if (result == -1)
    {
        L_ERROR_P("Error in device string format:<%s>", mDevname.c_str());
        return ImageCaptureInterface::FAILURE;
    }
    if (num == 0)
    {
        name = deviceStringPattern.cap(Device1Group);
    }
    else
    {
        name = deviceStringPattern.cap(Device2Group);
    }
    return ImageCaptureInterface::SUCCESS;
}
Esempio n. 2
0
/**
 * Sets
 *   interfaceName
 *   deviceName
 *
 **/
int V4L2CaptureInterface::setConfigurationString(string _devname)
{
    this->interfaceName = _devname;

    //     Group Number                   1       2 3        4 5      6       7 8       9       10     11   12     13
    QRegExp deviceStringPattern(QString("^([^,:]*)(,([^:]*))?(:(\\d*)/(\\d*))?((:mjpeg)|(:yuyv)|(:fjpeg))?(:(\\d*)x(\\d*))?$"));
    static const int Device1Group     = 1;
    static const int Device2Group     = 3;
    static const int FpsNumGroup      = 5;
    static const int FpsDenumGroup    = 6;
    static const int CompressionGroup = 7;
    static const int WidthGroup       = 12;
    static const int HeightGroup      = 13;

    printf ("Input string %s\n", _devname.c_str());
    QString qdevname(_devname.c_str());
    int result = deviceStringPattern.indexIn(qdevname);
    if (result == -1)
    {
        printf("Error in device string format:%s\n", _devname.c_str());
        exit(EXIT_FAILURE);
    }
    printf (
        "Parsed data:\n"
        "  | - Device 1=%s\n"
        "  | - Device 2=%s\n"
        "  | - FPS %s/%s\n"
        "  | - Size [%sx%s]\n"
        "  \\ - Compressing: %s\n"
        "RGB decoding is %s\n",
        deviceStringPattern.cap(Device1Group) .toLatin1().constData(),
        deviceStringPattern.cap(Device2Group) .toLatin1().constData(),
        deviceStringPattern.cap(FpsNumGroup)  .toLatin1().constData(),
        deviceStringPattern.cap(FpsDenumGroup).toLatin1().constData(),
        deviceStringPattern.cap(WidthGroup)   .toLatin1().constData(),
        deviceStringPattern.cap(HeightGroup)  .toLatin1().constData(),
        deviceStringPattern.cap(CompressionGroup).toLatin1().constData(),
        mIsRgb ? "on" : "off"
    );

    deviceName[RIGHT_FRAME] = deviceStringPattern.cap(Device1Group).toLatin1().constData();
    deviceName[LEFT_FRAME ] = deviceStringPattern.cap(Device2Group).toLatin1().constData();

    bool isOk;
    cameraMode.fpsnum = deviceStringPattern.cap(FpsNumGroup).toInt(&isOk);
    if (!isOk) cameraMode.fpsnum = 1;

    cameraMode.fpsdenum = deviceStringPattern.cap(FpsDenumGroup).toInt(&isOk);
    if (!isOk) cameraMode.fpsdenum = 10;

    cameraMode.width = deviceStringPattern.cap(WidthGroup).toInt(&isOk);
    if (!isOk || cameraMode.width <= 0) cameraMode.width = 800;

    cameraMode.height = deviceStringPattern.cap(HeightGroup).toInt(&isOk);
    if (!isOk || cameraMode.height <= 0) cameraMode.height = 600;

    decoder = UNCOMPRESSED;
    if (!deviceStringPattern.cap(CompressionGroup).isEmpty())
    {
        if (!deviceStringPattern.cap(CompressionGroup).compare(QString(":mjpeg")))
            decoder = COMPRESSED_JPEG;
        if (!deviceStringPattern.cap(CompressionGroup).compare(QString(":fjpeg")))
            decoder = COMPRESSED_FAST_JPEG;
    }

    cameraMode.compressed = (decoder != UNCOMPRESSED);

    printf("Capture Right device: V4L2 %s\n", deviceName[RIGHT_FRAME].c_str());
    printf("Capture Left  device: V4L2 %s\n", deviceName[ LEFT_FRAME].c_str());
    printf("MJPEG compression is: %s\n", CODEC_NAMES[cameraMode.compressed]);
    return isOk ? 0 : 1;
}
Esempio n. 3
0
DirectShowCaptureInterface::DirectShowCaptureInterface(const string &devname, bool isRgb)
{
    mDevname = devname;
    mIsRgb   = isRgb;

    //     Group Number                   1       2 3        4 5      6       7 8       9       10     11        1213     14
    QRegExp deviceStringPattern(QString("^([^,:]*)(,([^:]*))?(:(\\d*)/(\\d*))?((:mjpeg)|(:yuyv)|(:rgb)|(:fjpeg))?(:(\\d*)x(\\d*))?$"));
    static const int Device1Group     = 1;
    static const int Device2Group     = 3;
    static const int FpsNumGroup      = 5;
    static const int FpsDenumGroup    = 6;
    static const int CompressionGroup = 7;
    static const int WidthGroup       = 13;
    static const int HeightGroup      = 14;

    L_DDEBUG_P("Input string <%s>", devname.c_str());
    QString qdevname(devname.c_str());
    int result = deviceStringPattern.indexIn(qdevname);
    if (result == -1)
    {
        L_ERROR_P("Error in device string format:<%s>", devname.c_str());
        return;
    }
    L_INFO_P("Parsed data:\n"
             "  | - Device 1=%s\n"
             "  | - Device 2=%s\n"
             "  | - FPS %s/%s\n"
             "  | - Size [%sx%s]\n"
             "  \\ - Compressing: %s\n"
             "RGB decoding is %s",
             deviceStringPattern.cap(Device1Group).toLatin1().constData(),
             deviceStringPattern.cap(Device2Group).toLatin1().constData(),
             deviceStringPattern.cap(FpsNumGroup).toLatin1().constData(),
             deviceStringPattern.cap(FpsDenumGroup).toLatin1().constData(),
             deviceStringPattern.cap(WidthGroup).toLatin1().constData(),
             deviceStringPattern.cap(HeightGroup).toLatin1().constData(),
             deviceStringPattern.cap(CompressionGroup).toLatin1().constData(),
             mIsRgb ? "on" : "off"
    );

    mDeviceIDs[Frames::LEFT_FRAME ] = deviceStringPattern.cap(Device1Group).isEmpty() ? -1 : deviceStringPattern.cap(Device1Group).toInt();
    mDeviceIDs[Frames::RIGHT_FRAME] = deviceStringPattern.cap(Device2Group).isEmpty() ? -1 : deviceStringPattern.cap(Device2Group).toInt();

    bool err;
    int fpsnum = deviceStringPattern.cap(FpsNumGroup).toInt(&err);
    if (!err) fpsnum = 1;

    int fpsdenum = deviceStringPattern.cap(FpsDenumGroup).toInt(&err);
    if (!err) fpsdenum = 10;

    int width = deviceStringPattern.cap(WidthGroup).toInt(&err);
    if (!err || width <= 0) width = 800;

    int height = deviceStringPattern.cap(HeightGroup).toInt(&err);
    if (!err || height <= 0) height = 600;

    mCompressed = DirectShowCameraDescriptor::UNCOMPRESSED_YUV;
    if (!deviceStringPattern.cap(CompressionGroup).isEmpty())
    {
       if      (!deviceStringPattern.cap(CompressionGroup).compare(QString(":rgb"))) {
           mCompressed = DirectShowCameraDescriptor::UNCOMPRESSED_RGB;
           mIsRgb   = true;
       }
       else if (!deviceStringPattern.cap(CompressionGroup).compare(QString(":mjpeg"))) {
           mCompressed = DirectShowCameraDescriptor::COMPRESSED_JPEG;
       }
       else if (!deviceStringPattern.cap(CompressionGroup).compare(QString(":fjpeg"))) {
           mCompressed = DirectShowCameraDescriptor::COMPRESSED_FAST_JPEG;
       }
    }

    for (int i = 0; i < Frames::MAX_INPUTS_NUMBER; i++)
    {
        L_INFO_P("Capture %s device: DShow:%d", Frames::getEnumName((Frames::FrameSourceId)i), mDeviceIDs[i]);
    }
    L_INFO_P("Format is: %s", DirectShowCameraDescriptor::codec_names[mCompressed]);

    /* TODO: Make cycle here */
    for (int i = 0; i < Frames::MAX_INPUTS_NUMBER; i++)
    {
        mFormats[i].type = DirectShowCameraDescriptor::codec_types[mCompressed];
        mFormats[i].height = height;
        mFormats[i].width  = width;
        mFormats[i].fps    = (int)((double)fpsdenum / fpsnum);
    }

    skippedCount = 0;
    isRunning = false;
}
Esempio n. 4
0
UEyeCaptureInterface::UEyeCaptureInterface(string _devname) :
    sync(NO_SYNC),
    currentLeft(NULL),
    currentRight(NULL),
    spin(this)
{
    printf("#################################################   \n");
    printf("Hi, Stranger. I will help you with the uEye cameras.\n");
    printf("Remember, everything is in the eye of the beholder. \n");
    printf("#################################################   \n");
    int camNum = 0;
    is_GetNumberOfCameras (&camNum);
    printf("Currently there are %d cameras in the system:\n", camNum);
    UEYE_CAMERA_LIST *camList = (UEYE_CAMERA_LIST *)malloc(sizeof(ULONG) + camNum * sizeof(UEYE_CAMERA_INFO));
    camList->dwCount = camNum;
    is_GetCameraList(camList);

    printf("%2s %16s %5s %5s %5s %6s %16s\n",
            "N", "Model" ,"camId", "devId" ,"sensId", "inuse?", "Serial");

    for (int i = 0; i < camNum; i++)
    {
        printf("% 2d %16s % 5u % 5u %5u %6s %16s\n",
            i,
            camList->uci[i].Model,
            camList->uci[i].dwCameraID,
            camList->uci[i].dwDeviceID,
            camList->uci[i].dwSensorID,
            camList->uci[i].dwInUse != 0 ? "used" : "free",
            camList->uci[i].SerNo);

    }
    free(camList);


    this->devname = _devname;

    //     Group Number                   1       2 3        4 5          6 7             8 910   11     12 13     14 15                 16 17
    QRegExp deviceStringPattern(QString("^([^,:]*)(,([^:]*))?(:(\\d*)mhz)?(:([0-9.]*)fps)?(:((10)|(8))b)?(:x(\\d*))?(:(sync|hsync|fsync|esync))?(:(global))?$"));
    static const int Device1Group       = 1;
    static const int Device2Group       = 3;
    static const int PixelClockGroup    = 5;
    static const int FpsGroup           = 7;
    static const int BitsGroup          = 9;
    static const int BinningGroup       = 13;
    static const int SyncGroup          = 15;
    static const int GlobalShutterGroup = 17;

    //static const int WidthGroup       = 12;
    //static const int HeightGroup      = 13;

    printf ("Input string %s\n", _devname.c_str());
    QString qdevname(_devname.c_str());
    int result = deviceStringPattern.indexIn(qdevname);
    if (result == -1)
    {
        printf("Error in device string format:%s\n", _devname.c_str());
        exit(EXIT_FAILURE);
    }
    printf (
        "Parsed data:\n"
        "  | - Device 1=%s\n"
        "  | - Device 2=%s\n"
        "  | - Pixelclock %s Mhz, FPS %s\n"
        "  | - BPP:%s with bining %s\n"
        "  | - Sync:%s\n"
        "  \\ - GlobalShutter:%s\n",

        deviceStringPattern.cap(Device1Group).toLatin1().constData(),
        deviceStringPattern.cap(Device2Group).toLatin1().constData(),
        deviceStringPattern.cap(PixelClockGroup).toLatin1().constData(),
        deviceStringPattern.cap(FpsGroup).toLatin1().constData(),
        deviceStringPattern.cap(BitsGroup).toLatin1().constData(),
        deviceStringPattern.cap(BinningGroup).toLatin1().constData(),
        deviceStringPattern.cap(SyncGroup).toLatin1().constData(),
        deviceStringPattern.cap(GlobalShutterGroup).toLatin1().constData()
    );

    string leftName  = deviceStringPattern.cap(Device1Group).toLatin1().constData();
    string rightName = deviceStringPattern.cap(Device2Group).toLatin1().constData();
    bool err;

    int leftID =  deviceStringPattern.cap(Device1Group).toInt(&err);
    if (!err) {
        printf("Wrong left device ID (%s)\n", leftName.c_str());
    }

    int rightID =  deviceStringPattern.cap(Device2Group).toInt(&err);
    if (!err) {
        printf("Wrong right device ID (%s)\n", rightName.c_str());
    }

    int pixelClock = deviceStringPattern.cap(PixelClockGroup).toInt(&err);
    if (!err) pixelClock = 85;

    double fps = deviceStringPattern.cap(FpsGroup).toDouble(&err);
    if (!err) fps = 50.0;


/*    int width = deviceStringPattern.cap(WidthGroup).toInt(&err);
    if (!err || width <= 0) width = 800;

    int height = deviceStringPattern.cap(HeightGroup).toInt(&err);
    if (!err || height <= 0) height = 600;*/


    int binning = 1;
    binning = deviceStringPattern.cap(BinningGroup).toInt(&err);
    if (!err) binning = 1;

    sync = NO_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("sync")))
        sync = SOFT_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("hsync")))
        sync = HARD_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("fsync")))
        sync = FRAME_HARD_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("esync")))
        sync = EXT_SYNC;


    bool  globalShutter = false;
    if (!deviceStringPattern.cap(GlobalShutterGroup).compare(QString("global")))
        globalShutter = true;

    printf("Shutter is:%s\n", globalShutter ? "global" : "rolling");

    printf("Capture Left  device: GigE DeviceID = %d\n", leftID);
    printf("Capture Right device: GigE DeviceID = %d\n", rightID);

    leftCamera.init(leftID, (binning == 2), globalShutter, pixelClock, fps);
    rightCamera.init(rightID, (binning == 2), globalShutter, pixelClock, fps);

    skippedCount = 0;
    triggerSkippedCount = 0;
    frameDelay = 0;
}