@@ -4,22 +4,22 @@ import { CORNER_KEYS, MARKER_DIAMETER, MARKER_RADIUS } from "../../utils/constan
44import { Corners } from "." ;
55import { useWindowWidth , useWindowHeight } from '@react-hook/window-size' ;
66import { useDispatch } from 'react-redux' ;
7- import { cornersSelect , cornersSet } from "../../slices/cornersSlice" ;
7+ import { cornersSet } from "../../slices/cornersSlice" ;
88import { getMarkerXY , getXY } from "../../utils/detect" ;
99import { Chessboard } from 'kokopu-react' ;
10- import { CornersDict , CornersPayload , Game , setBoolean , setStringArray } from "../../types" ;
10+ import { CornersPayload , Game , setBoolean , setStringArray } from "../../types" ;
1111import { gameSelect } from "../../slices/gameSlice" ;
1212
13- const Video = ( { modelRef, canvasRef, videoRef, sidebarRef, playing, setPlaying, playingRef, setText, digital, webcam } : {
13+ const Video = ( { modelRef, canvasRef, videoRef, sidebarRef, playing,
14+ setPlaying, playingRef, setText, digital, webcam, cornersRef } : {
1415 modelRef : any , canvasRef : any , videoRef : any , sidebarRef : any ,
1516 playing : boolean , setPlaying : setBoolean , playingRef : any ,
16- setText : setStringArray , digital : boolean , webcam : boolean
17+ setText : setStringArray , digital : boolean , webcam : boolean ,
18+ cornersRef : any
1719} ) => {
18- const corners : CornersDict = cornersSelect ( ) ;
1920 const game : Game = gameSelect ( ) ;
2021
2122 const displayRef : any = useRef ( null ) ;
22- const cornersRef : any = useRef ( null ) ;
2323 const gameRef = useRef < Game > ( game ) ;
2424
2525 const aspectRatio = 16 / 9 ;
@@ -78,7 +78,7 @@ const Video = ({ modelRef, canvasRef, videoRef, sidebarRef, playing, setPlaying,
7878 canvasRef . current . height = videoRef . current . offsetHeight ;
7979
8080 CORNER_KEYS . forEach ( ( key ) => {
81- const xy = getXY ( corners [ key ] , oldHeight , oldWidth ) ;
81+ const xy = getXY ( cornersRef . current [ key ] , oldHeight , oldWidth ) ;
8282 const payload : CornersPayload = {
8383 "xy" : getMarkerXY ( xy , canvasRef . current . height , canvasRef . current . width ) ,
8484 "key" : key
@@ -113,10 +113,6 @@ const Video = ({ modelRef, canvasRef, videoRef, sidebarRef, playing, setPlaying,
113113 updateWidthHeight ( ) ;
114114 } , [ windowWidth , windowHeight ] ) ;
115115
116- useEffect ( ( ) => {
117- cornersRef . current = corners
118- } , [ corners ] )
119-
120116 useEffect ( ( ) => {
121117 if ( ( webcam ) || ( videoRef . current . src === "" ) ) {
122118 return ;
0 commit comments