Skip to content

Instantly share code, notes, and snippets.

@RH2
Created May 5, 2022 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RH2/c29135dc5de2f5ce1ad656a6b2bc3624 to your computer and use it in GitHub Desktop.
Save RH2/c29135dc5de2f5ce1ad656a6b2bc3624 to your computer and use it in GitHub Desktop.
houdini import mark detection with camera registration.py
node = hou.pwd()
geo = node.geometry()
import os
import glob
geo.addAttrib(hou.attribType.Point, "id", 0)
geo.addAttrib(hou.attribType.Point, "corner", 0)
geo.addAttrib(hou.attribType.Point, "name", "")
geo.addAttrib(hou.attribType.Point, "dimx", 0)
geo.addAttrib(hou.attribType.Point, "dimy", 0)
geo.addAttrib(hou.attribType.Point, "camx", 0.0)
geo.addAttrib(hou.attribType.Point, "camy", 0.0)
geo.addAttrib(hou.attribType.Point, "camz", 0.0)
geo.addAttrib(hou.attribType.Point, "heading", 0.0)
geo.addAttrib(hou.attribType.Point, "pitch", 0.0)
geo.addAttrib(hou.attribType.Point, "roll", 0.0)
geo.addAttrib(hou.attribType.Point, "f", 0.0)
geo.addAttrib(hou.attribType.Point, "px", 0.0)
geo.addAttrib(hou.attribType.Point, "py", 0.0)
geo.addAttrib(hou.attribType.Point, "k1", 0.0)
geo.addAttrib(hou.attribType.Point, "k2", 0.0)
geo.addAttrib(hou.attribType.Point, "k3", 0.0)
geo.addAttrib(hou.attribType.Point, "k4", 0.0)
geo.addAttrib(hou.attribType.Point, "t1", 0.0)
geo.addAttrib(hou.attribType.Point, "t2", 0.0)
# f.write( "{name},{x},{y},{alt},{heading},{pitch},{roll},{f},{px},{py},{k1},{k2},{k3},{k4},{t1},{t2}".format(name=str() )
# Add code to modify contents of geo.
# Use drop down menu to select examples.
path = r"A:\Controllerscan\coke\mov1\det"
wildcard = r"*.txt"
completePath = os.path.join(path, wildcard)
print(completePath)
for det in glob.iglob(completePath):
f = open(det, "r")
content = f.read()
for line in content.split("\n"):
if line is not "":
vars = line.split(",")
#print(vars)
point = geo.createPoint()
point.setAttribValue("id", int(vars[0]))
point.setAttribValue("corner", int(vars[1]))
point.setAttribValue("dimx", int(vars[4]))
point.setAttribValue("dimy", int(vars[5]))
point.setAttribValue("name", vars[6])
point.setAttribValue("camx", float(vars[7]))
point.setAttribValue("camy", float(vars[8]))
point.setAttribValue("camz", float(vars[9]))
point.setAttribValue("heading", float(vars[10]))
point.setAttribValue("pitch", float(vars[11]))
point.setAttribValue("roll", float(vars[12]))
point.setAttribValue("f", float(vars[13]))
point.setAttribValue("px", float(vars[14]))
point.setAttribValue("py", float(vars[15]))
point.setAttribValue("k1", float(vars[16]))
point.setAttribValue("k2", float(vars[17]))
point.setAttribValue("k3", float(vars[18]))
point.setAttribValue("k4", float(vars[19]))
point.setAttribValue("t1", float(vars[20]))
point.setAttribValue("t2", float(vars[21]))
point.setPosition( (float(vars[2]), (1.0-float(vars[3])) , 0.0) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment