Page 1 of 1

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

Posted: Tue 03 Mar 2015, 15:40
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!

Hi SFR

Posted: Tue 03 Mar 2015, 21:08
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/

Posted: Tue 03 Mar 2015, 21:23
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!

You are in true.

Posted: Tue 03 Mar 2015, 22:54
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!

Posted: Tue 28 Apr 2015, 14:09
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

Posted: Tue 28 Apr 2015, 15:51
by SFR
Yeah, good idea, added in v1.3.

Thanks &
Greetings!

Posted: Wed 22 Jul 2015, 08:56
by greengeek
Nice app. I find the lite version works for me as the full version (and rul3r) gives me the following output:

Posted: Wed 22 Jul 2015, 09:11
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!

Posted: Wed 22 Jul 2015, 09:30
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.

Posted: Mon 23 Oct 2017, 13:53
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!

Posted: Mon 23 Oct 2017, 19:58
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.

Posted: Mon 23 Oct 2017, 21:36
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!

Posted: Mon 23 Oct 2017, 23:45
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!

Posted: Tue 24 Oct 2017, 02:50
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

Posted: Tue 24 Oct 2017, 06:26
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?)

Posted: Tue 24 Oct 2017, 08:48
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!