Wolfram 언어

이미지 처리 및 신호 처리

회전 객체의 증강 현실

ImageDisplacements는 비디오 시퀀스의 광학 흐름 필드 공간 을 실시간으로 파악합니다. 회전 을 통해 임베디드 카메라 전방에서 회전 바늘의 움직임을 감지할 수 있습니다. 따라서 증강 현실의 예에서 가상 시계의 시간을 늘리거나 줄일 수 있습니다.

벡터 필드 의 회전 는 회전의 고유량을 결정합니다.

In[1]:=
Click for copyable input
listCurl = flow \[Function] ListConvolve[{{0.5`, 0, -0.5`}}, flow[[All, All, 2]], {{1, 2}, {1, 2}}, "Fixed"] - ListConvolve[{{-0.5`}, {0.`}, {0.5`}}, flow[[All, All, 1]], {{1, 2}, {1, 2}}, "Fixed"];
전체 Wolfram 언어 입력 표시하기
In[2]:=
Click for copyable input
(* Convert the incoming video frames to gray scale and swap left and \ right to mimic a mirror image. *) preProcessFrame = img \[Function] ImageReflect[ColorConvert[img, "Grayscale"], Left -> Right];

이 증강 현실의 예에 사용되는 전체 코드는 한페이지 미만입니다.

In[3]:=
Click for copyable input
DynamicModule[ {frames, flow, curl, mask, time = 0, W = 320, H = 240, w = 240, h = 160, r = 64}, (* specify a sensitive image region *) mask = ImageCompose[ ConstantImage[0, {W, H}], ImageAdjust[Image[GaussianMatrix[r/2]]], {w, h} ]; (* initialize the optical flow acquisition *) frames = Table[preProcessFrame@CurrentImage[], {2}]; flow = First@ImageDisplacements[frames]; Graphics[ {Inset[ (* read and display camera image, determine the curl *) Dynamic[ frames[[1]] = frames[[2]]; frames[[2]] = preProcessFrame@CurrentImage[]; flow = First@ImageDisplacements[frames, 0.7 flow]; curl = Image@listCurl@flow; time -= 2 ImageMeasurements[curl, "Mean", Masking -> mask]; frames[[2]] ], {0, 0}, {0, 0}, {W, H} ], Inset[ (* display clock *) Dynamic[ ClockGauge[ DatePlus[Date[], {Round[5 time, 5], "Minute"}], GaugeStyle -> RGBColor[1, 0.75, 0], LabelStyle -> White, GaugeFaceStyle -> Opacity[0.1] ], UpdateInterval -> 1 ], {w, h}, {0, 0}, {2 r, 2 r} ] }, PlotRange -> {{0, W}, {0, H}}, ImageSize -> {W, H} ] ]
동영상 작동
동영상 정지

관련 예제

de en es fr ja pt-br ru zh