Jump to content

ViveSR C API ViveSR_GetMultiDataSize() not working


Hanno

Recommended Posts

Hi, 

 

I'm trying to get the C API working in my application but I'm having some trouble. I looked at the ViveSR_VS2015_SampleCode project and I believe I'm creating and initializing everything the way I'm supposed to but  ViveSR_GetMultiDataSize() always returns 13 i.e. SR_Error:: DATA_NOT_FOUND.

 

I'm using a Vive Pro and I have used the lighthouse_console.exe tool to dump the config.json and copied it to the appropriate ..Steam\config\lighthouse\lhr-3bd88144 folder.

 

The demo applications are working as expected, just not my C++ application.

 

Any thoughts?

 

Regards,
Hanno

Link to comment
Share on other sites

hi Hanno,

 

 

Did the camera works fine?

you can check by these two ways :

1. press "1" in sample-vs2015.exe console

2. go to steamvr->setting->camera*>Test Camera Rate(should see live camera videostreaming and 3 green checked signs)

 

And could you upload SRWorks.log file seeing what's happened?

Link to comment
Share on other sites

Thanks for the quick reply!

 

Yes the camera works fine, I have check both ways. Pressing 1 in the sample shows 2 windows displaying the left and right cameras and the steamvr->settings->camera->Test Camera Rate shows video streaming with 3 green check marks.

 

I should mention that I'm using OpenVR in the same application - in other word OpenVR is already initialized when I call ViveSR_Initial(). Could this be a problem?

 

Here is the contents of the SRWorks.log file (the forum doesn't allow me to upload files with a .log extension):

 

[Vive SRWorks] [2018-05-28 10:56:37] [LOG] ViveSR_Initial() success
[Vive SRWorks] [2018-05-28 10:56:37] [LOG] ViveSR_CreateModule() start
[JSON] [2018-05-28 10:56:37] [LOG] E:\Games\Steam
[JSON] [2018-05-28 10:56:37] [LOG] found steam install path
[JSON] [2018-05-28 10:56:37] [LOG] usig device : LHR-3BD88144
[JSON] [2018-05-28 10:56:37] [LOG] found device config file
[JSON] [2018-05-28 10:56:38] [LOG] Cali_V2D_00000
[JSON] [2018-05-28 10:56:38] [LOG] MIE_GCP_00000
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] CM_MT2_MID0_00000
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() end
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() start
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] CM_MT3_MID2_00000
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() end
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() start
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] CM_MT4_MID4_00000
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() end
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() start
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] CM_MT5_MID6_00000
[Vive SRWorks] [2018-05-28 10:56:38] [LOG] ViveSR_CreateModule() end
[DEVICE_VIVE2_MODE2_0] [2018-05-28 10:56:39] [LOG] M_MSCD_set_VRINT_1
[DEVICE_VIVE2_MODE2_0] [2018-05-28 10:56:39] [LOG] M_MSCD_set_VRINT_TYPE1
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0ViveSR_StartModule() start
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0ViveSR_StartModule() check pass
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0ViveSR_StartModule() initial end
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0ViveSR_StartModule() initial pass
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0ViveSR_StartModule() start pass
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0_00000
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM0ViveSR_StartModule() end
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM2ViveSR_StartModule() start
[Vive SRWorks] [2018-05-28 10:56:39] [LOG] SM2ViveSR_StartModule() check pass
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:39] [LOG] initialization mode 2-2
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:39] [LOG] Create Mapping table start
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:39] [LOG] Create Mapping table end
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:39] [LOG] Create Mapping table start
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:40] [LOG] Create Mapping table end
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:40] [LOG] initialization mode end2-2
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM2ViveSR_StartModule() initial end
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM2ViveSR_StartModule() initial pass
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:40] [LOG] TurnOn
() start pass
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM2_00000
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM2ViveSR_StartModule() end
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4ViveSR_StartModule() start
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4ViveSR_StartModule() check pass
[ENGINE_DEPTH_4] [2018-05-28 10:56:40] [LOG] init_S
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:40] [LOG] loading undistortion parameters start
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4ViveSR_StartModule() initial end
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4ViveSR_StartModule() initial pass
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4ViveSR_StartModule() start pass
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4_00000
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM4ViveSR_StartModule() end
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM6ViveSR_StartModule() start
[Vive SRWorks] [2018-05-28 10:56:40] [LOG] SM6ViveSR_StartModule() check pass
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:41] [LOG] loading undistortion parameters end
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:41] [LOG] loading undistortion parameters start
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:41] [LOG] loading undistortion parameters end
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:41] [LOG] TurnOn end
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] SM6ViveSR_StartModule() initial end
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] SM6ViveSR_StartModule() initial pass
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] SM6ViveSR_StartModule() start pass
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] SM6_00000
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] SM6ViveSR_StartModule() end
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] ViveSR_ModuleLink() start
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] LM0-2_MODE1_00000
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] ViveSR_ModuleLink() end
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] ViveSR_ModuleLink() start
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] LM2-4_MODE1_00000
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] ViveSR_ModuleLink() end
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] ViveSR_ModuleLink() start
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] LM4-6_MODE1_00000
[Vive SRWorks] [2018-05-28 10:56:41] [LOG] ViveSR_ModuleLink() end
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:56:59] [LOG] module alive
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:57:10] [LOG] module alive
[ENGINE_UNDISTORTION_2_DLL] [2018-05-28 10:57:22] [LOG] module alive

 

Link to comment
Share on other sites

It should be: ViveSR:: SRModule_TYPE:: ENGINE_UNDISTORTION 

 

I'm doing something very similar to C example project by calling:

ViveSR_CreateModule(ViveSR:: SRModule_TYPE::ENGINE_UNDISTORTION, sr_module_id + 1));

 

