Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Request for an App
-
Thanks, that's interesting but given that the jpg may contain other extraneous items, I think it would be better to outline the area of interest. The calculation part of the script is in the git. What I need is help with the UI.
-
Could you colour flood fill from the outside and then test pixels? You might need to eliminate e.g. the compass in your example. Though I doubt it adds much to the inaccuracy.
-
Is there something wrong with the approach of entering vertices by touching them?
-
@ihf , I think you are getting frustrated now. I understand why 🤐
But I am sure guys here can help with what you need. If you look at the path demo in the examples folder, pretty sure it's what you are looking for with a ui. Not something I can do competently, so I will we another one answer. But I think that's on the right track
-
I was concerned that the creative alternative suggestions might be because what I am envisioning is somehow more difficult than it seems. I am pretty sure that collecting the polygon's vertices' coordinates and the scale line can't be difficult (at least for someone who is adept at using the Pythonista UI). Figuring out if the polygon has been closed without actually touching (precisely) the initial vertex ought to be doable by looking at the distance and simply prompting for whether this closes the outline. Adding the ability to move the vertices to fine tune is something that could be added later.
-
@ihf , I don't know about the native graphic support on iOS. But in 1984 it was pretty easy to program with polygons in c. It was what set the Mac apart. Was all in the Mac toolbox. The Mac toolbox from memory was just an exception call to the 68000 Motorola series processors. That exception was caught and looked up to see if it was a toolbox call.
Anyway enough reminiscing, if it was easy to do in 1984, should be very easy today. But the functions did not just work on a singular polygon, worked on multiple polygons. Was so cool for its time -
@MartinPacker 's method would still allow for the same input, and it would work nicely. See the Monte Carlo method.
-
I added a very simple ui as a pull req.
https://github.com/jsbain/RoomAreaFinderDraw the first line, then set the scale in the upper Left corner until the line length matches whatever the real length is, in whatever units you want. Then add vertices (click, or drag then release). Area is shown, though won't be accurate until the path is almost closed.
Some obvious improvements need to be made: magnifying zoom type effect when dragging, ability to grab and move existing points, slider for scale, perhaps pan/zoom for small devices.
-
@JonB My hat is off to you! It is already useful. With the improvements, I think this would be a publishable app. Many thanks!
-
@JonB I see you initially set scale to 0.08. What is the origin of that value? My thought was to set scale by initially touching 2 points that define a known length and then entering that length.
-
@ihf , sorry if I frustrated your efforts. But very happy to see you got a solution , or a least on the road to one.
-
I set the scale based on what looked about right on my ipad in landscape. it was slightly easier to implement this way, as it did not require an additional mode -- just draw, then set scale whenever it is convienent. for instance, you might find the initial points were not that accurate, so you can tweak and see the effect. A slider would be more intuitive i think.
-
@jonB The reason I had thought to measure scale independent of the area to be traced was that I thought it would be best to set scale using the longest known measurement on the plan and that might not be on the perimeter.
-
@jonb I am interested in modifying the script you were kind enough to write but I fear that my knowledge of the UI module (and perhaps Python more generally) is somewhat limited. I am trying to go through the script line by line and I have a few questions. Lines 27-28 and 36 seem to be setting a text label which never appears when the script is executed. Am I missing something? The script is already useful but it would benefit greatly by the features you mentioned (e.g., magnifying zoom effect when dragging, ability to grab and move existing points, slider for scale, pan/zoom) as well as a way to select the jpg of the floor plan (I can probably figure that one out :-). Any help you can provide is most appreciated.
-
i will make some comments on your github so we don't clutter the forums
-
@JonB I added floorplanarea-4 to the git repository with a file picker to select an image from the photo gallery and a slider for the scale setting. I tried to get the code to work in the RoomAreaView function but resorted to using a temporary file and calling the script with that file. In using the script, I also realize that a slider is fine except that the initial setting of the scale must be done with a known distance (e.g., a room width) but that measurement may not be part of the area calculation (e.g., it may be an interior room). So, a better way to set scale might be to do that explicitly (tap a button, select 2 pts with a known distance and enter that measurement in feet/inches) and then go on to mark the area to be computed.
I will say that this is already a useful script as I can now simply save a floor plan to the photo gallery and open it with the script and measure areas. Thank you for your expert assistance.
-
I have been playing around with getting gestures to work properly, to zoom/pan. It sort of works, but does not work inside a panel... yet. I will take a look at what you've got and incorporate into it.
A useful addition would probably be the ability to take a photo, then apply a perspective transform. for another project i was playing around with some of the built in ios rectangle detection algorithms.
-
@jonb I think that another useful feature would be the ability to measure distances (as opposed to areas). In other words, a linear measurement mode would permit line segments to be drawn anywhere (just as it does now for area measurement) but without connecting them to each other. Scale setting could then be invoked by a button that uses the last linear measure together with input of the known distance. Area measurement mode would work as it does now. This is essentially how Adobe Acrobat works. AA has 3 measurement modes: distance, perimeter, area. The current script could easily show perimeter by summing the distances measured. As I try to use the slider, I realize that entering the known distance would be better because it is hard to get the slider to the precise value that is based on the known distance. It would be easier to just type in that distance.
-
@JonB If you can find time, could you please take a look at floorplanarea-4? The script works fine but I have found that the slider is very hard to set (it changes the moment I take my finger off it) so I think a better UI would be to have a Scale Setting mode which would permit me to select 2 points for which there is a known distance and to enter the distance in feet and inches. This would also get around the problem I sometimes have where I have had to add a multiplier to the values provided by the slider because I wanted the displayed distance to be larger than the slider allowed.
The basic use case for this script is that I start with a picture of a floorplan which has some lengths shown and I want to determine the area of the space. I added a few lines at the end to permit me to select (using the image picker) an image in the photo gallery. I could not figure out how to feed the picked image to RoomAreaView directly so I used a temp file. I'm sure there must be a better way, but this works. It would also be nice if there were a way to snap the line segments to horizontal and vertical since most (though not all walls are that way). Being able to zoom for small plan images would be nice but I have managed without it.
Thanks very much for your help.
-
I might have forgotton to mention that I added two finger pan/zoom to the version in my repo a while back. Also, old points can be edited by grabbing the handles. This does let you be very precise... I sort of stopped working on this because I realized it probably needs a revamp from the ground up, the way I connected the touch handling with the other ui elements is pretty flawed -- it works, but is not clean, everything depends on everything else.
I will take a look at what you've got.