Exemplo n.º 1
0
    void USBCamera::open()
    {
        LINFO << "Capture: Trying to open USB camera.";
        LINFO << "Capture: (Warning) You can change the capture device with the configuration files.";

        try
        {
            if(!isOpened())
            {
                m_camera->release();
                m_camera->open(getDeviceNumber());
                setImageSize(m_frameWidth, m_frameHeight);

                if(!isOpened())
                {
                    throw OpenCVException("can't open usb camera");
                }
            }
        }
        catch(cv::Exception & ex)
        {
            throw OpenCVException(ex.msg.c_str());
        }

        LINFO << "Capture: Succesfully opened USB camera.";
    }
bool TinyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std::string &error)
{
    struct pcm *&streamHandle = _streamHandle[streamDirection];
    struct pcm_config pcmConfig;

    const AlsaCtlPortConfig::PortConfig &portConfig = getPortConfig();

    // Fill PCM configuration structure
    pcmConfig.channels = portConfig.channelNumber;
    pcmConfig.rate = portConfig.sampleRate;

    // Check Format is supported by the plugin
    if (portConfig.format >= pcmFormatTranslationTableSize) {

        error = "The format n°" + asString(portConfig.format) +
                " is not supported by the TinyAlsa plugin";
        return false;
    }

    uint8_t format = pcmFormatTranslationTable[portConfig.format].formatAsNumerical;

    // Check format is supported by Tinyalsa
    if (format == std::numeric_limits<uint8_t>::max()) {

        error = "The format " + pcmFormatTranslationTable[portConfig.format].formatAsString +
                " is not supported by Tinyalsa";
        return false;
    }

    pcmConfig.format = static_cast<pcm_format>(format);

    pcmConfig.period_size       = _periodTimeMs * pcmConfig.rate / _msPerSec;
    pcmConfig.period_count      = _nbRingBuffer;
    pcmConfig.start_threshold   = 0;
    pcmConfig.stop_threshold    = 0;
    pcmConfig.silence_threshold = 0;
    pcmConfig.silence_size      = 0;
    pcmConfig.avail_min         = 0;

    // Open and configure
    streamHandle = pcm_open(getCardNumber(),
                            getDeviceNumber(),
                            streamDirection == Capture ? PCM_IN : PCM_OUT,
                            &pcmConfig);

    // Prepare the stream
    if (!pcm_is_ready(streamHandle) || (pcm_prepare(streamHandle) != 0)) {

        // Format error
        error = formatAlsaError(streamDirection, "open", pcm_get_error(streamHandle));

        doCloseStream(streamDirection);
        return false;
    }

    return true;
}
Exemplo n.º 3
0
GstRecorder::GstRecorder(quint16 width, quint16 height, quint16 fps,
                         QString device, QObject *parent)
    : QObject(parent),
      videoWitdhPx(width),
      videoHeightPx(height),
      framerate(fps),
      devicepath(device) {
  QGst::init();
  deviceNumber = getDeviceNumber(devicepath);
  qDebug() << "GstRecoder: Initilaizing...";
  if (QGst::ElementFactory::find("omxh264enc")) {
    usesOmx = true;
    qDebug() << "GstRecoder: using OpenMAX";
  }
}
bool 
MCP23008Expander::start()
{
    // Init the implementation object
    g_mcp23008_set_i2c_address( expander, getDeviceNumber(), getBusAddress() );

    // Start things up
    g_mcp23008_start( expander );

    // Turn all of the pins over to outputs
    g_mcp23008_set_pin_mode( expander, 0, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 1, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 2, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 3, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 4, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 5, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 6, MCP23008_PIN_OUTPUT );
    g_mcp23008_set_pin_mode( expander, 7, MCP23008_PIN_OUTPUT );
}
Boolean UNIX_AssociatedProtocolController::getDeviceNumber(CIMProperty &p) const
{
	p = CIMProperty(PROPERTY_DEVICE_NUMBER, getDeviceNumber());
	return true;
}