Update
This commit is contained in:
parent
7d25bb8f2f
commit
a2bf3236b0
|
|
@ -21,7 +21,7 @@ global proc AEInputDeviceReplace(string $attr)
|
|||
global proc AEadjustInputDevice(string $attr)
|
||||
{
|
||||
string $value = `optionMenuGrp -q -v a2vAEInputDevice`;
|
||||
setAttr $attr $value -type "string";
|
||||
setAttr -type "string" $attr $value;
|
||||
}
|
||||
|
||||
global proc AEInputTypeNew(string $attr)
|
||||
|
|
@ -51,11 +51,13 @@ global proc AEVideoPathNew(string $attr)
|
|||
{
|
||||
setUITemplate -pst attributeEditorTemplate;
|
||||
textFieldButtonGrp -l "Video Path" a2VAEVideoPath;
|
||||
|
||||
setUITemplate -ppt;
|
||||
textFieldButtonGrp -e
|
||||
-tx ""
|
||||
-buttonCommand ("AEVideoPathBrowse "+$attr)
|
||||
-changeCommand ("AEAdjustVideoPath "+$attr)
|
||||
-buttonLabel "..."
|
||||
-placeholderText "Select Video File"
|
||||
-forceChangeCommand
|
||||
a2VAEVideoPath;
|
||||
|
||||
|
|
@ -72,18 +74,23 @@ global proc AEVideoPathBrowse(string $attr)
|
|||
string $value = `getAttr $attr`;
|
||||
string $currentDir = `dirname $value`;
|
||||
string $videoFilters = "MP4 Files (*.mp4);;MOV Files (*.mov);;AVI Files (*.avi);;MPEG Files (*.mpg);;All Files (*.*)";
|
||||
string $result[] = `fileDialog2 -caption "Select Video File" -fileMode 1 -fileFilter $videoFilters -selectFileFilter "MP4 Files" -dialogStyle 2`
|
||||
string $result[] = `fileDialog2 -dialogStyle 2
|
||||
-caption "Select Video File"
|
||||
-fileMode 1
|
||||
-fileFilter $videoFilters
|
||||
-startingDirectory $currentDir
|
||||
-selectFileFilter "MP4 Files"`;
|
||||
|
||||
if($result){
|
||||
if(`size $result`){
|
||||
textFieldButtonGrp -e -tx $result[0] a2VAEVideoPath;
|
||||
setAttr $attr $result[0] -type "string";
|
||||
setAttr -type "string" $attr $result[0];
|
||||
}
|
||||
}
|
||||
|
||||
global proc AEAdjustVideoPath(string $attr)
|
||||
{
|
||||
string $value = `textFieldButtonGrp -q -tx a2VAEVideoPath`;
|
||||
setAttr $attr $value;
|
||||
setAttr -type "string" $attr $value;
|
||||
}
|
||||
|
||||
global proc AEVideo2ARKitTemplate(string $nodeName)
|
||||
|
|
@ -109,11 +116,11 @@ global proc AEVideo2ARKitTemplate(string $nodeName)
|
|||
// editorTemplate -addControl "inputDevice";
|
||||
editorTemplate -callCustom "AEInputDeviceNew"
|
||||
"AEInputDeviceReplace"
|
||||
$nodeName;
|
||||
"inputDevice";
|
||||
//editorTemplate -addControl "videoPath";
|
||||
editorTemplate -callCustom "AEVideoPathNew"
|
||||
"AEVideoPathReplace"
|
||||
$nodeName;
|
||||
"videoPath";
|
||||
editorTemplate -addControl "networkUrl";
|
||||
editorTemplate -addControl "networkPort";
|
||||
editorTemplate -addControl "modelPath";
|
||||
|
|
|
|||
|
|
@ -49,31 +49,35 @@ class Video2ARKitNode(om.MPxNode):
|
|||
|
||||
def compute(self, plug, data_block):
|
||||
# 如果正在請求輸出屬性 (52個中的任何一個)
|
||||
if plug in self.output_attrs.values():
|
||||
print(self.output_attrs.values())
|
||||
|
||||
# 獲取輸入值
|
||||
current_time = data_block.inputValue(self.aInTime).asMTime().asUnits(om.MTime.kFilm) # 假設 24fps
|
||||
trigger = data_block.inputValue(self.aProcessTrigger).asBool()
|
||||
video_path = data_block.inputValue(self.aVideoPath).asString()
|
||||
model_path = data_block.inputValue(self.aModelPath).asString()
|
||||
input_type = data_block.inputValue(self.aInputType).asInt()
|
||||
if all(plug != o_attr for o_attr in self.output_attrs.values()):
|
||||
return
|
||||
# if plug in self.output_attrs.values():
|
||||
|
||||
# 檢查是否需要重新分析影片
|
||||
if trigger and not self._cache:
|
||||
self._cache = process.process_video(video_path, model_path)
|
||||
# 獲取輸入值
|
||||
current_time = data_block.inputValue(self.aInTime).asTime().asUnits(om.MTime.kFilm) # 假設 24fps
|
||||
trigger = data_block.inputValue(self.aProcessTrigger).asBool()
|
||||
video_path = data_block.inputValue(self.aVideoPath).asString()
|
||||
model_path = data_block.inputValue(self.aModelPath).asString()
|
||||
input_type = data_block.inputValue(self.aInputType).asInt()
|
||||
|
||||
# 獲取當前幀數的權重
|
||||
frame_idx = int(current_time)
|
||||
frame_data = self._cache.get(frame_idx, {})
|
||||
# 檢查是否需要重新分析影片
|
||||
if trigger and not self._cache:
|
||||
self._cache = process.process_video(video_path, model_path)
|
||||
|
||||
# 輸出對應的值
|
||||
for name, attr_obj in self.output_attrs.items():
|
||||
if plug == attr_obj:
|
||||
val = frame_data.get(name, 0.0)
|
||||
handle = data_block.outputValue(attr_obj)
|
||||
handle.setFloat(val)
|
||||
data_block.setClean(plug)
|
||||
return
|
||||
# 獲取當前幀數的權重
|
||||
frame_idx = int(current_time)
|
||||
frame_data = self._cache.get(frame_idx, {})
|
||||
|
||||
# 輸出對應的值
|
||||
for name, attr_obj in self.output_attrs.items():
|
||||
if plug == attr_obj:
|
||||
val = frame_data.get(name, 0.0)
|
||||
handle = data_block.outputValue(attr_obj)
|
||||
handle.setFloat(val)
|
||||
data_block.setClean(plug)
|
||||
return
|
||||
|
||||
def setDependencyDirty(self, plug, affectedPlugs):
|
||||
if plug == self.aProcessTrigger:
|
||||
|
|
|
|||
Loading…
Reference in New Issue