cancel
Showing results for 
Search instead for 
Did you mean: 

Rift nightvision experimentation

raidho36
Explorer
I was watching a diggers' video of going through abandoned bomb shelter, but there's clearly were traces of hobos presense, and they were shining their flashlight to see around. I thought better be ready for nutbar encounter, draw a knife or something. That's paranoid, obviously, but it gave an idea.


What if I use Rift-mounted camera as a nightvision device? If I use IR-filter-removed camera and attach an array of IR LEDs that would shine invisible IR light, the camera would pick it up as if it was regular flashlight, and the image will be routed to the Rift, effectively creating a DYI NV similar to that of military application.

Turns out you can actually do that, and it's quite easy, too. The downside is that you'd have to carry a computer and a UPS to power your setup. I didn't actually attached IR LEDs array to the Rift because I have no practical application for it, but I've tested it with camera and the array and it worked fairly well. As well as attaching LEDs to the Rift, you can replace regular LEDs with IR ones in LED flashlight and it'll work, too (don't forget to compensate for current difference).

The Unity scene setup is very simple: an OVRCameraController is being the root object, with it's two cameras as children, and another object as a child. This object has it's X and Y scale of something like 20 and Z scale of 1. It's sub-object is a quad with scale 1 and Z-position of roughly 20 as well. It's material is unlit texture.

Then there's a script that creates a webcam texture and assigns it to said material, so the quad displays webcam contents. There was an issue with camera lag and low framerate, and I think I've nailed it pretty well by letting the image stay in place in the scene as long as it takes while you rotate your head freely, and only update it's position (resetting it to the center of your view) when the new camera frame is arrived. It turned out to actually work pretty well. The main issue is that you end up completely stereoblind and your FOV is also getting pretty narrow (unless you use wide FOV cam).

using UnityEngine;
using System.Collections;

public class WebcamTextureScript : MonoBehaviour {
public Material mat;
public GameObject quad;
public GameObject cam;

private WebCamDevice[] devices;
private WebCamTexture texture;
private int current = 0;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
if ( texture != null && texture.didUpdateThisFrame )
{
quad.transform.rotation = cam.transform.rotation;
}
if ( Input.GetKeyDown ( "q" ) )
{
devices = WebCamTexture.devices;
if ( texture != null && texture.isPlaying )
texture.Stop ( );
if ( devices.Length > 0 )
{
texture = new WebCamTexture( devices[ current ].name, 768, 480, 60 );
current = ( current + 1 ) % devices.Length;
texture.Play ( );

quad.transform.localScale = new Vector3 ( 25.0f * ( (float)texture.width / (float)texture.height ), 25.0f, 1.0f );
mat.mainTexture = texture;
}
}
}
}
2 REPLIES 2

troach06
Honored Guest
That seems like a totally awesome idea for a VR experience! Especially in a cave, exploring the cave with night vision would be epic! Also, horror games would be even scarier! >:D

raidho36
Explorer
This is for actual IRL nightvision, kinda.