summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-ocrd-fork-pylsd.spec253
-rw-r--r--sources1
3 files changed, 255 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..a615947 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/ocrd-fork-pylsd-0.0.4.tar.gz
diff --git a/python-ocrd-fork-pylsd.spec b/python-ocrd-fork-pylsd.spec
new file mode 100644
index 0000000..9f97746
--- /dev/null
+++ b/python-ocrd-fork-pylsd.spec
@@ -0,0 +1,253 @@
+%global _empty_manifest_terminate_build 0
+Name: python-ocrd-fork-pylsd
+Version: 0.0.4
+Release: 1
+Summary: pylsd is the python bindings for LSD - Line Segment Detector
+License: BSD
+URL: https://github.com/kba/pylsd
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/19/e4/f31ed73961a1c87d40b8e64505729367cc85bbcd45776d0d3561a2889cf2/ocrd-fork-pylsd-0.0.4.tar.gz
+BuildArch: noarch
+
+Requires: python3-numpy
+
+%description
+### 1. Introduction
+pylsd is the python bindings for [LSD - Line Segment Detector](http://www.ipol.im/pub/art/2012/gjmr-lsd/).
+### 2. Install
+This package uses distutils, which is the default way of installing python modules. To install in your home directory, securely run the following:
+```
+git clone https://github.com/primetang/pylsd.git
+cd pylsd
+[sudo] python setup.py install
+```
+Or directly through `pip` to install it:
+```
+[sudo] pip install pylsd
+```
+### 3. Usage
+We can use the package by using `from pylsd.lsd import lsd`, and `lines = lsd(src)` is the call format for the `lsd` function, where `src` is a Grayscale Image (`H * W` numpy.array), and the return value `lines` is the Detected Line Segment, `lines` is an `N * 5` numpy.array, each row represents a straight line, the 5-dimensional vector is:
+`[point1.x, point1.y, point2.x, point2.y, width]`
+According to these presentations, we can use it just like the following code ([here is the link](https://github.com/primetang/pylsd/tree/master/example)):
+* by using cv2 module
+```python
+import cv2
+import numpy as np
+import os
+from pylsd.lsd import lsd
+fullName = 'car.jpg'
+folder, imgName = os.path.split(fullName)
+src = cv2.imread(fullName, cv2.IMREAD_COLOR)
+gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
+lines = lsd(gray)
+for i in xrange(lines.shape[0]):
+ pt1 = (int(lines[i, 0]), int(lines[i, 1]))
+ pt2 = (int(lines[i, 2]), int(lines[i, 3]))
+ width = lines[i, 4]
+ cv2.line(src, pt1, pt2, (0, 0, 255), int(np.ceil(width / 2)))
+cv2.imwrite(os.path.join(folder, 'cv2_' + imgName.split('.')[0] + '.jpg'), src)
+```
+* by using PIL(Image) module
+```python
+from PIL import Image, ImageDraw
+import numpy as np
+import os
+from pylsd.lsd import lsd
+fullName = 'house.png'
+folder, imgName = os.path.split(fullName)
+img = Image.open(fullName)
+gray = np.asarray(img.convert('L'))
+lines = lsd(gray)
+draw = ImageDraw.Draw(img)
+for i in xrange(lines.shape[0]):
+ pt1 = (int(lines[i, 0]), int(lines[i, 1]))
+ pt2 = (int(lines[i, 2]), int(lines[i, 3]))
+ width = lines[i, 4]
+ draw.line((pt1, pt2), fill=(0, 0, 255), width=int(np.ceil(width / 2)))
+img.save(os.path.join(folder, 'PIL_' + imgName.split('.')[0] + '.jpg'))
+```
+The following is the result:
+* car.jpg by using cv2 module
+![](https://github.com/primetang/pylsd/blob/master/example/car.jpg)
+![](https://github.com/primetang/pylsd/blob/master/example/cv2_car.jpg)
+* house.png by using PIL(Image) module
+![](https://github.com/primetang/pylsd/blob/master/example/house.png)
+![](https://github.com/primetang/pylsd/blob/master/example/PIL_house.jpg)
+
+%package -n python3-ocrd-fork-pylsd
+Summary: pylsd is the python bindings for LSD - Line Segment Detector
+Provides: python-ocrd-fork-pylsd
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-ocrd-fork-pylsd
+### 1. Introduction
+pylsd is the python bindings for [LSD - Line Segment Detector](http://www.ipol.im/pub/art/2012/gjmr-lsd/).
+### 2. Install
+This package uses distutils, which is the default way of installing python modules. To install in your home directory, securely run the following:
+```
+git clone https://github.com/primetang/pylsd.git
+cd pylsd
+[sudo] python setup.py install
+```
+Or directly through `pip` to install it:
+```
+[sudo] pip install pylsd
+```
+### 3. Usage
+We can use the package by using `from pylsd.lsd import lsd`, and `lines = lsd(src)` is the call format for the `lsd` function, where `src` is a Grayscale Image (`H * W` numpy.array), and the return value `lines` is the Detected Line Segment, `lines` is an `N * 5` numpy.array, each row represents a straight line, the 5-dimensional vector is:
+`[point1.x, point1.y, point2.x, point2.y, width]`
+According to these presentations, we can use it just like the following code ([here is the link](https://github.com/primetang/pylsd/tree/master/example)):
+* by using cv2 module
+```python
+import cv2
+import numpy as np
+import os
+from pylsd.lsd import lsd
+fullName = 'car.jpg'
+folder, imgName = os.path.split(fullName)
+src = cv2.imread(fullName, cv2.IMREAD_COLOR)
+gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
+lines = lsd(gray)
+for i in xrange(lines.shape[0]):
+ pt1 = (int(lines[i, 0]), int(lines[i, 1]))
+ pt2 = (int(lines[i, 2]), int(lines[i, 3]))
+ width = lines[i, 4]
+ cv2.line(src, pt1, pt2, (0, 0, 255), int(np.ceil(width / 2)))
+cv2.imwrite(os.path.join(folder, 'cv2_' + imgName.split('.')[0] + '.jpg'), src)
+```
+* by using PIL(Image) module
+```python
+from PIL import Image, ImageDraw
+import numpy as np
+import os
+from pylsd.lsd import lsd
+fullName = 'house.png'
+folder, imgName = os.path.split(fullName)
+img = Image.open(fullName)
+gray = np.asarray(img.convert('L'))
+lines = lsd(gray)
+draw = ImageDraw.Draw(img)
+for i in xrange(lines.shape[0]):
+ pt1 = (int(lines[i, 0]), int(lines[i, 1]))
+ pt2 = (int(lines[i, 2]), int(lines[i, 3]))
+ width = lines[i, 4]
+ draw.line((pt1, pt2), fill=(0, 0, 255), width=int(np.ceil(width / 2)))
+img.save(os.path.join(folder, 'PIL_' + imgName.split('.')[0] + '.jpg'))
+```
+The following is the result:
+* car.jpg by using cv2 module
+![](https://github.com/primetang/pylsd/blob/master/example/car.jpg)
+![](https://github.com/primetang/pylsd/blob/master/example/cv2_car.jpg)
+* house.png by using PIL(Image) module
+![](https://github.com/primetang/pylsd/blob/master/example/house.png)
+![](https://github.com/primetang/pylsd/blob/master/example/PIL_house.jpg)
+
+%package help
+Summary: Development documents and examples for ocrd-fork-pylsd
+Provides: python3-ocrd-fork-pylsd-doc
+%description help
+### 1. Introduction
+pylsd is the python bindings for [LSD - Line Segment Detector](http://www.ipol.im/pub/art/2012/gjmr-lsd/).
+### 2. Install
+This package uses distutils, which is the default way of installing python modules. To install in your home directory, securely run the following:
+```
+git clone https://github.com/primetang/pylsd.git
+cd pylsd
+[sudo] python setup.py install
+```
+Or directly through `pip` to install it:
+```
+[sudo] pip install pylsd
+```
+### 3. Usage
+We can use the package by using `from pylsd.lsd import lsd`, and `lines = lsd(src)` is the call format for the `lsd` function, where `src` is a Grayscale Image (`H * W` numpy.array), and the return value `lines` is the Detected Line Segment, `lines` is an `N * 5` numpy.array, each row represents a straight line, the 5-dimensional vector is:
+`[point1.x, point1.y, point2.x, point2.y, width]`
+According to these presentations, we can use it just like the following code ([here is the link](https://github.com/primetang/pylsd/tree/master/example)):
+* by using cv2 module
+```python
+import cv2
+import numpy as np
+import os
+from pylsd.lsd import lsd
+fullName = 'car.jpg'
+folder, imgName = os.path.split(fullName)
+src = cv2.imread(fullName, cv2.IMREAD_COLOR)
+gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
+lines = lsd(gray)
+for i in xrange(lines.shape[0]):
+ pt1 = (int(lines[i, 0]), int(lines[i, 1]))
+ pt2 = (int(lines[i, 2]), int(lines[i, 3]))
+ width = lines[i, 4]
+ cv2.line(src, pt1, pt2, (0, 0, 255), int(np.ceil(width / 2)))
+cv2.imwrite(os.path.join(folder, 'cv2_' + imgName.split('.')[0] + '.jpg'), src)
+```
+* by using PIL(Image) module
+```python
+from PIL import Image, ImageDraw
+import numpy as np
+import os
+from pylsd.lsd import lsd
+fullName = 'house.png'
+folder, imgName = os.path.split(fullName)
+img = Image.open(fullName)
+gray = np.asarray(img.convert('L'))
+lines = lsd(gray)
+draw = ImageDraw.Draw(img)
+for i in xrange(lines.shape[0]):
+ pt1 = (int(lines[i, 0]), int(lines[i, 1]))
+ pt2 = (int(lines[i, 2]), int(lines[i, 3]))
+ width = lines[i, 4]
+ draw.line((pt1, pt2), fill=(0, 0, 255), width=int(np.ceil(width / 2)))
+img.save(os.path.join(folder, 'PIL_' + imgName.split('.')[0] + '.jpg'))
+```
+The following is the result:
+* car.jpg by using cv2 module
+![](https://github.com/primetang/pylsd/blob/master/example/car.jpg)
+![](https://github.com/primetang/pylsd/blob/master/example/cv2_car.jpg)
+* house.png by using PIL(Image) module
+![](https://github.com/primetang/pylsd/blob/master/example/house.png)
+![](https://github.com/primetang/pylsd/blob/master/example/PIL_house.jpg)
+
+%prep
+%autosetup -n ocrd-fork-pylsd-0.0.4
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-ocrd-fork-pylsd -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 17 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.4-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..c257934
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+bcc725331840de49fe5967f642e87287 ocrd-fork-pylsd-0.0.4.tar.gz