-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function to parse warpables.json into a multi-sequencer request in GCloud #10
Comments
For starters, we can simply use
In any of these cases, we'd still want to find the lowest This whole portion I can help with later, we don't have to worry too much about it; but it does correspond to this ruby code: |
@jywarren I am not very familiar with how webgl based functions work, it would be great if you can guide me here or point me to some resources as to how we get from the lat,long in the input json to the inputs for the webgl-distort module which are |
So what I understand by reading the links mentioned above is that we are trying to take the spherical lat/long values and convert them to x/y values on a plane. One thing I am not sure of is what is our reference point while calculating the new positions, I mean x,y values with respect to what point?? I would really appreciate any help here @jywarren @icarito 😄 |
Okay so looking at the ruby version here https://github.com/publiclab/mapknitter-exporter/blob/6c2fc0671944fc2c673fc7eb0b68a88e46ca3882/lib/mapknitterExporter.rb#L53-L69 |
Okay this kinda makes sense now! @jywarren I got down most of this, just need a little help with how to use the scaling factor (cm per pixel) |
Yes, so:
In the final version we can circle back and convert To be honest, i kind of forget how https://github.com/publiclab/mapknitter/blob/main/lib/exporter.rb#L63 is from the mercator projection conversion function: https://www.baeldung.com/java-convert-latitude-longitude OK, so scale is the same as the cm_per_pixel: https://github.com/publiclab/mapknitter-exporter/blob/6c2fc0671944fc2c673fc7eb0b68a88e46ca3882/lib/mapknitterExporter.rb#L348 But Does this help? Sorry, cartography is always a bit confusing!!! |
@jywarren Yeah, one more question though, how do I use pxperm to scale if the distance we have is not is meters but in degrees, I mean lon/lat values even relative to a point are gonna be in degrees right? So do we use the formula I mentioned above |
Alright! @jywarren Try this |
So to avoid image being cropped we need to resize the canvas first, now pushing in the converter I used! |
Alright! |
🎉 |
I think the next step here will be to start to bring all this together and stitch all the images together using canvas-resize and overlay! 😃 |
Ok cool! Running this on a 3-image map with larger images, I see: |
Oh actually it was three images, so maybe images are getting lost as the subsequent images are pasted over them? But it definitely warped all three! |
@jywarren Awesome, So tomorrow I'll try to manually generate a sequence to export a 3 image map and if that goes well we can start writing a script to automate that! |
@jywarren Also, as the output of the 3 image url you mentioned earlier, I tried it and it should give something like this.. Actually right now I have just aligned the images separately side by side rather than overlaying them onto a single canvas. Maybe you need to adjust the zoom to see all 3? |
possibly! Yeah i assumed once the overlaying is working, they'd all appear
on the same image. Thanks!
…On Wed, May 22, 2019 at 12:00 PM Varun Gupta ***@***.***> wrote:
@jywarren <https://github.com/jywarren> Also, as the output of the 3
image url you mentioned earlier, I tried it and it should give something
like this..
[image: Screen Shot 2019-05-22 at 9 28 49 PM]
<https://user-images.githubusercontent.com/25617855/58189706-9f5d9000-7cd8-11e9-9b10-911a76c5af0d.png>
Actually right now I have just aligned the images separately side by side
rather than overlaying them onto a single canvas. Maybe you need to adjust
the zoom to see all 3?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6JYU5K6SLYLNLTWL23TPWVUZJA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV7Q4NY#issuecomment-494865975>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6JYVGBQCUQOEQEYNNWTPWVUZJANCNFSM4HJTZRDQ>
.
|
@jywarren I am facing an issue and I think this relates to the internal structure of webgl-distort. |
Oh hmm, I'm not sure but it could be that the order is different. Let's
look at this code for comparison :
https://github.com/publiclab/Leaflet.DistortableImage/blob/cf82effaaf573d4af1c10752deda078c7845a7cd/src/edit/DistortableImage.Edit.js#L469
…On Wed, May 22, 2019, 11:39 PM Varun Gupta ***@***.***> wrote:
@jywarren <https://github.com/jywarren> I am facing an issue and I think
this relates to the internal structure of webgl-distort.
So the final corner points are coming out to be different from the inputs.
Are the inputs not the exact final corner points like
(nw,ne)
(sw,se)
??
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6J22UUWGZJZ72VK5NR3PWYGVDA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWA7FPI#issuecomment-495055549>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6JZT7D4AGGB3537LLJTPWYGVDANCNFSM4HJTZRDQ>
.
|
It's hard to say but you can compare it to the Mapknitter map itself?
…On Wed, May 22, 2019, 11:54 PM Varun Gupta ***@***.***> wrote:
I'll take a look!
So for the test image I used the following values
(40,0|214,45)
(0,104|169,166)
with image width being 214 and height being 166
this is the result that I got:
[image: image_0]
<https://user-images.githubusercontent.com/25617855/58224726-6f47d880-7d3c-11e9-8aff-9e67dafc87d6.png>
[image: image_1]
<https://user-images.githubusercontent.com/25617855/58224730-71aa3280-7d3c-11e9-8d4e-30bdb0557c87.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6J5TRN6RQ3LDUP73ELTPWYIMLA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWA7XDQ#issuecomment-495057806>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6JZ2VJUZYC4KP4AE7U3PWYIMLANCNFSM4HJTZRDQ>
.
|
@jywarren Is there someone else who would know more about this? Maybe someone from the mapknitter team? |
Maybe sashadev-sky? What is your exact question, though? Like, do you
suspect the corner order is not consistent? The code I sent marks North,
South East West, but I think you may need to just try some tests to see
what comes out the same as a mapknitter map looks like.
…On Wed, May 22, 2019, 11:57 PM Varun Gupta ***@***.***> wrote:
@jywarren <https://github.com/jywarren> Is there someone else who would
know more about this? Maybe someone from the mapknitter team?
I'll try to go through the mapknitter ruby version code for the time
being. 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6J57YW5WD3XW7HFVD43PWYIX5A5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWA72ZA#issuecomment-495058276>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J4P76SSXQ2MVADQPKLPWYIX5ANCNFSM4HJTZRDQ>
.
|
Actually, my question is that the final coordinates are coming out to be very different from what we are putting in as input, and I can't think of a reason why 😅 |
Actually not just the order, the corner points are entirely different from the input values. |
Oh hmm, can you point me at the exact points in the code where it's going
in and coming out? I'm about to go to sleep but can take a quick look!
…On Thu, May 23, 2019, 12:29 AM Varun Gupta ***@***.***> wrote:
Actually not just the order, the corner points are entirely different from
the input values.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6J7H2ITRLXTGZTXOJL3PWYMQVA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWBA6VQ#issuecomment-495062870>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J4EGIHOC2GFCOG6CETPWYMQVANCNFSM4HJTZRDQ>
.
|
Oh, do you mean in the image sequencer module code? |
Yeah like where do you mean you're passing values in and seeing different values out? Can you help me reproduce what you're seeing? Thanks! |
Also, can you please suggest a different map with multiple images which are smaller in size? Thanks! |
Hmm, unfortunately I think you may have to make one. Or you could point at
the scaled down versions of images, which do exist in mapknitter. See how
these images correspond:
https://s3.amazonaws.com/grassrootsmapping/warpables/306189/DJI_1202_thumb.JPG
https://s3.amazonaws.com/grassrootsmapping/warpables/306189/DJI_1202_medium.JPG
https://s3.amazonaws.com/grassrootsmapping/warpables/306189/DJI_1202.JPG
So try fetching the thumbnail versions?
…On Sat, May 25, 2019, 9:34 PM Varun Gupta ***@***.***> wrote:
Also, can you please suggest a different map with multiple images which
are smaller in size? Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6JYI3GWBSLHH7J3WBETPXHSHJA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWH4F4Y#issuecomment-495960819>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J2FDYRVPXL2V56WG6TPXHSHJANCNFSM4HJTZRDQ>
.
|
Oh, great! I'll start writing up the script for compositing sequence. |
Alright! @jywarren I think I have this pretty much down, I am running into one final issue where after warping the overlay step does not overlay correctly, some part is cropped off..this however does not happen with the canvas resize, the code however is essentially the same. I guess I would have to dig a little deeper but I think we are pretty close here! 😄 |
Wowwwwww!! So cool!
…On Sun, May 26, 2019, 11:59 AM Varun Gupta ***@***.***> wrote:
Alright! @jywarren <https://github.com/jywarren> I think I have this
pretty much down, I am running into one final issue where after warping the
overlay step does not overlay correctly, some part is cropped off..this
however does not happen with the canvas resize, the code however is
essentially the same. I guess I would have to dig a little deeper but I
think we are pretty close here! 😄
import-image webgl-distort canvas-resize import-image webgl-distort overlay
using this
[image: image_6]
<https://user-images.githubusercontent.com/25617855/58384225-0642b800-7ffd-11e9-8f63-b0fa472f26d1.jpeg>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6JYGICGB2FJZS7SBERTPXKXTLA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWIIR3Y#issuecomment-496011503>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J2NQHW3N7ALSFKX43TPXKXTLANCNFSM4HJTZRDQ>
.
|
Okay so I used a little trick just to see if everything works correctly, I excluded completely black points from getting overlaid. The result is perfect! |
Also, I am noticing that single sequences are running faster than equivalent multi step sequence! I think the added overhead of creating sequencer instances is actually more than the time we save! |
Alright! I have deployed a working exporter to the cloud which gives the correct result locally but the function runs out of memory in the cloud! Here is the final result locally: (A screenshot, the whole image is too large!!) |
This is looking great!!! Let's resolve the outer edge bounds issue and I'll
ask Sebastian to look at what infrastructure this can be run on. Are
instructions pretty clear as to how to set this up, and can you point me at
a URL for it (or message @ icarito with it) so we can get it set up in a
larger memory environment?
Thanks!
…On Mon, May 27, 2019, 8:23 AM Varun Gupta ***@***.***> wrote:
Alright! I have deployed a working exporter to the cloud which gives the
correct result locally but the function runs out of memory in the cloud!
Here is the final result locally: (A screenshot, the whole image is too
large!!)
[image: Screen Shot 2019-05-27 at 5 49 44 PM]
<https://user-images.githubusercontent.com/25617855/58419306-dc929b00-80a7-11e9-8744-911602e049b8.png>
@jywarren <https://github.com/jywarren> All we need now is to deploy on a
platform with more memory and this should give us a basic exporter! 🎉
I have made a special overlay module for this(different from the one in
the core sequencer) and it is consumed via npm in our app.
Some things still need work like the canvas is a little small to
accommodate all the images(I think this is happening because the given
corners for distortion and the final result are off by 100-200 pixels)
But still this is a start 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6JY3Y45YBTB6LJT4LY3PXPHDXA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWJVK7Q#issuecomment-496194942>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J2OXONTHQYV443QZXLPXPHDXANCNFSM4HJTZRDQ>
.
|
Sure! Docker is already set on the project and we should be able to set this up fairly easily! I'll commit the changes I made to the Api, and then we ahould be able to easily export as a docker container. |
@jywarren One thing I wanted to run by you was that right now I have reduced the Api to run a single sequence since that was faster, but let's also keep the old code, it would help in parallelizing the process. 😄 |
Yes, I think the parallel processing may be very important as file size and count scale up, no?
|
This function (referencing issue title) is now at https://github.com/publiclab/image-sequencer-app/blob/main/src/util/converter.js And accessed via this new route: af29486 |
@jywarren yeah parallel processing would be very important! But I want to get the basic version running, after which we can use the cluster api for parallelizing. |
I'll push in the canvas size fix today for sure! :D |
Alright! @jywarren I have added preliminary parallelization in the multiSequencer file, do take a look! I am just using one core of the CPU right now but it is already so much faster!!! 🎉 |
It's still running into memory constraints in the cloud functions!
|
@jywarren I think there is some problem with the way I have implemented this function, I tried increasing the scaling factor in the function and it just broke! The Images don't line up If I use a different height and width! Maybe you can take a look to see if you see anything wrong? 😅 |
Also @jywarren I have added the tests and the readme, left comments in the code and cleaned it up. |
basically the problem is that the images are being overlaid differently for different canvas sizes! |
Can you point at where you've implemented scaling? And open a new issue? I
should have time to look later today. Thanks!
…On Wed, May 29, 2019, 8:21 AM Varun Gupta ***@***.***> wrote:
basically the problem is that the images are being overlaid differently
for different canvas sizes!
The formula I have used to get the distortion positions is:
(node.x - minLon)*width/(maxLon-minLon) and similarly for y .
Then the overlay position is the minX and minY for all four corners of one
image.
This is only working with some values of width and height! In other cases
the overlay is off!! Since I am not really familiar with how webgl-distort
works internally I would really appreciate any help here :D
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAAF6JZHC4FWTXBINRISCZ3PXZYKJA5CNFSM4HJTZRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWPETPQ#issuecomment-496912830>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J2IXTSOYKZY7CUFNMLPXZYKJANCNFSM4HJTZRDQ>
.
|
Sure! Thanks a ton! 😃 |
We now have a basic multi-sequencer running in GCloud, although it's struggling with some bugs and performance issues -- see #6. Once we address those, we'll need a function which can fetch a warpables.json file (or receive it as JSON) and initiate a multi-sequencer call to GCloud.
Here is an example map with multiple images:
https://mapknitter.org/maps/ceres--2/ \ https://mapknitter.org/maps/ceres--2/warpables.json
Here is one with just a single very very small image, for initial testing (it should run much faster):
https://mapknitter.org/maps/pvdtest/ / https://mapknitter.org/maps/pvdtest/warpables.json
So, we will have JSON in this format (ref publiclab/mapknitter-exporter-sinatra#1 (comment)):
And we'll want to generate a request in a format like this (the sequence is wrong but it does include webgl-distort, and overlays to composite multiple images):
https://us-central1-public-lab.cloudfunctions.net/is-function-edge/api/v1/process/?steps=[{"id":1,"input":"https://i.publiclab.org/i/31778.png","steps":"webgl-distort{nw:0,101|ne:1023,-51|se:1223,864|sw:100,764}"},{"id":2,"input":1,"steps":"import-image{url:https://i.publiclab.org/i/31778.png},webgl-distort{nw:0,101|ne:1023,-51|se:1223,864|sw:100,764},overlay"}]
The text was updated successfully, but these errors were encountered: