Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 17-05-2011, 11:32   #106
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

M'dJ,That was fast work!and GOOD work1.11 works better!extracts and rebuilds well!I'm going to do some more testing.

I updated my scripts
imgkap_AUTO_Rebuild.doc
imgkap_Extract2Edit.doc

For birds like me
these are for building,extracting and rebuilding quickly without overwriting important stuff!
Have them in the folder with imgkap with the image and/or kaps .
and change from .doc to .bat
Double-click and go.
You can only have one "EX" on deck at a time.Hide any others from the Autorebuild script.
(Edit out all the blather if it bugs you!
and change outputs too,etc)
__________________

__________________
HappySeagull is offline   Reply With Quote
Old 17-05-2011, 12:18   #107
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 61
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by HappySeagull View Post
I rewrote the helpfile for myself.A bunch of easy notes I'm afraid I'll forget without it!might help others?
Attachment 27505

might be out of date now with newest version!
I think, you tan write on MS-DOS> or Shell> imgkap without argument.

Produce on screen :
ERROR - Usage:\imgkap [option] [inputfile] [lat0 lon0 lat1 lon1 | headerfile] [outputfile]

imgkap Version 1.11 by M'dJ

Convert kap to img :
imgkap mykap.kap myimg.png : convert mykap into myimg.png
imgkap mykap.kap mheader.kap myimg.png : convert mykap into header myheader (only text header kap file) and myimg.png

Convert img to kap :
imgkap myimg.png myheaderkap.kap : convert myimg.png into myimg.kap using myheader.kap for kap informations
imgkap myimg.png myheaderkap.kap myresult.kap : convert myimg.png into myresult.kap using myheader.kap for kap informations
imgkap mykap.png lat0 lon0 lat1 lon2 myresult.kap : convert myimg.png into myresult.kap using WGS84 positioning
imgkap -s 'LOWEST LOW WATER' myimg.png lat0 lon0 lat1 lon2 -f : convert myimg.png into myimg.kap using WGS84 positioning and options

Convert kml to kap :
imgkap mykml.kml : convert GroundOverlay mykml file into kap file using name and directory of image
imgkap mykml.kml mykap.kap: convert GroundOverlay mykml into mykap file

WGS84 positioning :
lat0 lon0 is a left,top point
lat1 lon1 is a right,bottom point
lat to be beetwen -85 and +85 degree
lon to be beetwen -180 and +180 degree
different format are accepted : -1.22 1°10'20.123N -1d22.123 ...
Options :
-n : Force compatibilty all KAP software, max 127 colors
-f : fix units to FATHOMS
-s name : fix souding datum
-t title : change name of map
-p color : color of map
- Kap to image color : ALL|RGB|DAY|DSK|NGT|NGR|GRY|PRC|PRG
ALL generate multipage image, use only with GIF or TIF - image or Kap to Kap color : NONE|KAP|MAP|IMG
NONE use colors in image file, default
KAP only width KAP or header file, use RGB tag in KAP file
MAP generate DSK and NGB colors for map scan (< 64 colors) Black -> Gray, White -> Black
IMG generate DSK and NGB colors for image (photo, satellite...)
I modify this any version.

To make a text file, just write Shell>imgkap 2>myfile.txt and in MS-DOS>imgkap > myfile.txt (or same Shell ?)

M'dJ
__________________

__________________
MdJ is offline   Reply With Quote
Old 17-05-2011, 12:32   #108
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by MdJ View Post
Version 1.11 same as 1.1

Now option "-n" is modified to force KAP begin at colors 1 (max 127).

You can use -n option with all other option to produce KAP file

HappySeagull, try with VisNav...
> imgkap first.kap -n result.kap

Regards
three colours works,two colours does not. -n didn't help
here's visnav+kapview

Click image for larger version

Name:	ScreengrabVisNav.png
Views:	113
Size:	29.3 KB
ID:	27515Click image for larger version

Name:	screengrabKapview.png
Views:	125
Size:	29.8 KB
ID:	27516Click image for larger version

