measur3r v1.3 - onscreen measurement in pixels, cm, inches

Mathematical tools, physics simulators, CAD, CNC, etc.
Post Reply
Message
Author
User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

measur3r v1.3 - onscreen measurement in pixels, cm, inches

#1 Post by SFR »

With this app you can measure objects on the desktop.
Just launch it, click on point A, click on point B and enjoy the results. ;)
You'll get coordinates of A & B points, a distance between them in pixels, centimeters and inches, and additionally a distance relative to X and Y axes.

Requirements: bash, xwininfo, xrandr, getcurpos, awk, which (g)xmessage

EDIT: attached also measur3r_lite, which supports only pixel units, not cm/in.
For those for whom the regular version can not read the physical display size and who are unable to determine that size by themselves (or just don't need/care about cm/in).
___________

Changelog:

Version 1.1
- a warning window in case if obtaining the physical size of the display has failed (thanks to Jasper & mister_electronico)
- physical size of the display can be also defined manually in $HOME/.measur3r

Version 1.2
- fix in calculations for screens that have width smaller than height (thanks to MochiMoppel)

Version 1.3
- added 'Repeat' button (thanks to charlie6)
- better compatibility with _real_ xmessage

Have fun &
Greetings!
Attachments
measur3r_lite-1.3.pet
Supports only pixel units.
(1.8 KiB) Downloaded 851 times
measur3r-1.3.pet
(2.35 KiB) Downloaded 892 times
Screenshot.png
(7.32 KiB) Downloaded 1097 times
Last edited by SFR on Tue 28 Apr 2015, 15:51, edited 5 times in total.
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Hi SFR

#2 Post by mister_electronico »

Hi SFR the program seems very interesting, but can not get it to work.

If I run through terminal gives me the following error

awk: fatal: division by zero attempted
awk: fatal: division by zero attempted


I am working with Slacko Puppy 5.6 Non-PAE.

I find it very interesting.



Greetings!






________________________________________________________________________
My Blog

https://misterelectronicoes.wordpress.c ... -homemade/

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#3 Post by SFR »

Hmm, I think you're facing the same problem as Jasper here: http://www.murga-linux.com/puppy/viewto ... 820#831820
I've no idea why in my (and MochiMoppel's, and Geoffrey's) case xrandr reports real screen dimensions and in your and Jasper's not...

Anyway, as a workaround you could (if you know your display's actual dimensions, in millimeters) alter the code and hardcode these values right after this line, e.g.:

Code: Select all

read MM_X MM_Y <<< `xrandr | grep -wo -m1 '[0-9]*mm x [0-9]*mm' | tr -cd '[0-9]x' | awk -F "x" '{print $1" "$2}'`

# hardcoded:
MM_X=267
MM_Y=200
Thanks for you interest &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

You are in true.

#4 Post by mister_electronico »

Hi SFR you are in true, I don't know why :

read MM_X MM_Y <<< `xrandr | grep -wo -m1 '[0-9]*mm x [0-9]*mm' | tr -cd '[0-9]x' | awk -F "x" '{print $1" "$2}'`

do
MM_X = 0
and

MM_Y = 0

But like you said I change :


MM_X = 320
MM_Y = 200

Is my case:

#xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 1920 x 1920
VGA-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1920x1080 60.0*+
DVI-0 disconnected (normal left inverted right x axis y axis)


and works...

So thanks SFR .... good program.

Greetings!

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#5 Post by charlie6 »

Hi SFR,
this is really an awesome app ! thanks for it also !

I regularly reads drawings on screen and have to estimate dimensions ...using a ruler and doing measurments straight onto the screen and performing some cross-multiplication to convert to real size...etc,etc,etc,...funny isn't?! :(

In ordre to repeat successive measuurments using measur3r, here is what i've found to repeat measur3r start without having to each time select it in the menu.

replace line 69

Code: Select all

xmessage -title "$APPNAME" -center -font monospace -bg yellow "$RESULT"
by the following 6 lines

Code: Select all

xmessage -buttons "REPEAT,RESUME" -title "$APPNAME" -center -font monospace -bg yellow "$RESULT"
ANSWER=$?

if [ $ANSWER -eq 101 ]; then
exec measur3r
fi
HTH
Charlie
Attachments
measur3r.png
(12.94 KiB) Downloaded 792 times

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#6 Post by SFR »

Yeah, good idea, added in v1.3.

Thanks &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#7 Post by greengeek »

Nice app. I find the lite version works for me as the full version (and rul3r) gives me the following output:
Attachments
unable_to_determine.jpg
(27.86 KiB) Downloaded 640 times

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#8 Post by SFR »

Yes, in some cases, I don't know why, xrandr doesn't report physical size of the display (see my post above).
If you know the real dimensions, just follow the instructions (echo "X_MM Y_MM" ...).

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#9 Post by 01micko »

Just a note - xrandr is an extension which all drivers (Xorg drivers) don't necessarily support. (vesa, modesetting, fb etc)

here is a C snippet that gets it - use with caution (wont work over hdmi)

Code: Select all

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>

// application entry point
int main(int argc, char* argv[])
{
  int fbfd = 0; // framebuffer filedescriptor
  struct fb_var_screeninfo var_info;

  // Open the framebuffer device file for reading and writing
  fbfd = open("/dev/fb0", O_RDWR);
  if (fbfd == -1) {
    printf("Error: cannot open framebuffer device.\n");
    return(1);
  }
  printf("The framebuffer device opened.\n");

  // Get variable screen information
  if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var_info)) {
    printf("Error reading variable screen info.\n");
  }
  printf("Display info %dx%d, %d bpp\n", 
         var_info.xres, var_info.yres, 
         var_info.bits_per_pixel );

  // close file  
  close(fbfd);
  
  return 0;

}
Dunno if there is equivalent lib in bash.
Puppy Linux Blog - contact me for access

