본문 바로가기
  • 환영 합니다 ! Welcome!
Creo korea 임시

LAB) 자동으로 View 저장 하여, Teachable Machine 적용

by ToolBOX01 2021. 3. 26.
반응형

Changing dimensions and saving as an image. Classifying Models with Teachable Machine

 

자신의 이미지, 소리 및 포즈를 인식하도록 컴퓨터를 훈련 시키십시오. 사이트, 앱 등에 대한 머신 러닝 모델을 빠르고 쉽게 생성 할 수있는 방법-전문 지식이나 코딩이 필요하지 않습니다.

 

 

Teachable Machine 홈 페이지

 

Teachable Machine

Train a computer to recognize your own images, sounds, & poses. A fast, easy way to create machine learning models for your sites, apps, and more – no expertise or coding required.

teachablemachine.withgoogle.com

 

Teachable Machine 사용 방법

Teachable Machine 사용 방법

1. Creo Template Model

Dimension Value로 모델을 회전 하기 위해 좌표계를 추가 한다.

 

Add coordinate system

 

 

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을 이용하여, 이미지로 부품 이름을 찾습니다. 

 

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 v1 .xlsm
0.03MB

 

 

 

 

 

Teachable Machine 어떻게 이용 할수 있을까?

 

코랄을 어디에? 왜? Why, Where Coral?

코랄에 대해 글이 연재되고 있는데요, 그럼 어디에? 왜? 사용하는 것일까요?​다시 스펙을 보겠습니다.​개...

blog.naver.com

 

Business inquiries : lionkk@idt21c.com