If you’re a python man, here’s the relevant portion of the StackOverflow response.
import cv2
import urllib
import numpy as np
stream=urllib.urlopen('http://localhost:8080/frame.mjpg')
bytes=''
while True:
bytes+=stream.read(1024)
a = bytes.find('\xff\xd8')
b = bytes.find('\xff\xd9')
if a!=-1 and b!=-1:
jpg = bytes[a:b+2]
bytes= bytes[b+2:]
i = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR)
cv2.imshow('i',i)
if cv2.waitKey(1) ==27:
exit(0)
Mjpeg over http is multipart/x-mixed-replace with boundary frame info and jpeg data is just sent in binary. So you don’t really need to care about http protocol headers. All jpeg frames start with marker 0xff 0xd8 and end with 0xff 0xd9. So the code above extracts such frames from the http stream and decodes them one by one. like below.
...(http)
0xff 0xd8 --|
[jpeg data] |--this part is extracted and decoded
0xff 0xd9 --|
...(http)
0xff 0xd8 --|
[jpeg data] |--this part is extracted and decoded
0xff 0xd9 --|
...(http)
well, I solved this problem.
This Wifi stream now work on THETA V too.
Then I try to package it into HoloLens like other app I developed before.
but it failed. It seems some Unity API need to update. and the usage was changed.
I will continue to work on it.
well,I updated my unity to 2018.2.14f1 and did few modification, then it worked on HoloLens.
However,there are some problems:
The delay is very serious. Theta V camera stream video showed only about 0.5 FPS.
I think wifi signal and code compatibility issue coused this problem together.
when I wear HoloLens and walk, the HoloLens camera view moved with big lag, like not enough CPU resource.
when camera and HoloLens divided by a wall, the signal lost an HoloLens might be freezing.
Thanks for sharing your progress. Great news about the update.
The code base you are looking at is a bit old and using MotionJPEG.
Another strategy could be to use the plug-in API.
With the Hololens, is the only way to get the video to the headset through Wi-Fi?
This technique of using an external signalling server might be a fast way for you to get something going.
As you’re in Japan, you could try and contact the team at TwinCam Go, Tokyo Metropolitan University. They may be able to give you some tips with their project.
I recently got a loaner Oculus Go and will use it to test Wi-Fi streaming with webRTC and the NTT Enterprise Cloud WebRTC platform. I have not started the test yet. Note that the NTT Enterprise Cloud is free for community use with a sizable monthly quota.
Sorry that I forget the answer. Hololens basically is a wireless equipment which has 3 connection methods, usb(small like cell phone) , buletooth and Wi-Fi. To get the video in different room, Wi-Fi seems the most suitable one.
Then, the new API you gave me(https://api.ricoh/docs/theta-plugin/), is Android standard, I don’t know how to use those API in Unity and don’t know whether it supports HoloLens. And I am seeking some information from the existing demo. Most of those demo is for Android… well, I’m a little upset, now I am learning WebRTC&Unity try to find out something.
By the way, I wanna know the relationship between RICOH THETA API v2.1 and Plug-in API version 1. And can the latter be used on various platforms(Unity to HoloLens)?
Can you use another PC to run the Unity app and then stream it to HoloLens?
Connect the THETA V to the PC with a USB cable. Make sure the Unity app detects the THETA V as a webcam. Run the Unity app on your PC. Try the technique above to get the display onto the headset.
It looks like you should be able to use SteamVR with the Mixed Reality Headset.
Do you have the THETA V running inside of your Unity app on your PC using this technique?
Alternate technique
Have you tried this this technique to use Wi-Fi streaming to another room into HoloLens?
If you’re building your app with Unity, you may not need to use either API. Most people are plugging the THETA V into a USB cable and connecting it to their PC. They run the Unity app on their PC and display it to the headset.
The old package was for THETA S , but THETA V must using new API, several old API were not supported. So update the code to the new one can solve the problem.
I will upload my modified file tomorrow.