Hi there,
I spent the whole day looking for a way to get opencv to work with unity and I wasn’t able to get it to work.Some people were able to get it to work successfully. So can anyone share the method he used or a sample project if he can upload it ?
im using opencv with unity.there is an object following the movements of face detection circle on x,y,z axises.and i wanna prevent y,z axises and just move only for x axis
here is the code;
using UnityEngine;
public class PositionAtFaceScreenSpace : MonoBehaviour
{
private float _camDistance;
void Start()
{
_camDistance = Vector3.Distance(Camera.main.transform.position, transform.position);
}
void Update()
{
if (OpenCVFaceDetection.NormalizedFacePositions.Count == 0)
return;
transform.position = Camera.main.ViewportToWorldPoint(new Vector3( OpenCVFaceDetection.NormalizedFacePositions[0].x, OpenCVFaceDetection.NormalizedFacePositions[0].y, OpenCVFaceDetection.NormalizedFacePositions[0].z));
}
},how do i prevent y,z axises. i wanna move sphere only for x axis.
here is the movement code.
using UnityEngine;
public class PositionAtFaceScreenSpace : MonoBehaviour
{
private float _camDistance;
void Start()
{
_camDistance = Vector3.Distance(Camera.main.transform.position, transform.position);
}
void Update()
{
if (OpenCVFaceDetection.NormalizedFacePositions.Count == 0)
return;
transform.position = Camera.main.ViewportToWorldPoint(new Vector3( OpenCVFaceDetection.NormalizedFacePositions[0].x, OpenCVFaceDetection.NormalizedFacePositions[0].x, OpenCVFaceDetection.NormalizedFacePositions[0].x));
}
}