Canon Edsdk 2.5.2 VB.net과 라이브 뷰
문제
나는 두 가지 중 하나를 시도하고 있습니다. 선호도 번호 1 :
VB.NET 및 Canon EDSDK 2.5.2를 사용하여 라이브 뷰를 켜고 Windows 양식 응용 프로그램에서 라이브 출력을 렌더링하십시오. 현재 사진 상자에 넣으려고합니다. 그러나 나는 확실히 제안에 개방적입니다.
두 번째 옵션은 적어도 라이브 뷰를 켜고 카메라의 비디오 출력을 통해 모니터로 스트리밍하는 것입니다.
나는 정말로 첫 번째를 성취하고 싶다! 아래는 내 현재 코드베이스입니다. 도움말!
Private Sub btnStartLiveView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartLiveView.Click
Dim err As Integer = EDS_ERR_OK
Dim prop As Integer = EdsEvfOutputDevice.kEdsEvfOutputDevice_PC
Dim proptype As Integer = EDSDKTypes.kEdsPropID_Evf_OutputDevice
'// Stock the property.'
Dim wkIntPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(prop))
Marshal.StructureToPtr(prop, wkIntPtr, False)
'send property/command to the camera'
EdsSetPropertyData(model.getCameraObject(), proptype, 0, Marshal.SizeOf(prop), prop)
Dim stream As IntPtr
Dim outMemoryRef As IntPtr
Dim evfImage As IntPtr
err = EdsCreateMemoryStream(0, stream)
If err = EDS_ERR_OK Then
err = EdsCreateImageRef(stream, outMemoryRef) '(stream, evfImage)'
Else
Dim str As String = Hex(err)
MessageBox.Show(str)
End If
If err = EDS_ERR_OK Then
err = EdsDownloadEvfImage(model.getCameraObject(), evfImage)
Else
Dim str As String = Hex(err)
MessageBox.Show("&H" & str & "L") ' Shows &H2CL which = ERR_FILE_FORMAT_NOT_RECOGNIZED'
End If
' Get the Incidental Data of the Image'
If err = EDS_ERR_OK Then
Dim zoom As UInt32
Dim point As IntPtr
EdsGetPropertyData(outMemoryRef, kEdsPropID_Evf_ZoomPosition, 0, Marshal.SizeOf(zoom), zoom)
EdsGetPropertyData(outMemoryRef, kEdsPropID_Evf_ZoomPosition, 0, Marshal.SizeOf(point), point)
Else
'MessageBox.Show(err.ToString())'
End If
Dim buffer(Marshal.SizeOf(stream)) As Byte
Dim mStream As System.IO.Stream = New System.IO.MemoryStream(Marshal.SizeOf(stream))
Dim gcTime As GCHandle = GCHandle.Alloc(0, GCHandleType.Pinned)
Dim pTime As IntPtr = gcTime.AddrOfPinnedObject()
Marshal.Copy(stream, buffer, 0, Marshal.SizeOf(stream))
mStream.Write(buffer, 0, Marshal.SizeOf(stream))
Me.PictureBox1.Image = Image.FromStream(mStream)
EdsRelease(stream)
End Sub
올바른 솔루션이 없습니다
다른 팁
나는 원래이 질문을 게시 한 사람이었습니다. 나는 여전히 답을 찾고있는 다른 사람들이 있다는 것을 알았습니다. 나는 우리가 마침내 내 블로그에 올린 솔루션을 게시했습니다. http://www.overridepro.com/2009/06/28/canon-sdk-live-view/ .
다음은 클래스 카메라를 정의하는 .VB 파일입니다.
Dim camera as New Camera
camera.EstablishSession()
camera.TakePicture("C:\path\to\save.jpg")
camera.StartLiveView(me.LiveViewPictureBox)
camera.StopLiveView()
camera.FlushTransferQueue()
유용하다고 생각합니다.
<snip>
수년에 걸쳐이 코드 블록에 대한 업데이트를 위해 여러 이메일을 받았는데,이 코드는 오픈 소스로 Github에 있습니다.
http://github.com/superjoe30/camlift-controller
카메라 클래스는 SLNCAMLIFTCONTROLLER / SRC / CAMER.VB에 있습니다.
이 코드 중 일부는 당황스럽게 끔찍합니다. 예를 들어, 5D 및 7D 카메라에서 작동하도록하려면 SDK를 초기화 한 다음 의도적으로 충돌하는 프로그램을 만들어야합니다. 끔찍한! 알아요! 이것은 Klugesaurus에서 발견됩니다. 5D 또는 7D에 연결하려고 할 때는 작동하지 않습니다. 스파이크 구덩이가 있습니다. 그래서 우리는 농민 (Klugesaurus)을 스파이크에 밀어 넣어 그를 죽이고 (조용히 실패) 농민의 시체를 가로 질러 안전을 위해 걸을 수 있습니다.
추악하고 끔찍하지만마다 매번 작동합니다. 하지 않으면 작동하지 않습니다. 나는 Canon에게 EOS 유틸리티의 소스 코드를 릴리스 할 것인지 여러 번 물었습니다. 이는 5D 및 7D에 완벽하게 연결됩니다. 그들은 매번 견고하게 거부했습니다. 내 동료는 그들이 Klugesaurus를 사용하고 있다고 밝히고 싶지 않다고 농담합니다. 어쨌든, 나는 단지 당신에게 그 불쾌한 세부 사항까지 머리를주고 싶었습니다.
또한 카메라와 인터페이스하기 위해 파이썬 모듈을 만들었습니다.http://github.com/superjoe30/pyedsdk
코드 샘플이 있습니다 여기 그리고 그것을 진정시키는 다양한 방법에 대한 토론.