Exemplo n.º 1
0
void URealSenseTask::EnableHandDetection(bool enable)
{
	if (!collector->IsValid()){
		UE_LOG(RealSensePluginLog, Warning, TEXT("RealSense unavailable."));
		return;
	}

	//local pointer
	PXCSenseManager* pp = collector->psm;

	pxcStatus status = pxcStatus::PXC_STATUS_NO_ERROR;
	/* Set Module */
	if (!enable){
		collector->handModule->Release();
		// Hand Module Configuration
		PXCHandConfiguration* config = collector->handModule->CreateActiveConfiguration();
		config->DisableAllAlerts();

		config->ApplyChanges();
		config->Update();

		collector->handConfig = config;

		HandsEnabled = false;
		return;
	}
	if (enable)
	{
		status = pp->EnableHand();
		collector->handModule = pp->QueryHand();
	}

	PXCHandModule* handModule = collector->handModule;

	if (handModule == NULL || status != pxcStatus::PXC_STATUS_NO_ERROR)
	{
		UE_LOG(RealSensePluginLog, Log, TEXT("Failed to pair the hand module with I/O"));
		return;
	}

	if (pp->Init(collector) >= PXC_STATUS_NO_ERROR)
	{
		collector->handData = collector->handModule->CreateOutput();
	}

	// Hand Module Configuration
	PXCHandConfiguration* config = handModule->CreateActiveConfiguration();
	config->EnableNormalizedJoints(true);
	if (true) config->SetTrackingMode(PXCHandData::TRACKING_MODE_FULL_HAND);
	config->EnableAllAlerts();
	//config->EnableSegmentationImage(true);

	config->ApplyChanges();
	config->Update();

	collector->handConfig = config;

	HandsEnabled = true;
}
Exemplo n.º 2
0
    void initializeHandTracking()
    {
        // 手の検出器を作成する
        handAnalyzer = senseManager->QueryHand();
        if ( handAnalyzer == 0 ) {
            throw std::runtime_error( "手の検出器の取得に失敗しました" );
        }

        // 手のデータを取得する
        handData = handAnalyzer->CreateOutput();
        if ( handData == 0 ) {
            throw std::runtime_error( "手の検出器の作成に失敗しました" );
        }

        // RealSense カメラであれば、プロパティを設定する
        PXCCapture::DeviceInfo dinfo;
        senseManager->QueryCaptureManager()->QueryDevice()->QueryDeviceInfo( &dinfo );
        if ( dinfo.model == PXCCapture::DEVICE_MODEL_IVCAM ) {
            PXCCapture::Device *device = senseManager->QueryCaptureManager()->QueryDevice();
            device->SetDepthConfidenceThreshold( 1 );
            //device->SetMirrorMode( PXCCapture::Device::MIRROR_MODE_DISABLED );
            device->SetIVCAMFilterOption( 6 );
        }

        // Hand Module Configuration
        PXCHandConfiguration* config = handAnalyzer->CreateActiveConfiguration();
        //config->EnableNormalizedJoints( showNormalizedSkeleton );
        //config->SetTrackingMode( PXCHandData::TRACKING_MODE_EXTREMITIES );
        //config->EnableAllAlerts();
        config->EnableSegmentationImage( true );

        config->ApplyChanges();
        config->Update();
    }
bool GesturePipeline::init()
{
    _pxcSenseManager = PXCSenseManager::CreateInstance();
    /* Set Mode & Source */
    pxcCHAR * deviceName = retrieveDeviceName();
    _pxcSenseManager->QueryCaptureManager()->FilterByDeviceInfo(deviceName, 0, 0);


    pxcStatus status = _pxcSenseManager->EnableHand();
    _pxcHandModule = _pxcSenseManager->QueryHand();

    if (_pxcHandModule == NULL || status != pxcStatus::PXC_STATUS_NO_ERROR)
    {
        cocos2d::log("Failed to pair the gesture module with I/O");
        return 0;
    }

    /* Init */
    if (_pxcSenseManager->Init() >= PXC_STATUS_NO_ERROR)
    {
        _pxcHandData = _pxcHandModule->CreateOutput();

        initRules(_pxcHandData);


        // IF IVCAM Set the following properties
        PXCCapture::Device *device = _pxcSenseManager->QueryCaptureManager()->QueryDevice();
        PXCCapture::DeviceInfo dinfo;
        device->QueryDeviceInfo(&dinfo);
        if (dinfo.model == PXCCapture::DEVICE_MODEL_IVCAM)
        {
            device->SetDepthConfidenceThreshold(1);
            device->SetMirrorMode(PXCCapture::Device::MIRROR_MODE_DISABLED);
            device->SetIVCAMFilterOption(6);
        }

        // Hand Module Configuration
        PXCHandConfiguration* config = _pxcHandModule->CreateActiveConfiguration();
        config->SetTrackingMode(PXCHandData::TrackingModeType::TRACKING_MODE_FULL_HAND);
        config->EnableSegmentationImage(true);

        config->ApplyChanges();
        config->Update();
        config->Release();

        return 1;
    }
    else
    {
        cocos2d::log("Init Failed");
        return 0;
    }

}
Exemplo n.º 4
0
void URealSenseTask::EnableGestureDetection(bool enableAll, bool enable, FString singleGesture)
{
	if (!collector->IsValid()){
		UE_LOG(RealSensePluginLog, Warning, TEXT("RealSense unavailable."));
		return;
	}

	PXCHandConfiguration* config = collector->handConfig;

	//Null check, hand has to be enabled before we can enable gestures
	if (config == NULL)
	return;

	//enable gestures
	config->LoadGesturePack(L"navigation");

	//single gesture enabling example
	if (!singleGesture.IsEmpty()){
		if (enable)
		{
			config->EnableGesture(*singleGesture);
			GesturesEnabled = true;
		}
		else
		{
			config->DisableGesture(*singleGesture);
		}
	}
	else{
		//enable all gestures
		if (enableAll)
		{
			config->EnableAllGestures();
			UE_LOG(RealSensePluginLog, Log, TEXT("Gestures enabled"));
		}
			
		else
		{
			config->DisableAllGestures();
			UE_LOG(RealSensePluginLog, Log, TEXT("Gestures disabled"));
		}

		GesturesEnabled = enableAll;
	}

	config->ApplyChanges();
	config->Update();	
}
void GesturePipeline::enableGestureDetectedRule(bool enabled, bool continuousTracking)
{
    // Hand Module Configuration
    PXCHandConfiguration* config = _pxcHandModule->CreateActiveConfiguration();

    if (enabled)
        config->EnableAllGestures(true);
    else config->DisableAllGestures();

    config->ApplyChanges();
    config->Update();
    config->Release();

    _gestureDetectedRule->enabled = enabled;
    _gestureDetectedRule->_continuousTracking = continuousTracking;
}