0

I'm using the claraifai API I've retrieved the regions for the face to form the bounding box but actually drawing the box gives me seriously off values as seen in the image.

code:

 return {
      topRow: face.top_row * height,
      leftCol: face.left_col * width,
      bottomRow: (face.bottom_row * height) - (face.top_row * height),
      rightCol: (face.right_col * width) - (face.left_col * width)
    }

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Pat
  • 9
  • 1

1 Answers1

0

Try to add a div relatively positioned inside the parent div.

Before:

const FaceImage = ({image, boxs}) => {
    return (
        <div className="faceimage">
            <img id="imgA" alt='' src={image}/>
            <div className="bounding-box" style={{
                top: boxs.top_row, 
                left: boxs.left_col,
                bottom: boxs.bottom_row,
                right: boxs.right_col 
            }}></div>
        </div>
    );
}

After:

const FaceImage = ({image, boxs}) => {
    return (
        <div className="faceimage">
            <div className="relative">
                <img id="imgA" alt='' src={image}/>
                <div className="bounding-box" style={{
                    top: boxs.top_row, 
                    left: boxs.left_col,
                    bottom: boxs.bottom_row,
                    right: boxs.right_col 
                }}></div>
            </div>
        </div>
    );
}

Css:

.relative {
    position: relative;
}
Pedro Henrique
  • 117
  • 2
  • 12