Coder Social home page Coder Social logo

Comments (2)

MansourTrabelsi avatar MansourTrabelsi commented on August 27, 2024

help me please , i have this error
Traceback (most recent call last):
File "gen.py", line 19, in
from synthgen import *
File "/home/mansour/SynthText/synthgen.py", line 20, in
import text_utils as tu
File "/home/mansour/SynthText/text_utils.py", line 12, in
from pygame import freetype
ImportError: cannot import name freetype

from synthtext.

shubham303 avatar shubham303 commented on August 27, 2024

I solved bounding box twist problem by using below function

def order_points(pts):
	# sort the points based on their x-coordinates
	xSorted = pts[np.argsort(pts[:, 0]), :]
	# grab the left-most and right-most points from the sorted
	# x-roodinate points
	leftMost = xSorted[:2, :]
	rightMost = xSorted[2:, :]
	# now, sort the left-most coordinates according to their
	# y-coordinates so we can grab the top-left and bottom-left
	# points, respectively
	leftMost = leftMost[np.argsort(leftMost[:, 1]), :]
	(tl, bl) = leftMost
	
	rightMost = rightMost[np.argsort(rightMost[:, 1]), :]
	tr, br = rightMost
	
	x1, y1 = bl
	x2, y2 = br
	w1 =  math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	
	x1, y1 = tl
	x2, y2 = tr
	w2 =  math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	#width of box
	w = max(w1, w2)
	
	x1, y1 = tl
	x2, y2 = bl
	h1 = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	
	x1, y1 = tr
	x2, y2 = br
	h2 = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	h=max(h1, h2)  # height of box
	
	return np.array([tl, tr, br, bl], dtype="float32"), int(w) , int(h)

This function, given a bounding box returns, coordinates in clockwise order starting from top left, also it returns width and height of bounding box

from synthtext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.