@@ -110,6 +110,9 @@ import { MultiFrameResultCrossFilter } from "@dynamsoft/dynamsoft-utility";
110110import " ./VideoCapture.css" ;
111111
112112function VideoCapture() {
113+ const uiContainer = useRef <HTMLDivElement >(null );
114+ const resultsContainer = useRef <HTMLDivElement >(null );
115+
113116 const pInit = useRef (
114117 null as Promise <{
115118 cameraView: CameraView ;
@@ -128,8 +131,8 @@ function VideoCapture() {
128131 // Create a `CameraEnhancer` instance for camera control and a `CameraView` instance for UI control.
129132 const cameraView = await CameraView .createInstance ();
130133 const cameraEnhancer = await CameraEnhancer .createInstance (cameraView );
131- elRef .current ! .innerText = " " ;
132- elRef .current ! .append (cameraView .getUIElement ()); // Get default UI and append it to DOM.
134+ uiContainer .current ! .innerText = " " ;
135+ uiContainer .current ! .append (cameraView .getUIElement ()); // Get default UI and append it to DOM.
133136
134137 // Create a `CaptureVisionRouter` instance and set `CameraEnhancer` instance as its image source.
135138 const router = await CaptureVisionRouter .createInstance ();
@@ -140,8 +143,12 @@ function VideoCapture() {
140143 resultReceiver .onDecodedBarcodesReceived = (
141144 result : DecodedBarcodesResult
142145 ) => {
146+ if (! result .barcodesResultItems .length ) return ;
147+
148+ resultsContainer .current ! .innerHTML = " " ;
149+ console .log (result );
143150 for (let item of result .barcodesResultItems ) {
144- console . log ( item .text ) ;
151+ resultsContainer . current ! . innerHTML += ` ${ item .formatString }: ${ item . text }<br><hr> ` ;
145152 }
146153 };
147154 router .addResultReceiver (resultReceiver );
@@ -193,7 +200,6 @@ function VideoCapture() {
193200 cameraView .dispose ();
194201 }
195202 };
196- const elRef = useRef <HTMLDivElement >(null );
197203
198204 useEffect (() => {
199205 (async () => {
@@ -214,7 +220,14 @@ function VideoCapture() {
214220 };
215221 }, []);
216222
217- return <div ref = { elRef } className = " div-ui-container" ></div >;
223+ return (
224+ <div >
225+ <div ref = { uiContainer } className = " div-ui-container" ></div >
226+ Results:
227+ <br />
228+ <div ref = { resultsContainer } className = " div-results-container" ></div >
229+ </div >
230+ );
218231}
219232
220233export default VideoCapture ;
@@ -231,6 +244,12 @@ export default VideoCapture;
231244 width : 100% ;
232245 height : 70vh ;
233246}
247+
248+ .div-results-container {
249+ width : 100% ;
250+ height : 10vh ;
251+ overflow : auto ;
252+ }
234253```
235254
236255### Create and edit the ` ImageCapture ` component
@@ -424,7 +443,6 @@ button {
424443
425444.container {
426445 margin : 2vmin auto ;
427- text-align : center ;
428446 font-size : medium ;
429447 width : 80vw ;
430448}
0 commit comments