and then later calling:

ViveSR_GetMultiData(sr_module_id[1], (void*)data_all, mask, size);

 

 

Link to comment
Share on other sites

It should be: ViveSR:: SRModule_TYPE:: ENGINE_UNDISTORTION 

 

I'm doing something very similar to C example project by calling:

ViveSR_CreateModule(ViveSR:: SRModule_TYPE::ENGINE_UNDISTORTION, sr_module_id + 1));

 

and then later calling:

ViveSR_GetMultiData(sr_module_id[1], (void*)data_all, mask, size);

 

the usage flow :

step 1. ViveSR_Initial()

step 2. ViveSR_CreateModule(Module A);

step 3. ViveSR_CreateModule(Module B);

step 4. ViveSR_StartModule(Module A);

step 5. ViveSR_StartModule(Module B);

step 6. ViveSR_ModuleLink(Module A, Module B);

step N. GetMultiDataSize/GetMultiData(Module B);

 

Module B has no data for GetMultiDataSize & GetMultiData  API untill step 6 had been done

 

the original sample-vs2015.exe, press 'g' is a simple example for GetMultiDataSize & GetMultiData  API.

Is this example works correckly on your side?

Link to comment
Share on other sites

Ah yes I didn't say that in my post but I do follow the steps as you show. My code looks something like this:

 

ViveSR_CreateModule(ViveSR:: SRModule_TYPE:: DEVICE_VIVE2_MODE2, aModuleID)
ViveSR_CreateModule(ViveSR:: SRModule_TYPE:: ENGINE_UNDISTORTION, aModuleID + 1)
ViveSR_CreateModule(ViveSR:: SRModule_TYPE:: ENGINE_DEPTH, aModuleID + 2)
ViveSR_CreateModule(ViveSR:: SRModule_TYPE:: ENGINE_RIGID_RECONSTRUCTION, aModuleID + 3)

 

ViveSR_StartModule(aModuleID[0]);
ViveSR_StartModule(aModuleID[1]);
ViveSR_StartModule(aModuleID[2]);
ViveSR_StartModule(aModuleID[3]);

 

ViveSR_ModuleLink(aModuleID[0], aModuleID[1], ViveSR:: SRWorks_Link_Method:: SR_Active);
ViveSR_ModuleLink(aModuleID[1], aModuleID[2], ViveSR:: SRWorks_Link_Method:: SR_Active);
ViveSR_ModuleLink(aModuleID[2], aModuleID[3], ViveSR:: SRWorks_Link_Method:: SR_Active);

 

And then ViveSR_GetMultiDataSize(aModuleID[1], &uSize, iMask)

 

When I press 'g' in the sample I just get two windows not displaying anything but if I put a break point in the code then ViveSR_GetMultiDataSize() returns ViveSR:: SR_Error:: WORK.

 

So it looks like the ViveSR_GetMultiDataSize() call works but I'm not sure what else is supposed to happen when I press 'g' ?

 

Link to comment
Share on other sites

Seems there is a timing issue. A workaround now is to add some delay before ViveSR_GetMultiData() at first time call. In the sample after pressed 'g', it will popup 2 windows showing undistroted righ and left images, respectively.

Link to comment
Share on other sites

I see, how big of a delay? A couple of milliseconds or seconds?

 

When I press '1' in the sample I get windows showing the left and right images but pressing 'g' just brings up two windows with black backgrounds. Does this mean there is still some configuration or maybe hardware issues?

 

 

 

 

Link to comment
Share on other sites

According to my test, it is about 50~100ms. It only needs when run with "Start Debugging" mode in VS2015 but no need if run at "Start Without Debugging" mode.

 

Please try to add the code snippet marked in RED below for key 'g' to see if it works. 

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

char *data_all = (char*)malloc(size);
while (1) //added
//added
if (data_all) {
ViveSR_GetMultiData(sr_module_id[1], (void*)data_all, mask, size);
memcpy(gc_raw_undistorted_data_l, data_all, sizeof(char)* frame_width * frame_height * frame_channel);
data_shift += sizeof(char)* frame_width * frame_height * frame_channel;
memcpy(gc_raw_undistorted_data_r, data_all + data_shift, sizeof(char)* frame_width * frame_height * frame_channel);
data_shift += sizeof(char)* frame_width * frame_height * frame_channel;
memcpy(&FrameSeq, data_all + data_shift, sizeof(unsigned int));
data_shift += sizeof(unsigned int);
memcpy(&TimeStp, data_all + data_shift, sizeof(unsigned int));
data_shift += sizeof(unsigned int);
memcpy(sr_pose_l, data_all + data_shift, sizeof(float) * 16);
data_shift += sizeof(float) * 16;
memcpy(sr_pose_r, data_all + data_shift, sizeof(float) * 16);
}
fprintf(stderr, "FrameSeq : %ud, TimeStp : %ud, pose %f, %f\n", FrameSeq, TimeStp, sr_pose_l[12], sr_pose_r[12]);
cv::Mat _undistort_l = cv::Mat(UNDISTORTED_IMAGE_H, UNDISTORTED_IMAGE_W, CV_8UC3, gptr_undistorted_l).clone();
cv::Mat _undistort_r = cv::Mat(UNDISTORTED_IMAGE_H, UNDISTORTED_IMAGE_W, CV_8UC3, gptr_undistorted_r).clone();
cv::cvtColor(_undistort_l, _undistort_l, CV_RGB2BGR);
cv::cvtColor(_undistort_r, _undistort_r, CV_RGB2BGR);
cv::imshow("ViveSR_GetDataMulti_L", _undistort_l);
cv::imshow("ViveSR_GetDataMulti_R", _undistort_r);
cv::waitKey(1);
data_shift = 0; //added
//added

free(data_all);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...