Name:	ScreengrabVisNavOK.png
Views:	120
Size:	30.1 KB
ID:	27517


to try:

Code:
imgkap TestChartPalette2colours2.png 49.506478 -124.838820 49.480322 -124.772093 -n
imgkap TestChartPalette3colours.png 49.506478 -124.838820 49.480322 -124.772093
Click image for larger version

Name:	TestChartPalette2colours2.png
Views:	113
Size:	2.9 KB
ID:	27514

Click image for larger version

Name:	TestChartPalette3colours.png
Views:	116
Size:	3.7 KB
ID:	27512
__________________
HappySeagull is offline   Reply With Quote
Old 17-05-2011, 12:33   #109
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

But it's much better!who makes a map with two colours?
__________________
HappySeagull is offline   Reply With Quote
Old 17-05-2011, 15:26   #110
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 61
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by HappySeagull View Post
But it's much better!who makes a map with two colours?
For error with two or three colors.

One celebrity in French of strange (bizarre in French) :

Watch Bizarre, Bizarre Online - VideoSurf Video Search

M'dJ
__________________
MdJ is offline   Reply With Quote
Old 17-05-2011, 18:03   #111
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by MdJ View Post
For error with two or three colors.

One celebrity in French of strange (bizarre in French) :

Watch Bizarre, Bizarre Online - VideoSurf Video Search

M'dJ


Oh,and imgkap1.11 works fine with the black+white chart posted above in thread.I extracted ,rebuilt .. and did that yet again.It Works!
Click image for larger version

Name:	B+WEX+rebuilt.png
Views:	111
Size:	12.3 KB
ID:	27520
ps: no error with 3 colours..."beezair-rr?"or what?
__________________
HappySeagull is offline   Reply With Quote
Old 17-05-2011, 18:11   #112
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

M'dJ ,per post 107-I'll try that!Thanks!
__________________
HappySeagull is offline   Reply With Quote
Old 18-05-2011, 11:06   #113
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

...The reason for all that...was to colourize the B+W chart,which I could not do before without trouble but now it's easy ..see?
Click image for larger version

Name:	coloured.png
Views:	121
Size:	31.4 KB
ID:	27530

much easier to read this chart now!
__________________
HappySeagull is offline   Reply With Quote
Old 18-05-2011, 11:35   #114
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

My next imgkap project:
create images to match input lat/lon corners without screen grabs....The arithmetic has use per kmls? and per borders, in the header ...ie:writing refpoints?
so far,I have:
((lat1-lat2)/cos((lat1-lat2)/2+lat2))*(imageXpixels/imageYpixels)+/-lon1=lon2
or a variation depending on N/S,E/W positions...
and it works...at least, a kap comes out per the dimensions image dimensions..

I am guessing, in the formula above that for Mercator, an averaged mid latitude is the cos to use but I should check this...the lowest lat might be best and it seems to work as well and is simpler...hmm?

