change to individual hotspot definitions

This commit is contained in:
interfisch 2023-10-07 00:26:50 +02:00
parent c88256a845
commit e2b2346f76
7 changed files with 84 additions and 37 deletions

View File

@ -5,13 +5,29 @@ https://pannellum.org/
## Usage
python panoconfig.py input.txt -o index.htm
python panoconfig.py input.txt -o pannellum/index.htm
put index.htm in panellum folder together with images inside images/ folder.
## input config file format
x,y,z,id,filename,angleoffset
FromFile,ToFile,Pitch,Yaw,TargetYaw|i
xyz have to be a consistent unit
angleoffset is positive if center of image is rotated ccw
## overlay Pitch and Yaw
run overlaylatLong.sh with .jpg files in same directory.
This will create an "overlay" directory with the fotos and a lat long overlay.
## Workflow
Add .jpg equirectengular 360 photos in a directory with overlayLatLong.sh .
Run overlayLatLong.sh
create a file (for example input.txt)
Add clickable hotspots in every line
Example: from kitchen.jpg to livingroom.jpg at pitch=0 and yaw=-30 (coordinats in from picture).
kitchen,livingroom,0,-30,i
(i for autocalculate yaw viewpoint in target photo)
Every image in the "to" field has to exist at least once as "from".
Download pannellum and put pannellum folder in directory next to the python file.
Run "python panoconfig.py input.txt -o pannellum/index.htm" to create index.htm with config in it.
Run python -m http.server in pannellum folder.
Navigate to http://localhost:8000

BIN
Rasteroverlay.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
Rasteroverlay.xcf Normal file

Binary file not shown.

View File

@ -1,3 +1,2 @@
570,260,50,Outside,outside.jpg,10
350,440,50,Inside,inside.jpg,270
435,530,50,Room,room.jpg,-70
kitchen,livingroom,0,-30,i
livingroom,kitchen,0,165,i

9
overlayLatLong.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
mkdir overlay
for file in *.jpg
do
echo "$file"
convert "$file" Rasteroverlay.png -gravity Center -composite overlay/overlay_"$file"
done

View File

@ -1,9 +1,13 @@
import math
import argparse
#old
#input config file format: x,y,z,id,filename,angleoffset
#angleoffset is 0 when center of 360 image points to the right, positive rotation means image center in pointing more CCW. value in degrees
#new:
#input config file format: FromFile,ToFile,Pitch,Yaw,TargetYaw|i,Text
parser = argparse.ArgumentParser(
prog = 'File Edit Script',
description = 'Read content of text file and write to file',
@ -40,59 +44,78 @@ with open(args.filename,'r') as rf:
linesinput=rf.readlines()
linesinput=[x.rstrip() for x in linesinput] #remove newline and whitespaces at end
linesmask=[True for x in linesinput]
output_scenes=[]
first_sceneId=None
for iline1,line1 in enumerate(linesinput):
if (linesmask[iline1]==False):
continue
x1,y1,z1,id1,filename1,angleoffset1=line1.split(',')
x1,y1,z1=(float(x1),float(y1),float(z1))
angleoffset1=float(angleoffset1)
print("Parsing: line1")
fromID,toID,pitch,yaw,targetYaw=line1.split(',')
#if (targetYaw=='i'):
# targetYaw=0
#pitch,yaw,targetYaw=(int(pitch),int(yaw),int(targetYaw))
if first_sceneId is None:
first_sceneId=id1 #take first entry as start scene
first_sceneId=fromID #take first entry as start scene
# ### Set information for scene ###
current_scene=template_scenes
current_scene=[x.replace('<id>',id1) for x in current_scene]
current_scene=[x.replace('<title>',id1) for x in current_scene]
current_scene=[x.replace('<filename>',filename1) for x in current_scene]
current_scene=[x.replace('<id>',fromID) for x in current_scene]
current_scene=[x.replace('<title>',fromID) for x in current_scene]
current_scene=[x.replace('<filename>',fromID+".jpg") for x in current_scene]
output_hotspots=[]
for iline2,line2 in enumerate(linesinput):
x2,y2,z2,id2,filename2,angleoffset2=line2.split(',')
x2,y2,z2=(float(x2),float(y2),float(z2))
angleoffset2=float(angleoffset2)
if (linesmask[iline2]==False):
continue
fromID2,toID2,pitch2,yaw2,targetYaw2=line2.split(',')
if fromID==fromID2:
linesmask[iline2]=False
if id1!=id2:
print()
print("from "+str(x1)+", "+str(y1)+" : "+id1)
print("to "+str(x2)+", "+str(y2)+" : "+id2)
print("dist="+str(distance(x1,y1,x2,y2)))
angle=math.degrees(math.atan2(y2-y1, x2-x1)) #in degrees
print("angle="+str(angle)+" offset1="+str(angleoffset1)+" offset2="+str(angleoffset2))
angle+=angleoffset1 #correct hotspot position by rotation of scene image
print("angle final="+str(angle))
pitch=-math.degrees(math.atan(z1/distance(x1,y1,x2,y2))) #from current looking to hotspot. 0deg=straight, 90deg=down
pitch=pitch/2 #manual correction
if (targetYaw2=='i'):
targetYaw2=0
for iline3,line3 in enumerate(linesinput):
fromID3,toID3,pitch3,yaw3,targetYaw3=line3.split(',')
if (toID2==fromID3 and fromID2==toID3):
targetYaw2=int(yaw3)-180
if (targetYaw2<-180):
targetYaw2+=360
print("Calculated Target Yaw="+str(targetYaw2))
pitch2,yaw2,targetYaw2=(int(pitch2),int(yaw2),int(targetYaw2))
print("from "+str(fromID2))
print("to "+str(toID2))
# ### Set information for target/hotspot ###
current_hotspot=template_hotspots
current_hotspot=[x.replace('<id>',id2) for x in current_hotspot]
current_hotspot=[x.replace('<yaw>',str(angle)) for x in current_hotspot]
current_hotspot=[x.replace('<pitch>',str(pitch)) for x in current_hotspot]
current_hotspot=[x.replace('<id>',toID2) for x in current_hotspot]
current_hotspot=[x.replace('<yaw>',str(yaw2)) for x in current_hotspot]
current_hotspot=[x.replace('<pitch>',str(pitch2)) for x in current_hotspot]
current_hotspot=[x.replace('<targetyaw>',str(targetYaw2)) for x in current_hotspot]
output_hotspots.append(current_hotspot)
output_hotspots_string=""
for _ihotspot,_hotspot in enumerate(output_hotspots):
if _ihotspot>0:

View File

@ -4,6 +4,6 @@
"type": "scene",
"text": "<id>",
"sceneId": "<id>",
"targetYaw": 0,
"targetYaw": <targetyaw>,
"targetPitch": 0
}