Puppyt
Posts: 907
Joined: Fri 09 May 2008, 23:37
Location: Moorooka, Queensland
Contact:

#10 Post by Puppyt »

Thank you SFR!
I just needed to compare two distances in (generally) non-vertical or non-horizontal directions on-screen, and measur3r 1.3 seems to have done the deed for me in terms of pixel distance results. Cheers!
Search engines for Puppy
[url]http://puppylinux.us/psearch.html[/url]; [url=https://cse.google.com/cse?cx=015995643981050743583%3Aabvzbibgzxo&q=#gsc.tab=0]Google Custom Search[/url]; [url]http://wellminded.net63.net/[/url] others TBA...

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#11 Post by Flash »

Huh. I never saw this before. It works fine in Quirky Werewolf 64-bit.

I have two suggestions: 1.) The point of the arrow I use for a cursor would be more accurate for finding a pixel than is the cross that measure3r uses - the cross is kind of broad. And 2.) Wouldn't this be better in Graphic, not Business?

But it really works well for me. Thanks, SFR!

I was able to move the window by dragging its edges to where I wanted them.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#12 Post by SFR »

Puppyt wrote:Thank you SFR!
I just needed to compare two distances in (generally) non-vertical or non-horizontal directions on-screen, and measur3r 1.3 seems to have done the deed for me in terms of pixel distance results. Cheers!
You're welcome, glad it does what you wanted it to do.
___________
Flash wrote:The point of the arrow I use for a cursor would be more accurate for finding a pixel than is the cross that measure3r uses - the cross is kind of broad.
I don't really have control over it - the shape of the mouse pointer comes from xwininfo utility, which is used by measur3r to aquire screen coordinates without interacting with what's on screen.
Flash wrote:Wouldn't this be better in Graphic, not Business?
Yep, Business doesn't fit, indeed...but it's in Engineering/Science/Simulation. ;)
Flash wrote:I was able to move the window by dragging its edges to where I wanted them.
Yeah, in some window managers (Openbox, Compiz) (g)xmessage's window has titlebar, but in JWM it doesn't, because of this (usually in /etc/xdg/templates/_root_.jwmrc, but YMMV):