lon1-((lat1-lat2)*(cos(lat2))*(imageXpixels/imageYpixels)=lon2

I'm editing an actual formula as a general version here so forgive mistakes?brackets etc.
__________________
HappySeagull is offline   Reply With Quote
Old 18-05-2011, 14:12   #115
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 61
Re: imgkap - kap File Converter Tool

Originally, when testing google images, I found significant errors in width and height of images, the reason is the projection. Mercator projection takes into account the elliptical earth.

The difference gave offset sometimes by several nautical miles.

The latest version of OpenCPN fixes this, but I prefer to keep my code who enlarged the image based on the elliptical with the following calculations:

WGSexentrik 0.081819

lontox (lon) return (lon * PI/180)

lattoy_WS84 (lat)
(
e = WGSexentrik;
sinl s = (l * M_PI/180.0);

return log (tan (M_PI / 4 + l * M_PI/360) * pow ((1. - s * e) / (1. * s + e) e / 2.));
)

W = lontox (lon1)-lontox (lon0);
ly = lattoy_WS84 (lat0)-lattoy_WS84 (lat1);


Then in the code, I adapt the height and width of the image to have the same relationship between lx and ly.

Imgkap, does not currently designed to transform the different projection, the goal is to process the images and converting to or from KAP.

I think it would work with GE2KAP or How to overlay NOAA raster charts in Google Earth | My marine electronics blog which is based on gdal.

M'dJ
__________________
MdJ is offline   Reply With Quote
Old 18-05-2011, 16:27   #116
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

Yikes!
That's about all a seagullcan offer to that!!

except,
a QUESTION for you M'dJ:
"Imgkap, does not currently designed to transform the different projection, the goal is to process the images and converting to or from KAP."

So,
when a Polyconic is extracted and rebuilt from header with IMGKAP,the new kap is still Polyconic....?
It seems to be.It says it is....I haven't looked really closely at this yet,except that it looks very well and waypoints match pretty well.Perhaps it's just the large scale that fools me?


Oh and...I did the simple algebra a seagull can handle and that to
make an image withX:Y PROPORTIONS that match the corners I want ....

(lon1-lon2)/((lat1-lat2)/cos(((lat1-lat2)/2)+lat2))=(X/Y) where Y=1 of course.
....or something like this depending on N/S of Equator and E/W of Greenwich,but as long as the output proportion agrees with common sense,...Subtracting "larger from smaller" should do the trick ?and "adding to the smaller" likewise. "-"=south and west not needed and gets too "busy"....they work and this is pretty cool!
__________________
HappySeagull is offline   Reply With Quote
Old 19-05-2011, 09:51   #117
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,395
Re: imgkap - kap File Converter Tool

"WGSexentrik 0.081819
lontox (lon) return (lon * PI/180)
lattoy_WS84 (lat)
(
e = WGSexentrik;
sinl s = (l * M_PI/180.0);

return log (tan (M_PI / 4 + l * M_PI/360) * pow ((1. - s * e) / (1. * s + e) e / 2.));
)
W = lontox (lon1)-lontox (lon0);
ly = lattoy_WS84 (lat0)-lattoy_WS84 (lat1);

Then in the code, I adapt the height and width of the image to have the same relationship between lx and ly."
...I'll have to rearrange it ...I can't see it so clear with "lattoy",return and such in there!but I think I know what you mean..
all the GEOdatum models, are a tiny bit compromised on a not-exactly spherical Earth and Projection-to-flat Map adds a little more.. so Google Earth tweaks their model even more to display "intuitively" , I guess.
But I'm happy with "close enough" accuracy... the sounder always trumps me+gps+chart!
__________________
HappySeagull is offline   Reply With Quote
Old 25-06-2011, 04:30   #118
Registered User
 
Netsurfer's Avatar

Join Date: Jan 2010
Location: Cologne, Germany
Boat: Beneteau Oceanis 331
Posts: 557
Re: imgkap - kap File Converter Tool V1.1

Quote:
Originally Posted by MdJ View Post
imgkap Version 1.1

Install
For all system, tested on Windows 32 and on linux 32 and 64 bit
Having a C or C++ compiler : gcc, g++…

Download and install freeimage-dev, on Ubuntu > sudo apt-get install libfreeimage-dev
Prefer last version, see The FreeImage Project

Download imgkap.c and compile width gcc or g++:
> gcc imgkap.c -O3 -s -lfreeimage -o imgkap
I wanted to install the program on my Debian Lenny server.

I tried
Quote:
gcc imgkap.c -O3 -s -lfreeimage -o imgkap
with the following result
Quote:
imgkap.c: In function 'writeimgkap':
imgkap.c:1078: warning: incompatible implicit declaration of built-in function 'log2'
imgkap.c:1134: warning: incompatible implicit declaration of built-in function 'round'
imgkap.c: In function 'kaptoimg':
imgkap.c:1348: error: 'FI_COLOR_IS_RGB_COLOR' undeclared (first use in this function)
imgkap.c:1348: error: (Each undeclared identifier is reported only once
imgkap.c:1348: error: for each function it appears in.)
imgkap.c:1348: warning: assignment makes pointer from integer without a cast
imgkap.c: In function 'imgheadertokap':
imgkap.c:1549: error: 'FI_COLOR_IS_RGB_COLOR' undeclared (first use in this function)
imgkap.c:1549: warning: assignment makes pointer from integer without a cast
imgkap.c: In function 'imgtokap':
imgkap.c:1676: warning: incompatible implicit declaration of built-in function 'round'
As I am a total Noob on Linux any help is appreciated.

Or if anybody has another idea ...
I want to use the program for installing an OpenCPN community KAP chart DB. So users should be able to upload their KAP chart files. On the server the chart should be splitted into the header and the image.

Many thanks in advance,

Gunther
__________________
Deutschsprachige Community- und Support-Website unter OpenCPN.de
Netsurfer is offline   Reply With Quote
Old 25-06-2011, 05:22   #119
Registered User

Join Date: Dec 2005
Location: WNA
Boat: Dufour 35
Posts: 3,250
Re: imgkap - kap File Converter Tool

Gunther
I think that you may not have all the necessary "development headers" installed.
You may try
Quote:
apt-get update && apt-get upgrade
apt-get install build-essential
depending on how you keep your server updated. The main thing is to have the meta package "build-essential" installed.
Did you follow this instruction
Quote:
Download and install freeimage-dev, on Ubuntu > sudo apt-get install libfreeimage-dev
This package may have a different name in Debian.

Thomas
__________________
cagney is offline   Reply With Quote
Old 25-06-2011, 05:47   #120
Registered User
 
Netsurfer's Avatar

Join Date: Jan 2010
Location: Cologne, Germany
Boat: Beneteau Oceanis 331
Posts: 557
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by cagney View Post
Gunther
I think that you may not have all the necessary "development headers" installed.
Hmmm ..., looked like there were 6 packages missing -> installed.

Quote:
This package may have a different name in Debian.
I think it has the same name and should be installed:
Quote:
# apt-get install libfreeimage-dev
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut
Lese Status-Informationen ein... Fertig
libfreeimage-dev ist schon die neueste Version.
Tried again afterwards but still with the same error messages:
Quote:
imgkap.c: In function 'writeimgkap':
imgkap.c:1078: warning: incompatible implicit declaration of built-in function 'log2'
imgkap.c:1134: warning: incompatible implicit declaration of built-in function 'round'
imgkap.c: In function 'kaptoimg':
imgkap.c:1348: error: 'FI_COLOR_IS_RGB_COLOR' undeclared (first use in this function)
imgkap.c:1348: error: (Each undeclared identifier is reported only once
imgkap.c:1348: error: for each function it appears in.)
imgkap.c:1348: warning: assignment makes pointer from integer without a cast
imgkap.c: In function 'imgheadertokap':
imgkap.c:1549: error: 'FI_COLOR_IS_RGB_COLOR' undeclared (first use in this function)
imgkap.c:1549: warning: assignment makes pointer from integer without a cast
imgkap.c: In function 'imgtokap':
imgkap.c:1676: warning: incompatible implicit declaration of built-in function 'round'
BTW: Where (in which path) should I put the source file (imgkap.c) or doesn't it matter?

Anything else I could try?

Thanks
Gunther
__________________

__________________
Deutschsprachige Community- und Support-Website unter OpenCPN.de
Netsurfer is offline   Reply With Quote
Reply

Tags
imgkap

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Development Debugging Environment - Setup Help rgleason OpenCPN 577 11-11-2017 06:02
OpenCPN Beta Version 3.1.814 Released bdbcat OpenCPN 185 14-09-2012 08:43
Route File Transfer via SDcard to Garmin 441s four winds Navigation 11 25-02-2012 09:34
GRIB Weather Mark Ward OpenCPN 26 12-02-2012 22:33
Route Properties, Missing Functions James Baines OpenCPN 13 13-07-2011 05:31



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 00:44.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.