Gasman2014 / KiCad-Diff

Scripts for performing image diffs between pcbnew layout revisions
MIT License
248 stars 42 forks source link

Running it on Linux #2

Closed leoheck closed 4 years ago

leoheck commented 6 years ago

Hi, I am trying to run/port your project on Linux. I couldn't find from where the pkg tkUI came from. Do you have any reference to help me install it?

Gasman2014 commented 6 years ago

oops - looks like I forgot to upload tkui.py to the repo. Will fix when I get a minute.

BW

John

On 4 Oct 2018, at 02:21, Leandro Heck notifications@github.com wrote:

Hi, I am trying to run/port your project on Linux. I couldn't find from where the pkg tkUI came from. Do you have any reference to help me install it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuRv7oPsNVGR-aNjhNtFIuqLv1Hocks5uhWKJgaJpZM4XHNRo.

Gasman2014 commented 6 years ago

Now uploaded the missing file. Hope it works now.

leoheck commented 6 years ago

Interesting @Gasman2014, thank you. Another thing that may be missing is this /Users/johnpateman/Kicad/PcbDraw/pcbdraw.py Can you add it too?

Gasman2014 commented 6 years ago

I thought I had removed that dependancy - I was working on this but it is still a bit of w.i.p.

It was cribbed from this project;

https://github.com/yaqwsx/PcbDraw https://github.com/yaqwsx/PcbDraw

(I was using it without the component image library)

https://github.com/yaqwsx/PcbDraw/blob/master/promo_pcbdraw.png

On 4 Oct 2018, at 14:46, Leandro Heck notifications@github.com wrote:

Interesting @Gasman2014 https://github.com/Gasman2014, thank you. Another thing that may be missing is this /Users/johnpateman/Kicad/PcbDraw/pcbdraw.py Can you add it too?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427024875, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuWUoSK8ghVncHbs8h5yZNJT9QWWSks5uhhE1gaJpZM4XHNRo.

leoheck commented 6 years ago

Cool, the dependencies are not the issue anymore.

I am almost there. The main window is appearing, the git commits are there, the page is being created but it is empty.

image

leoheck commented 6 years ago

I am using it with Kicad 5.0 (nightly builds). Do you think it may be the issue?

leoheck commented 6 years ago

The output is this:

➜ python3 /home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py 
Git
gitCmd: cd /home/lheck/Dropbox/deepx/HOMEBASE/homebase-hardware/ && /usr/bin/git log --pretty=format:"%h     %s"
Resolution (dpi) :  300
Commit1 ffd8bf2      Update the library.
Commit2 9c8e71a      Add a MPN found on mouser for the J6 (BT5_JTAG)
diff1:  ffd8bf2      Update the library.
diff2:  9c8e71a      Add a MPN found on mouser for the J6 (BT5_JTAG)
prjctName:  homebase.kicad_pcb
prjctPath:  /home/lheck/Dropbox/deepx/HOMEBASE/homebase-hardware/
2018-10-04 09:56:55
2018-09-27 16:02:48
Generating .svg files
Converting .svg files in  /tmp/svg/ffd8bf/   to .png
Inverting .png files in  /tmp/svg/ffd8bf/ 
Converting .svg files in  /tmp/svg/9c8e71/   to .png
Inverting .png files in  /tmp/svg/9c8e71/ 
Generating *.png diff files
{'title ': [], 'rev': '0.1', 'company': [], 'date': '2018-08-09', 'page': 'A4', 'thickness': '1.6', 'drawings': '5', 'tracks': '(tracks', 'zones': '0', 'modules': '193', 'nets': '179'}
{'title ': [], 'rev': '0.1', 'company': [], 'date': '2018-08-09', 'page': 'A4', 'thickness': '1.6', 'drawings': '0', 'tracks': '(tracks', 'zones': '0', 'modules': '188', 'nets': '178'}
Gasman2014 commented 6 years ago

I haven’t really packaged this very well - sorry. I had forgotten that I have another script installed - a plotting script that I put in /usr/local/bin/plotPCB2.py and had been there for such a long time that i had forgotten it was a dependency. I have now added that to the repo too. You can put this anywhere you want - just adjust the path at line 480/481 to whatever you prefer.

Nevertheless, even with this in place I have just had another go at testing and am hitting a similar problem as you have generating the initial SVG plots.

This may be a Kicad5 problem as I am having some general Python problems with Kicad at the moment - the python scripting interface seems to have changed a few times recently. I kinda wished I had stayed with one of the later dev versions as then python scripting and action menus were working - but they are now broken. Hopefully 5.0.1 will be out soon and some of the scripting will be re-enabled.