Code: Select all

<Group>
	<Name>xmessage</Name>
	<!-- <Option>icon:info16.xpm</Option> -->
	<Option>notitle</Option>
	<Option>nolist</Option>
</Group>
Anyway, you can also move it using Alt+Left_Mouse_Button.

Thanks &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

Puppyt
Posts: 907
Joined: Fri 09 May 2008, 23:37
Location: Moorooka, Queensland
Contact:

#13 Post by Puppyt »

Ah yes - in my haste I didn't provide testing details - I'm running measur3r in TahrPup32, v6.0.5, using the JWM environment. My screenie confirms Flash's observation that it winds up in "Business" - but it does the business, I guess. "Graphics" would also be my preference, all things considered.
(or I could rename my "Business" menu category more appropriately as "Science". No dramas...)

Flash refers to an issue I had reported to in another thread (http://murga-linux.com/puppy/viewtopic.php?t=111913) concerning the output dialogue. I will try the ALT+left click again in JWM to move it to a more practical location than center screen,
Cheers!
Attachments
measur3r_tahrpup32.jpg
Screenie of measur3r (v 1.3) in TahrPup32 6.0.5
(73.17 KiB) Downloaded 374 times
Search engines for Puppy
[url]http://puppylinux.us/psearch.html[/url]; [url=https://cse.google.com/cse?cx=015995643981050743583%3Aabvzbibgzxo&q=#gsc.tab=0]Google Custom Search[/url]; [url]http://wellminded.net63.net/[/url] others TBA...

Puppyt
Posts: 907
Joined: Fri 09 May 2008, 23:37
Location: Moorooka, Queensland
Contact:

#14 Post by Puppyt »

OK so Alt+left_mouse works a treat, thanks. Found that I can have multiple instances of measur3r going for immediate comparisons. In the example below I have a measure for the distance between two wires, illustrated by the white rectangle, in the dialogue to the right. On the left I have projected the width of the feed bunk at that distance (with due estimation of the vanishing points), shown in the red line (hmm looks off by about 2-3 degrees of rotation, seeing it from a distance). This image was made by using PrtScn and then adding the measurement lines in mtpaint 3.44.88, all done in TahrPup 6.0.5 (32bit) and JWM. Hope others find this really useful :)

PS I can even highlight select text in any dialogue - in grey and not shown here - but unfortunately only one dialogue will have the highlighted text at any one time. No biggie
Attachments
measur3r eg.jpg
Demo of multiple instances of measur3r open simultaneously
(35.94 KiB) Downloaded 376 times
Search engines for Puppy
[url]http://puppylinux.us/psearch.html[/url]; [url=https://cse.google.com/cse?cx=015995643981050743583%3Aabvzbibgzxo&q=#gsc.tab=0]Google Custom Search[/url]; [url]http://wellminded.net63.net/[/url] others TBA...

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#15 Post by greengeek »

SFR wrote:
Flash wrote:Wouldn't this be better in Graphic, not Business?
Yep, Business doesn't fit, indeed...but it's in Engineering/Science/Simulation. ;)
!
What Flash means is that it appears in the "Business" portion of the main Puppy menu (rather than referring to which "murga forum" subsection).

"Business" is probably a reasonable place for it since "calculator" is also there... but why isn't there a "Technical" subsection to the puppy menu? Thats where the Calculator and Ruler functions really should be. (Maybe it's an XDG or similar limitation - dependent on the big distros?)

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#16 Post by SFR »

RE: Business

Yeah, I got it now, sorry!
Intentionally it should go to 'Calculate' submenu and it does, in Fatdog.
In Puppy however /etc/xdg/menus/puppy-calculate.menu is a symlink to puppy-business.menu, that's why it ended up there.
But still, that's where all other calculating apps reside...

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

Post Reply