Here’s a step by step by guide of what works on every platform (Windows, Mac, Linux) (Reference: https://github.com/muimota/thetav_proxy):
-
Install nodejs: https://nodejs.org/en/ For jetson nano: sudo apt-get install nodejs libssl1.0-dev nodejs-dev
-
Write the following code and save it as anyName.js (e.g. thetav.js)
const http = require('http')
const server = http.createServer()
console.log("\nRICOH theta V camera proxy\n2019 @muimota")
server.on('request', (_req,_res) =>
{
const data = '{"name": "camera.getLivePreview"}'
const options = {
hostname: '192.168.1.1',
port: 80,
path: '/osc/commands/execute',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req = http.request(options, (res) => {
_res.writeHead(200,
{'Connection': 'Keep-Alive',
'Content-Type': 'multipart/x-mixed-replace; boundary="---osclivepreview---"',
'X-Content-Type-Options':'nosniff',
'Transfer-Encoding': 'Chunked'})
res.on('data', (d) => {
_res.write(d)
})
})
req.on('error', (error) => {
console.log('Error connecting ricoh camera')
_res.end('Error connecting ricoh camera')
})
req.write(data)
req.end()
}
)
server.listen(8000)
- Optional: only if someone had destroyed the network interface of jetson nano like me after following the guide i posted in the above reply to make the wifi adapter work as a proper wifi adapter again.
- Revert changes to /etc/dhcp/dhcpd.conf
- Revert changes to /etc/default/isc-dhcp-server
- Revert changes to /etc/network/interfaces. Make it:
source /etc/network/interfaces.d/* - Remove everything in /etc/hostapd/hostapd.conf
- Revert changes to /etc/sysctl.conf
- Revert changes to /etc/default/hostapd
- Revert startup changes:
sudo update-rc.d -f hostapd remove
sudo update-rc.d -f isc-dhcp-server remove - Revert changes to /etc/iptables.ipv4.nat
- Reboot the system
-
Start Theta V camera with connecting to smartphone via Theta’s Wifi mode (https://support.theta360.com/uk/manual/v/content/prepare/prepare_08.html) << basically the initial steps of how you connected your theta to phone, i.e. change wireless mode such that blue wireless lamp flashes on theta.
-
Connect to theta V’s wifi. For ubuntu, click network manager in ubuntu > click “connect to hidden wifi network” >
-
Connection: New
-
Network name: name that appeared on your smartphone. e.g. THETAYLXXXXXXXX.OSC
-
Wifi security: WPA / WPA 2 Personal. Add password. For me it’s theta’s serial number as usual.
For windows and mac, they should automatically find the network SSID, you just need to put your theta’s serial number in password.
-
in terminal (ubuntu/mac) or powershell (windows): node thetav.js
-
Go to http://127.0.0.1:8000 in Chrome or Firefox. You should see video stream with near-negligible network latency, limited to 65 Mbps (max speed supported by theta V).
-
It’s also possible to use it with gstreamer, which can later be used with cv2.videocapture like i used in my previous reply.
gst-launch-1.0 -v souphttpsrc location=http://127.0.0.1:8000 ! decodebin ! autovideosink -
For the method that worked for me (the node js thingy), here’s the python code i use to capture frames:
import os
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "dummy"
import cv2
import datetime
vcap = cv2.VideoCapture("http://127.0.0.1:800/")
while(1):
ret,frame = vcap.read()
cv2.imshow('VIDEO',frame)
cv2.waitkey(1)
I would say this nodejs solution is pretty good. The fps is consistent at 30 and the latency is 0.3 seconds max.