Skip to content

Commit 8bc7fe8

Browse files
committed
Seperate PS4 camera distortion by resolution
1 parent 3142a89 commit 8bc7fe8

2 files changed

Lines changed: 40 additions & 14 deletions

File tree

PSMSVirtualDeviceManager/Classes/Service/ClassSerivceConst.vb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,29 @@ Public Class ClassSerivceConst
6969
Class ClassCameraDistortion
7070
Enum ENUM_CAMERA_DISTORTION_TYPE
7171
PSEYE
72-
PS4CAM
72+
PS4CAM_SD
73+
PS4CAM_HD
7374
GENERIC
75+
76+
__MAX
7477
End Enum
7578

7679
Public Shared ReadOnly PSMOVESERVICE_KNOWN_DISTORTION As STRUC_CAMERA_DISTORTION_ITEM() = {
77-
New STRUC_CAMERA_DISTORTION_ITEM("PlayStation Eye", ENUM_CAMERA_DISTORTION_TYPE.PSEYE, 554.2563, 554.2563, 320, 240, -0.10771770030260086, 0.1213262677192688, 0.04875476285815239, 0.000917330733500421, 0.00010589254816295579), 'Error: Unknown
78-
New STRUC_CAMERA_DISTORTION_ITEM("PlayStation 4 Stereo Camera", ENUM_CAMERA_DISTORTION_TYPE.PS4CAM, 424.84967041015625, 515.53033447265625, 308.64697265625, 248.89617919921875, -0.021186288446187973, 0.049334883689880371, -0.062413521111011505, -0.00082370272139087319, 0.0016732711810618639) 'Error: 0.152170
80+
New STRUC_CAMERA_DISTORTION_ITEM("PlayStation Eye",
81+
ENUM_CAMERA_DISTORTION_TYPE.PSEYE,
82+
554.2563, 554.2563,
83+
320, 240,
84+
-0.10771770030260086, 0.1213262677192688, 0.04875476285815239, 0.000917330733500421, 0.00010589254816295579), 'Error: Unknown
85+
New STRUC_CAMERA_DISTORTION_ITEM("PlayStation 4 Stereo Camera (1080p)",
86+
ENUM_CAMERA_DISTORTION_TYPE.PS4CAM_HD,
87+
430.62008666992188, 521.9111328125,
88+
310.31588745117188, 248.12663269042969,
89+
-0.012369713746011257, 0.029541162773966789, -0.040692344307899475, 0.00077318056719377637, -0.0011542978463694453), 'Error: 0.152170
90+
New STRUC_CAMERA_DISTORTION_ITEM("PlayStation 4 Stereo Camera (480p)",
91+
ENUM_CAMERA_DISTORTION_TYPE.PS4CAM_SD,
92+
431.31747436523438, 522.7071533203125,
93+
306.66439819335938, 250.34086608886719,
94+
-0.0078428452834486961, 0.00922972708940506, -0.02076520211994648, 0.000541943998541683, -0.0013074720045551658) 'Error: 0.099504
7995
}
8096

8197
Structure STRUC_CAMERA_DISTORTION_ITEM

