# Help on calculating bounding vox

Help - guys sorry for my poor english currently i am working on a project to detect paper with trained model
InputTensor requires 640 x 640 image and my original image size is 390 X 640. from outputTensor i am gettng boxes to detect the paper but i am not able to draw correctly in canvas and dont know exact calculation to creating a boundingbox

Welcome to the Tensorflow Forum!

You need to scale the coordinates of the bounding box from the output tensor to the size of the original image.

Here are the steps to do that

1. Calculate the scaling factors for the height and width of the original image

`height_scale = original_image.shape / input_image.shape`
`width_scale = original_image.shape / input_image.shape`

2. Retrieve the coordinates of the bounding box from the outputTensor

`box_x, box_y, box_w, box_h = output_tensor`

3. Scale the coordinates of the bounding box to the size of the original image

`x = int(box_x * width_scale)`
`y = int(box_y * height_scale)`
`w = int(box_w * width_scale)`
`h = int(box_h * height_scale)`

4. Draw the bounding box on the original image

`cv2.rectangle(original_image, (x, y), (x + w, y + h), (0, 255, 0), 2)`

Thank you!