BW

John

On 4 Oct 2018, at 16:50, Leandro Heck notifications@github.com wrote:

I am using it with Kicad 5.0 (nightly builds). Do you think it may be the issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427070583, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuV1PYU9OKJDJS6ZvHJyxLdQZIWasks5uhi4ygaJpZM4XHNRo.

leoheck commented 6 years ago

No problem John, we are improving it here. :)

So, our current problem is in the SVG generation, right?

Can you point to me where in your code you believe the issue came from? I can try to look if I can improve it or also I can ask help for Kicad devs. They are really nice.

I am seeing your repo appearing everywhere when searching for Kicad 3rdParty tools and I am really interested in making this work again.

leoheck commented 6 years ago

I found this. Is that you? :)

image

Gasman2014 commented 6 years ago

The selected diffs are processed using makeSVG (line 452). This function in turn calls `plotPCB2.py’ (line 480) - which I have now uploaded to the repo!

I wrote the main program in Python3 - I thought that was a sensible choice but it causes problems with integrating with the Python 2.7 needed for Kicad - so I accessed it as a separate process.

This was working previously in 4.0.7 but now I am getting a thread error - it may simply be my current setup - but because of this I am going to have problems getting this debugged.

If you can get plotPCB2.py to run on its own (it takes two arguments - the kicad_pcb file and the destination directory

e.g. 'plotPCB2.py boardName.Kicad_pcb /home/username/outputdir'

If this runs, the rest of the Diff program should run OK.

You will need to do something with the first few lines of the plot file - certainly the shebang needs adjusting and you may not need to do the import sys sys.path.insert stuff that I have had to mess with to get it running on macOS.

You need 'image magick' installed too ;)

BW

John

On 4 Oct 2018, at 21:53, Leandro Heck notifications@github.com wrote:

No problem John, we are improving it here. :)

So, our current problem is in the SVG generation, right?

Can you point to me where in your code you believe the issue came from? I can try to look if I can improve it or also I can ask help for Kicad devs. They are really nice.

I am seeing your repo appearing everywhere when searching for Kicad 3rdParty tools and I am really interested in making this work again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427165552, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuc2I2AY1hHFuF2fhGxjzZsAsImoMks5uhnVCgaJpZM4XHNRo.

Gasman2014 commented 6 years ago

Yep, thats me. I can’t recall how I fixed that particular issue but I did get it running!

John

On 4 Oct 2018, at 22:09, Leandro Heck notifications@github.com wrote:

I found this. Is that you? :)

https://user-images.githubusercontent.com/1277920/46503203-89aa6180-c800-11e8-8a8b-92f8aacd1143.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427170030, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuZ7yj5YJMhNzN7vjHuaGtk4dOjB_ks5uhnj1gaJpZM4XHNRo.

leoheck commented 6 years ago

Cool, I was already doing tests running this plotPCB2.py alone. I couldnt make it work yet, and the commnad line doesn't give any info about the issue. I will continue my tests here. I will let you know if I make some progress.

Gasman2014 commented 6 years ago

I will say right from the start - I have absolutely no professional experience in writing Python code (or any code, for that matter). I am a medical doctor so please forgive my awful coding style!

BW

John

On 4 Oct 2018, at 22:34, Leandro Heck notifications@github.com wrote:

Cool, I was already doing tests running this plotPCB2.py alone. I couldnt make it work yet, and the commnad line doesn't give any info about the issue. I will continue my tests here. I will let you know if I make some progress.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427177249, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuahJCF-bFHTlVIb-HwuLr2tAb8rVks5uhn7TgaJpZM4XHNRo.

leoheck commented 6 years ago

Hey, I don't care about the code style! I care about things that work.

Apparently, it is almost working. I have many .png files there. I am trying to fix a new issue now.

Traceback (most recent call last):
  File "/home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py", line 1147, in <module>
    makeOutput(svgDir1, svgDir2, prjctName, prjctPath, times)
  File "/home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py", line 989, in makeOutput
    prj, layer = prjct.split('-')
ValueError: too many values to unpack (expected 2)
leoheck commented 6 years ago

I have colors haha

image

Gasman2014 commented 6 years ago

Whats your project called? Has it got a '_ 'in it?

prj, layer = prjct.split('-‘) is trying to unpack the project layer into a project name and a layer name (TestBCu) >> Test & BCu but is getting more than two variables on splitting on a “”. What are the names of the files in the diff plots directory?

I will have another look in the am!

JP

On 4 Oct 2018, at 23:10, Leandro Heck notifications@github.com wrote:

Hey, I don't care about the code style! I care about things that work.

Apparently, it is almost working. I have many .png files there. I am trying to fix a new issue now.

Traceback (most recent call last): File "/home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py", line 1147, in makeOutput(svgDir1, svgDir2, prjctName, prjctPath, times) File "/home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py", line 989, in makeOutput prj, layer = prjct.split('-') ValueError: too many values to unpack (expected 2) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427186113, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuepE_1W5Fdd8vjpfdzwSLWQhUoDMks5uhodngaJpZM4XHNRo.

leoheck commented 6 years ago

I have some projects that I can test it. The one I was using is homebase.kicad_mod I tried a fast workaround doing this: prj, layer, *rest = prjct.split('-')

I have to verify some things, for example the full path has some - on it: /home/lheck/Dropbox/home/HOMEBASE/project-homebase-hardware/

leoheck commented 6 years ago

Running it on another computer, I am facing this:

FILENAME: homebase-.__plots_e6f2ba_homebase.kicad_pcbB_Mask.svg
Traceback (most recent call last):
  File "/home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py", line 1137, in <module>
    makePNG(svgDir1, svgDir2, dpi, prjctName, prjctPath)
  File "/home/lheck/Dropbox/kicad-plugins/KiCad-Diff/kidiff_gui.py", line 552, in makePNG
    basename, ext = filename.split('.')
ValueError: too many values to unpack (expected 2)

My tmp files are being generated like this:

/tmp/svg/e88287:
homebase-.__plots_e88287_homebase.kicad_pcbB_Adhes.svg
homebase-.__plots_e88287_homebase.kicad_pcbB_CrtYd.svg
homebase-.__plots_e88287_homebase.kicad_pcbB_Cu.svg
homebase-.__plots_e88287_homebase.kicad_pcbB_Fab.svg
homebase-.__plots_e88287_homebase.kicad_pcbB_Mask.svg
homebase-.__plots_e88287_homebase.kicad_pcbB_Paste.svg
homebase-.__plots_e88287_homebase.kicad_pcbB_SilkS.svg
homebase-.__plots_e88287_homebase.kicad_pcbCmts_User.svg
homebase-.__plots_e88287_homebase.kicad_pcbDwgs_User.svg
homebase-.__plots_e88287_homebase.kicad_pcbEco1_User.svg
homebase-.__plots_e88287_homebase.kicad_pcbEco2_User.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_Adhes.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_CrtYd.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_Cu.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_Fab.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_Mask.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_Paste.svg
homebase-.__plots_e88287_homebase.kicad_pcbF_SilkS.svg
homebase-.__plots_e88287_homebase.kicad_pcbIn1_Cu.svg
homebase-.__plots_e88287_homebase.kicad_pcbIn2_Cu.svg
homebase-.__plots_e88287_homebase.kicad_pcbMargin.svg
leoheck commented 6 years ago

I fixed this, it was a mistake on my plotPCB2.py.

Now, I have some:

convert-im6.q16: unable to open image `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no images defined `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png' @ error/convert.c/ConvertImageCommand/3258.
convert-im6.q16: unable to open image `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: unable to open image `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no images defined `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png' @ error/convert.c/ConvertImageCommand/3258.
convert-im6.q16: unable to open image `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no images defined `/home/lheck/Dropbox/home/HOMEBASE/homebase/plots/22c375/homebase-B_Adhes.png' @ error/convert.c/ConvertImageCommand/3258.
leoheck commented 6 years ago

Interesting, I have some initial results!

image

leoheck commented 6 years ago

Some images are appearing, too.

image

leoheck commented 6 years ago

I also managed to apply your style.css I need to find where I am loosing the colors. Your screenshots are really good.

image

Gasman2014 commented 6 years ago

Did your board outline change between revisions - this is a problem as the whole frame of reference changes.

JP

On 4 Oct 2018, at 23:21, Leandro Heck notifications@github.com wrote:

I have colors haha

https://user-images.githubusercontent.com/1277920/46506456-b2375900-c80a-11e8-9272-8aa570a5122d.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427188541, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuZlmBJ1VF1CYegepHAshqN5GSV6iks5uhontgaJpZM4XHNRo.

leoheck commented 6 years ago

Yes, it did.

I am facing other issues right now. They are:

Gasman2014 commented 6 years ago

Look like you are making good progress. In your ‘plots’ directory you should have at least four subdirectories; one for each version - named after each hash, one ‘diff-hash1-hash2’ directory and one web directory.

The hash directories should contain a series of .png files in the form BoardName-LayerName.png e.g. MyBoard-F_Cu.png. These should all be coloured according to the table at the start of the main script. F_Cu should be a good one to check. There should also be an ‘info.txt’ file containing some info about the version. Are these files coloured correctly?

The diff-hash1-hash2 directory should contain the actual diff images named in the same format as above. there is also an info.txt file which is a text diff of the two versions. Again, these should be coloured.

The web directory contains two directories - thumbs and triptych. The thumb file contains small (300 x 250 px - approx) images of the diff files - same naming convention prepended with th_ . These are generated from the original files in the diff-hash-hash directory, so if they are coloured then these should be coloured too.

The triptych directory contains the html source for the three way layout. That should have local links to the previous files.

It looked like there might have been some problem with path substitution. In the /tmp/svg/e88287 directory, you said there was this file. homebase-.__plots_e88287_homebase.kicad_pcbMargin.svg What you should have is the following structure; tmp/svg/e88287/homebase_pcbmargin.svg

One of the problems that I have come across is the way that Kicad plots move if you remove or add something to the top or left edge of the plot

I have also considered doing something like the attached - pop all these in a directory and try moving the magenta slider ...

Also GitHub has some image diff tools builtin.

https://help.github.com/articles/rendering-and-diffing-images/ https://help.github.com/articles/rendering-and-diffing-images/

I am not sure if the code for that come from this project;

https://blog.github.com/2011-03-21-behold-image-view-modes/

https://github.com/cameronmcefee/Image-Diff-View-Modes/commit/8e95f70c9c47168305970e91021072673d7cdad8

BW

John

On 5 Oct 2018, at 04:21, Leandro Heck notifications@github.com wrote:

I also managed to apply your style.css I need to find where I am loosing the colors. Your screenshots are really good.

https://user-images.githubusercontent.com/1277920/46514468-787b4800-c834-11e8-9cc6-a828a1cf4af8.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427234720, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuTV3sudoexp4xZOSezPTUIMOjZ2_ks5uhtA4gaJpZM4XHNRo.

Gasman2014 commented 6 years ago

I noticed that the Diff1 track count said ‘(tracks’ rather than reporting the actual track count.

And the error is combining up here in the debugging output; Generating *.png diff files {'title ': [], 'rev': '0.1', 'company': [], 'date': '2018-08-09', 'page': 'A4', 'thickness': '1.6', 'drawings': '5', 'tracks': '(tracks', 'zones': '0', 'modules': '193', 'nets': '179'} {'title ': [], 'rev': '0.1', 'company': [], 'date': '2018-08-09', 'page': 'A4', 'thickness': '1.6', 'drawings': '0', 'tracks': '(tracks', 'zones': '0', 'modules': '188', 'nets': '178'} I can see that the title and company are not being populated. I will have another look at the board format to see if anything has changed in the layout. Otherwise I am not sure why this is happening - the rest of the parameters seem to have been returned correctly (I presume). Are there really 5 drawings in one diff and zero in the other though? My test cases have been smaller boards than these without so many components but there is no reason to believe that it shouldn’t work as expected.

JP

On 5 Oct 2018, at 15:33, Leandro Heck notifications@github.com wrote:

Yes, it did.

I am facing other issues right now. They are:

Some images have a number as the caption instead of the layer name Title and Company name are not being displayed The number of tracks is not being parsed properly. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427386751, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuX0WvnDcMTakzccdkai-bWIzx-oLks5uh23EgaJpZM4XHNRo.

leoheck commented 6 years ago

Good info here, you just shared.

So, I have all the 3 folders, their content looks good now and they are all colored as you said.

image

The diff- folder also looks good now and they are also coloured.

image

It looks better now, but I still there are some images with numbers instead of the layer names.

image

Actually, sometimes this thing is populated.

{'title ': [], 'rev': '0.1', 'company': [], 'date': '2018-08-09', 'page': 'A4', 'thickness': '1.6', 'drawings': '0', 'tracks': '(tracks', 'zones': '0', 'modules': '188', 'nets': '178'}
leoheck commented 6 years ago

image

leoheck commented 6 years ago

This is my debug to show the convert commands. Sometimes I have some issues here, like: The one starting by convert-im6.q16: images are.

Processing: homebase-F_Fab.png
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png -flatten -grayscale Rec709Luminance /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png -flatten -grayscale Rec709Luminance /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png "(" -clone 0-1 -compose darken -composite ")" -channel RGB -combine /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png
convert-im6.q16: images are not the same size `/home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png' @ error/channel.c/CombineImages/128.
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png -fill "#C2C200" -fuzz 75% -opaque "#ffffff" /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png
convert-im6.q16: unable to open image `/home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png': No such file or directory @ error/blob.c/OpenBlob/2701.
convert-im6.q16: no images defined `/home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png' @ error/convert.c/ConvertImageCommand/3258.
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png -define png:color-type=2 /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png -fill "#C2C200" -fuzz 75% -opaque "#ffffff" /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png -define png:color-type=2 /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png
convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png -fill "#C2C200" -fuzz 75% -opaque "#ffffff" /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png
leoheck commented 6 years ago

I can try to resize, crop or both if it is a problem.

leoheck commented 6 years ago

I managed to improve the getBoardData with:

def getBoardData(board):
    '''Takes a board reference and returns the
    basic parameters from it.
    Might be safer to split off the top section
    before the modules to avoid the possibility of
    recyling keywords like 'title' '''

    prms = {
        'title': "",
        'rev': "",
        'company': "",
        'date': "",
        'page': "",
        'thickness': 0,
        'drawings': 0,
        'tracks': 0,
        'zones': 0,
        'modules': 0,
        'nets': 0
    }

    thickDone = False

    with open(board, 'r') as f:
        for line in f:
            words = line.strip("\t ()").split()
            for key in prms:
                if len(words) > 1:
                    if key == words[0]:
                        prms[key] = words[1].strip("\t ()")
    return(prms)
Gasman2014 commented 6 years ago

I made a big assumption that the board outline was fairly fixed. The Kicad PLOT_SVG function plots the whole of the PCB canvas - so the board is just a small area in the middle of a large white canvas- unless it is cropped to the ROI.

Changing the board size or outline is a real problem as it is very difficult to determine a zero reference point. Without a set of co-ordinates, how do you map one image over another? I elected to trim the two revisions to their bounding boxes, and then do the comparison, making an assumption that the top left corner was the starting point to match. However, anychanges to the left and top board outline cause the whole plot area to be shifted. If the top & left remain constant between revisions, it is not a problem. I tried using the board reference but had some problems with this (there is some code that is commented out IIRC. This is another reason why plotting the output in a native format with a fixed outline is probably the best way to go, moving forward.

I have tried a couple of different approaches to this problem - I have been using OpenCV & PIL to try working out how to overlay one image on another with the least differences. This works in testing but adds a further layer of complexity.

BW

John

On 5 Oct 2018, at 16:05, Leandro Heck notifications@github.com wrote:

This is my prints to show the convert commands. Somtimes I have some issues here, like: The one starting by convert-im6.q16: images are.

Processing: homebase-F_Fab.png convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png -flatten -grayscale Rec709Luminance /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png -flatten -grayscale Rec709Luminance /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png "(" -clone 0-1 -compose darken -composite ")" -channel RGB -combine /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png convert-im6.q16: images are not the same size /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png' @ error/channel.c/CombineImages/128. convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png -fill "#C2C200" -fuzz 75% -opaque "#ffffff" /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png convert-im6.q16: unable to open image/home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png': No such file or directory @ error/blob.c/OpenBlob/2701. convert-im6.q16: no images defined `/home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/diff-16e3c5-2acd3f/homebase-F_Fab.png' @ error/convert.c/ConvertImageCommand/3258. convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png -define png:color-type=2 /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png -fill "#C2C200" -fuzz 75% -opaque "#ffffff" /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/16e3c5/homebase-F_Fab.png convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png -define png:color-type=2 /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png convert /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png -fill "#C2C200" -fuzz 75% -opaque "#ffffff" /home/lheck/Dropbox/deepx/HOMEBASE/homebase/plots/2acd3f/homebase-F_Fab.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gasman2014/KiCad-Diff/issues/2#issuecomment-427397348, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAyuS9eR9d1sZYl3SAVSa34bVb9M4Njks5uh3UvgaJpZM4XHNRo.

leoheck commented 6 years ago

I also had to improve the fields on the HTML page. I had to remove about 4 variables from the top of the list:

    </table>
    '''.format(
        TITLE=TITLE,
        DATE=DATE,
        COMPANY=COMPANY,
        diffDir1=diffDir1,
        diffDir2=diffDir2,
        THICK1=THICK1,
        THICK2=THICK2,
        D1DATE=D1DATE,
        D2DATE=D2DATE,
        DRAWINGS1=DRAWINGS1,
        DRAWINGS2=DRAWINGS2,
        D1TIME=D1TIME,
        D2TIME=D2TIME,
        TRACKS1=TRACKS1,
        TRACKS2=TRACKS2,
        ZONES1=ZONES1,
        ZONES2=ZONES2,
        MODULES1=MODULES1,
        MODULES2=MODULES2,
        NETS1=NETS1,
        NETS2=NETS2)
Gasman2014 commented 4 years ago

Hopefully the rewrite will have incorporated these changes and should be MUCH faster.