s39674 / image2schematic Goto Github PK
View Code? Open in Web Editor NEWTrying to extract pcb schematics from images using computer vision
Trying to extract pcb schematics from images using computer vision
Right now, in Dev - EasyOCR
branch, we send the chip detected text to skidl search()
to query KiCAD
chip pinout database (more info: https://devbisme.github.io/skidl/#finding-parts). But that database often doesn't support medium-to-large chips like micro processors. Does anyone know of a good database that does have support for those chips and python can interact with it? Thanks!
Currently, in branch: Dev_fetchViaHTTP_fix#15
we query www.octopart.com to get the chip's datasheet. In order to obtain the pin information, we need to analyze the pdf. Datasheets that have a dedicated pin table, like this:
https://datasheet.octopart.com/TC1427CPA-Microchip-datasheet-22875.pdf
Are quite easy to process using PyPDF2
:
response = requests.get(FirstBestDataSheetUrl)
reader2 = PdfReader(io.BytesIO(response.content))
if len(reader2.pages) > 0:
for page in reader2.pages:
if "PIN FUNCTION TABLE" in page.extract_text():
print(page.extract_text())
# print:
1 NC No connection.
2 IN A Control input A, TTL/CMOS compatible logic input.
3 GND Ground.
4 IN B Control input B, TTL/CMOS compatible logic input.
5 OUT B Output B, CMOS totem-pole output.
6V
DDSupply input, 4.5V to 16V.
7 OUT A Output A, CMOS totem-pole output.
8 NC No connection.
The problem is when we encounter PDFs that don't use a pin function table but instead use this form:
https://www.digchip.com/datasheets/download_datasheet.php?id=467924&part-number=MC74HC589A&type=pn2
Any ideas on how to deal with that?
Does anyone know a function that will take an image, an angle, and will return the image rotated by that angle?
Right now the points file is not looking too good:
Point: [435,479] connected to: (191,171)
Point: [435,466] connected to: (191,144)
Point: [435,453] connected to: (191,117)
Point: [435,439] connected to: (191,91)
Point: [435,426] connected to: (191,64)
Point: [436,412] connected to: (191,37)
ATtiny841-S | 6/PA7/BIDIRECTIONA | [190,171] connected to: (435,479)
ATtiny841-S | 5/PB2/BIDIRECTIONA | [190,144] connected to: (435,466)
ATtiny841-S | 4/~{RESET}/PB3/BIDIRECTIONA | [190,117] connected to: (435,453)
ATtiny841-S | 3/XTAL2/PB1/BIDIRECTIONA | [190,90] connected to: (435,439)
ATtiny841-S | 2/XTAL1/PB0/BIDIRECTIONA | [190,64] connected to: (435,426)
ATtiny841-S | 1/VCC/POWER-I | [190,37] connected to: (435,406)
I want to run it through some function that will format it nicely, something like this:
Point: [435,479] => connected to: (191,171)
Point: [435,466] => connected to: (191,144)
Point: [435,453] => connected to: (191,117)
Point: [435,439] => connected to: (191,91)
Point: [435,426] => connected to: (191,64)
Point: [436,412] => connected to: (191,37)
ATtiny841-S | 6/PA7/BIDIRECTIONA | [190,171] => connected to: (435,479)
ATtiny841-S | 5/PB2/BIDIRECTIONA | [190,144] => connected to: (435,466)
ATtiny841-S | 4/~{RESET}/PB3/BIDIRECTIONA | [190,117] => connected to: (435,453)
ATtiny841-S | 3/XTAL2/PB1/BIDIRECTIONA | [190,90] => connected to: (435,439)
ATtiny841-S | 2/XTAL1/PB0/BIDIRECTIONA | [190,64] => connected to: (435,426)
ATtiny841-S | 1/VCC/POWER-I | [190,37] => connected to: (435,406)
Any ideas?
I am getting the below error when I try to execute ConnectionFinding.py with default conditions:
Below are the logs:
PS E:\Work\Image2schematic> & C:/Python310/python.exe e:/Work/Image2schematic/ConnectionFinding.py
WARNING: KICAD_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched. @ [E:\Work\Image2schematic<frozen importlib._bootstrap_external>:883=>E:\Work\Image2schematic<frozen importlib._bootstrap>:241]
looping over contours
Approx: 4
Area: 10143.0
found ic at: 114,37 to: 178,199
Chip name: MCU_Microchip_ATtiny
Pins:
right line x of Ic: 178
WARNING: Could not load KiCad schematic library "MCU_Microchip_ATtiny", falling back to backup library. @ [e:\Work\Image2schematic\ConnectionFinding.py:198]
Traceback (most recent call last):
File "e:\Work\Image2schematic\ConnectionFinding.py", line 209, in
while f"/{i}/" not in CurrentICqueryResult[i]:
IndexError: list index out of range
PS E:\Work\Image2schematic> & C:/Python310/python.exe e:/Work/Image2schematic/ConnectionFinding.py
WARNING: KICAD_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched. @ [E:\Work\Image2schematic<frozen importlib._bootstrap_external>:883=>E:\Work\Image2schematic<frozen importlib._bootstrap>:241]
looping over contours
Approx: 4
Area: 10143.0
found ic at: 114,37 to: 178,199
Chip name: MCU_Microchip_ATtiny
Pins:
right line x of Ic: 178
WARNING: Could not load KiCad schematic library "MCU_Microchip_ATtiny", falling back to backup library. @ [e:\Work\Image2schematic\ConnectionFinding.py:198]
Traceback (most recent call last):
File "e:\Work\Image2schematic\ConnectionFinding.py", line 209, in
while f"/{i}/" not in CurrentICqueryResult[i]:
IndexError: list index out of range
The error seems to be related with skidl package .. Is there any installation steps which I missed?
Thanks !!
Hi S39674:
This is really a good project which I'm seeking for .
I'm working on the same , but it is hard to find a good solution .
Your idea is very good , I there any progress on this project .
I'm looking forward for your progress ,Thanks ..
If we don't manage to obtain a datasheet for some chip, as a last fall back we should count how many pins the chip have. Can someone write a function that will take an IC image as an input and will output the number of pins in it?
example:
output: 16
Note: I have tried using color range but it didn't work well.
Thanks!
The final schematic should include resistors, capacitors, inductors etc.. So we need a way to detect those component.
There is a nice dataset of PCB components here: https://sites.google.com/view/chiawen-kuo/home/pcb-component-detection but I don't know how to start training a model, can anyone help? Thanks!
I want to switch to using class so i will have better control over the link between IC and the points that are connected to it. Using classes also gives me the ability to save the IC/points info in a quicker and easier to work with format.
I started a new branch for this new and important step of this project, add added point.py
and chip.py
which include the minimum baseline.
Any suggestions?
In PcbFunctions.py
:
Image2schematic/PcbFunctions.py
Lines 63 to 76 in 059efd8
[x,y]
; Could someone write a simple regex to replace that?Does anyone know a function that will take an image, two x and y coordinates and will return a croped image based on those coordinates?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.