반응형
Changing dimensions and saving as an image. Classifying Models with Teachable Machine
자신의 이미지, 소리 및 포즈를 인식하도록 컴퓨터를 훈련 시키십시오. 사이트, 앱 등에 대한 머신 러닝 모델을 빠르고 쉽게 생성 할 수있는 방법-전문 지식이나 코딩이 필요하지 않습니다.
Teachable Machine 홈 페이지
Teachable Machine 사용 방법
1. Creo Template Model
Dimension Value로 모델을 회전 하기 위해 좌표계를 추가 한다.
2. VBA
1) Change the dimension value of the coordinate system
Source Code
모델에서 Dimension Name "MACHINE_Y"를 검색하고, 값을 변경 합니다
Sub JPG_IMAGE_EXPORT()
Dim asynconn As New Pfcls.CCpfcAsyncConnection
Dim conn As Pfcls.IpfcAsyncConnection
Dim session As Pfcls.IpfcBaseSession
On Error GoTo RunError
Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Dim model As IpfcModel
Set model = session.CurrentModel
'Cells 초기화
Range(Cells(6, "A"), Cells(Rows.Count, "A")).EntireRow.Delete
'Model File location
Cells(2, "c").Select
Selection.ClearContents
Cells(2, "c") = session.GetCurrentDirectory
'Model File Name
Cells(4, "c").Select
Selection.ClearContents
Cells(4, "c") = model.Filename
Dim Solid As IpfcSolid
Set Solid = model
Dim Modelowner As IpfcModelItemOwner
Set Modelowner = Solid
'Dimension Name
Dim CoordinateYdim As IpfcBaseDimension
Set CoordinateYdim = Modelowner.GetItemByName(EpfcModelItemType.EpfcITEM_DIMENSION, "MACHINE_Y")
'SET Regenerate
Dim RegenInstructions As New CCpfcRegenInstructions
Dim Instrs As IpfcRegenInstructions
Set Instrs = RegenInstructions.Create(True, True, Nothing)
Call session.SetConfigOption("regen_failure_handling", "resolve_mode")
'Window Repaint
Dim window As Pfcls.IpfcWindow
Set window = session.CurrentWindow
For i = 0 To 36
j = i * 10
CoordinateYdim.DimValue = j
Call Solid.Regenerate(Instrs)
Call window.Activate
Call window.Repaint
Cells(i + 6, "b") = j
Next i
Call session.SetConfigOption("regen_failure_handling", "no_resolve_mode")
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set model = Nothing
RunError:
If Err.Number <> 0 Then
MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
"Error No: " + CStr(Err.Number) + Chr(13) + _
"Error: " + Err.Description, vbCritical, "Error"
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect (2)
End If
End If
End If
End Sub
2) Save the screen as JPG
Y축을 10도 증강하여 36개의 JPG 파일을 저장 하고, Teachable Machine을 이용하여, 이미지로 부품 이름을 찾습니다.
Sub JPG_IMAGE_EXPORT()
Dim asynconn As New Pfcls.CCpfcAsyncConnection
Dim conn As Pfcls.IpfcAsyncConnection
Dim session As Pfcls.IpfcBaseSession
On Error GoTo RunError
Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Dim model As IpfcModel
Set model = session.CurrentModel
'Cells 초기화
Range(Cells(6, "A"), Cells(Rows.Count, "A")).EntireRow.Delete
'Model File location
Cells(2, "c").Select
Selection.ClearContents
Cells(2, "c") = session.GetCurrentDirectory
'Model File Name
Cells(4, "c").Select
Selection.ClearContents
Cells(4, "c") = model.Filename
Dim Solid As IpfcSolid
Set Solid = model
Dim Modelowner As IpfcModelItemOwner
Set Modelowner = Solid
Dim CoordinateYdim As IpfcBaseDimension
Set CoordinateYdim = Modelowner.GetItemByName(EpfcModelItemType.EpfcITEM_DIMENSION, "MACHINE_Y")
'SET Regenerate
Dim RegenInstructions As New CCpfcRegenInstructions
Dim Instrs As IpfcRegenInstructions
Set Instrs = RegenInstructions.Create(True, True, Nothing)
Call session.SetConfigOption("regen_failure_handling", "resolve_mode")
'Window Repaint
Dim window As Pfcls.IpfcWindow
Set window = session.CurrentWindow
'jpg 정의
Dim instructions As IpfcRasterImageExportInstructions
Dim imageExtension As String
Dim rasterHeight As Double, rasterWidth As Double
rasterHeight = 5
rasterWidth = 5
Dim dotsPerInch As Integer, imageDepth As Integer
dotsPerInch = EpfcDotsPerInch.EpfcRASTERDPI_100
imageDepth = EpfcRasterDepth.EpfcRASTERDEPTH_24
Dim creJPEG As New CCpfcJPEGImageExportInstructions
Dim JPEGInstrs As IpfcJPEGImageExportInstructions
Set JPEGInstrs = creJPEG.Create(rasterWidth, rasterHeight)
Set instructions = JPEGInstrs
session.ChangeDirectory ("D:\IDT\IMAGES")
For i = 0 To 36
j = i * 10
CoordinateYdim.DimValue = j
Call Solid.Regenerate(Instrs)
Call window.Activate
Call window.Repaint
oJpgfilename = model.FullName & "_" & j & ".JPG"
Call window.ExportRasterImage(oJpgfilename, instructions)
Cells(i + 6, "b") = j
Cells(i + 6, "c") = oJpgfilename
Next i
Call session.SetConfigOption("regen_failure_handling", "no_resolve_mode")
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set model = Nothing
RunError:
If Err.Number <> 0 Then
MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
"Error No: " + CStr(Err.Number) + Chr(13) + _
"Error: " + Err.Description, vbCritical, "Error"
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect (2)
End If
End If
End If
End Sub
Teachable Machine 어떻게 이용 할수 있을까?
Business inquiries : lionkk@idt21c.com
'Creo korea 임시' 카테고리의 다른 글
ToolBOX 프로그램 개발 - 라이브러리 관리 (0) | 2021.04.13 |
---|---|
Option 부품 선택 하기 프로그램 (0) | 2021.04.09 |
LAB) material 관리 프로그램 개발 (0) | 2021.03.25 |
LAB) UDF를 활용한 설계 검증 프로그램 (0) | 2021.03.25 |
Creo Illustrate 필요성 (0) | 2021.03.17 |