Четверг, 28.03.2024, 14:57
Приветствую Вас Гость | RSS
Меню сайта

Категории раздела
трёхмерные сканеры [17]
Программирование [2]
Панорамы [0]
панорамы

Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0

Форма входа

Главная » Статьи » Программирование

Исходный код для DIY 3D Laser Scanner

Принцип трёхмерного сканера:


Исходный код на Visual Basic 6.0:

Private WindowWidth

Private WindowHeight
Private threshold
Private rgbvalue

Private Sub Form_Load()
'
' DIY 3D Laser Scanner 2009, By Colin Ord. 17th September 2009.
' Working for REAL Object scans!!!!!!!
' Just hold laser and sweep across object until done
'
' Notes:
' 24-09-2009 Corrected x skew
' 27-09-2009 Corrected Z depth for 30 degree scan
' 28-09-2009 Correct aspect for 30 degree scans. Rotated laser not a linear movement.
' 8th October: added colour capture with reference image rgb.jpg

WindowWidth = 320
WindowHeight = 240
myy = 1

End Sub

Private Sub Timer1_Timer()

Dim R As Long
Dim G As Long
Dim B As Long

Dim myx
Dim myy
Dim rgbvalue

threshold = Slider1.Value '1600000 '3876853 'Reverse BGR hex value for a red colour
Text1.Text = threshold
threshold = 1585276

myy = 1

mynumber = 1
mytextnumber$ = mynumber

Form1.Picture3 = LoadPicture("C:\3d scanner\rgb.jpg")

mytextnumber$ = "C:\3d scanner\" & "1.jpg"

On Error GoTo ErrorHandler

ErrorHandler:
If Err.Number = 53 Or 481 Then
'Debug.Print "Some problem with loading jpg image."
Resume Next
End If

Picture1 = LoadPicture(mytextnumber$)

For xcnt = 0 To WindowWidth
If Picture1.Point(xcnt, 30) > threshold Then '100000 Then
origin = xcnt

GoTo start:
End If
Next

start:

For myy = 0 To WindowHeight

For myx = 0 To WindowWidth
If Picture1.Point(myx, myy) > threshold Then '1000000 Then
GoTo here:
End If
Next

here:

Picture1.PSet (myx, myy), RGB(255, 255, 0)
Picture1.Line (0, 30)-(WindowWidth, 30), RGB(0, 255, 0)

If Form1.Picture3.Point(myx, myy) > 100000 Then
rgbvalue = Form1.Picture3.Point(myx, myy)
End If

rotx = origin - myx
roty = myy * 2
rotz = (rotx + myx) / 2

'Output file
  Open "C:\3d scanner\3dmodel_01.asc" For Append As #1

'Read RGB values from hex pixel colour
R = &HFF& And rgbvalue
G = (&HFF00& And rgbvalue) \ 256
B = (&HFF0000 And rgbvalue) \ 65536

' Aligns scan with laser angle offset and skew
rot = 30 * 0.0174532 '57.29577951
rotzz = rotz * Cos(rot) - myx * Sin(rot)
rotxx = rotz * Sin(rot) + myx * Cos(rot)
rotyy = roty 'myy '/ 2

'create the vertex string - 'X Y Z R G B'
Print #1, ((rotxx + rotx) & " " & (rotyy / 2) & " " & ((rotzz * -2) * 2) & " " & R & " " & G & " " & B)
Close #1

'LASER LINE PREVIEW BOX- Draws each vertex with a red dot.
Picture2.PSet (myx, myy), RGB(255, 0, 0)
Next

End Sub

Адрес первоисточника: http://sites.google.com/site/colinord/Home/diy-3d-scanner/2009

Категория: Программирование | Добавил: fiend (25.05.2011)
Просмотров: 1026 | Комментарии: 1 | Рейтинг: 0.0/0
Всего комментариев: 0
Имя *:
Email *:
Код *:
Поиск

Ссылки
  • Russian3DScanner
  • David-laserscanner
  • Agisoft
  • Flexscan 3d
  • Photomodeler
  • Song Zhang
  • Intricad

  • Copyright MyCorp © 2024Бесплатный хостинг uCoz