PSMSVirtualDeviceManager/UCVirtualTrackers/UCVirtualTrackerItem.vb

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,16 @@ Public Class UCVirtualTrackerItem
372372
' The PS4 Cam requires precomputed distortion.
373373
Dim mConstCameraDistortion As ClassSerivceConst.ClassCameraDistortion.STRUC_CAMERA_DISTORTION_ITEM = Nothing
374374
If (bIsPlayStationCamera) Then
375-
If (ClassSerivceConst.ClassCameraDistortion.GetKnownDistortionByType(ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PS4CAM, mConstCameraDistortion)) Then
375+
Dim iCameraByResolution = ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.GENERIC
376+
Select Case (iResolutionWidth)
377+
Case 640
378+
iCameraByResolution = ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PS4CAM_SD
379+
Case 1920
380+
iCameraByResolution = ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PS4CAM_HD
381+
End Select
382+
383+
If (iCameraByResolution <> ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.GENERIC AndAlso
384+
ClassSerivceConst.ClassCameraDistortion.GetKnownDistortionByType(iCameraByResolution, mConstCameraDistortion)) Then
376385
Dim bCorrectDistort As Boolean = (
377386
CSng(mConfigCameraDistortion.iFocalLengthX) = CSng(mConstCameraDistortion.iFocalLengthX) AndAlso
378387
CSng(mConfigCameraDistortion.iFocalLengthY) = CSng(mConstCameraDistortion.iFocalLengthY) AndAlso
@@ -397,21 +406,22 @@ Public Class UCVirtualTrackerItem
397406
Dim bCorrectDistort As Boolean = False
398407
Dim iBadTypes = {
399408
ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PSEYE,
400-
ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PS4CAM
409+
ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PS4CAM_SD,
410+
ClassSerivceConst.ClassCameraDistortion.ENUM_CAMERA_DISTORTION_TYPE.PS4CAM_HD
401411
}
402412
For Each iType In iBadTypes
403413
' Dont allow PSEye and PS4Cam calibrations
404414
If (ClassSerivceConst.ClassCameraDistortion.GetKnownDistortionByType(iType, mConstCameraDistortion)) Then
405415
bCorrectDistort = (
406-
CSng(mConfigCameraDistortion.iFocalLengthX) = CSng(mConstCameraDistortion.iFocalLengthX) AndAlso
407-
CSng(mConfigCameraDistortion.iFocalLengthY) = CSng(mConstCameraDistortion.iFocalLengthY) AndAlso
408-
CSng(mConfigCameraDistortion.iPrincipalX) = CSng(mConstCameraDistortion.iPrincipalX) AndAlso
409-
CSng(mConfigCameraDistortion.iPrincipalY) = CSng(mConstCameraDistortion.iPrincipalY) AndAlso
410-
CSng(mConfigCameraDistortion.iDistortionK1) = CSng(mConstCameraDistortion.iDistortionK1) AndAlso
411-
CSng(mConfigCameraDistortion.iDistortionK2) = CSng(mConstCameraDistortion.iDistortionK2) AndAlso
412-
CSng(mConfigCameraDistortion.iDistortionK3) = CSng(mConstCameraDistortion.iDistortionK3) AndAlso
413-
CSng(mConfigCameraDistortion.iDistortionP1) = CSng(mConstCameraDistortion.iDistortionP1) AndAlso
414-
CSng(mConfigCameraDistortion.iDistortionP2) = CSng(mConstCameraDistortion.iDistortionP2))
416+
CSng(mConfigCameraDistortion.iFocalLengthX) = CSng(mConstCameraDistortion.iFocalLengthX) AndAlso
417+
CSng(mConfigCameraDistortion.iFocalLengthY) = CSng(mConstCameraDistortion.iFocalLengthY) AndAlso
418+
CSng(mConfigCameraDistortion.iPrincipalX) = CSng(mConstCameraDistortion.iPrincipalX) AndAlso
419+
CSng(mConfigCameraDistortion.iPrincipalY) = CSng(mConstCameraDistortion.iPrincipalY) AndAlso
420+
CSng(mConfigCameraDistortion.iDistortionK1) = CSng(mConstCameraDistortion.iDistortionK1) AndAlso
421+
CSng(mConfigCameraDistortion.iDistortionK2) = CSng(mConstCameraDistortion.iDistortionK2) AndAlso
422+
CSng(mConfigCameraDistortion.iDistortionK3) = CSng(mConstCameraDistortion.iDistortionK3) AndAlso
423+
CSng(mConfigCameraDistortion.iDistortionP1) = CSng(mConstCameraDistortion.iDistortionP1) AndAlso
424+
CSng(mConfigCameraDistortion.iDistortionP2) = CSng(mConstCameraDistortion.iDistortionP2))
415425

416426
If (bCorrectDistort) Then
417427
Exit For

0 commit comments

Comments
 (0)