How do I retrieve the positional coords of the scanner from e57

Please feel free to ask other members for help with certain projects
Post Reply
ScannerIRE
I have made 10-20 posts
I have made 10-20 posts
Posts: 13
Joined: Tue Apr 12, 2022 1:06 pm
Full Name: James Morrissey
Company Details: myself
Company Position Title: Software Dev
Country: Ireland
Has thanked: 3 times

How do I retrieve the positional coords of the scanner from e57

Post by ScannerIRE »

In CloudCompare

I can open a .e57 file, select any one of its "sweeps", expand its 'tree' then I'm able to select a 'Skybox' and press Ctrl + S and it automatically opens a new window to save the image.


But if select the 'TLS/GBL' part of the sweep and try to do the same thing, it gives and error 'Nothing to save'
[DepthMap] sensor 'TLS/GBL' has no associated depth map (you must compute it first)


I ultimately just want to extract the x,y,z, and rotational coordinates of the scanner and save them to a file
I'm aware that there's an 'export' function within the 'Position / Orientation ' Section that can allow it to do that


I'm just seeing if I can do a simple Ctrl + S on the TLS/GBL node/object, like how the skybox is saved

So my question is compute a Depth Map and have it associated with this sweep


I have also looked into http://lastools.org to see if I can retrieve the data but, no luck


I have tried using https://github.com/davidcaron/pye57 but I have had lots of trouble setting it up
You do not have the required permissions to view the files attached to this post.
badam
V.I.P Member
V.I.P Member
Posts: 459
Joined: Tue May 11, 2021 5:36 pm
1
Full Name: Adam Berta
Company Details: InnoScan 3D Hungary Kft
Company Position Title: unknown
Country: Hungary
Linkedin Profile: No
Has thanked: 16 times
Been thanked: 123 times
Contact:

Re: How do I retrieve the positional coords of the scanner from e57

Post by badam »

ScannerIRE wrote: Tue May 03, 2022 4:37 pm In CloudCompare

I can open a .e57 file, select any one of its "sweeps", expand its 'tree' then I'm able to select a 'Skybox' and press Ctrl + S and it automatically opens a new window to save the image.


But if select the 'TLS/GBL' part of the sweep and try to do the same thing, it gives and error 'Nothing to save'
[DepthMap] sensor 'TLS/GBL' has no associated depth map (you must compute it first)


I ultimately just want to extract the x,y,z, and rotational coordinates of the scanner and save them to a file
I'm aware that there's an 'export' function within the 'Position / Orientation ' Section that can allow it to do that


I'm just seeing if I can do a simple Ctrl + S on the TLS/GBL node/object, like how the skybox is saved

So my question is compute a Depth Map and have it associated with this sweep


I have also looked into http://lastools.org to see if I can retrieve the data but, no luck


I have tried using https://github.com/davidcaron/pye57 but I have had lots of trouble setting it up

You are tryng to solve the issue, soo many ways. And you clearly don't have the knowledge to do it properly. I'm sorry to say that, but you should contact someone who know how to program in C++. All of this can be done like in a week with libe57. export the image/coordinates of them.
ScannerIRE
I have made 10-20 posts
I have made 10-20 posts
Posts: 13
Joined: Tue Apr 12, 2022 1:06 pm
Full Name: James Morrissey
Company Details: myself
Company Position Title: Software Dev
Country: Ireland
Has thanked: 3 times

Re: How do I retrieve the positional coords of the scanner from e57

Post by ScannerIRE »

badam wrote: Tue May 03, 2022 4:58 pm
You are tryng to solve the issue, soo many ways. And you clearly don't have the knowledge to do it properly. I'm sorry to say that, but you should contact someone who know how to program in C++. All of this can be done like in a week with libe57. export the image/coordinates of them.
Thanks Adam !

Can there be some section on this forum dedicated to the installation/setup of libe57, pye57, libE57Format

I know that it would be a huge benefit for the less experienced people here.

I'm 99% sure that my issue is some silly mistake I made during the setup phase
badam
V.I.P Member
V.I.P Member
Posts: 459
Joined: Tue May 11, 2021 5:36 pm
1
Full Name: Adam Berta
Company Details: InnoScan 3D Hungary Kft
Company Position Title: unknown
Country: Hungary
Linkedin Profile: No
Has thanked: 16 times
Been thanked: 123 times
Contact:

Re: How do I retrieve the positional coords of the scanner from e57

Post by badam »

ScannerIRE wrote: Tue May 03, 2022 6:52 pm
badam wrote: Tue May 03, 2022 4:58 pm
You are tryng to solve the issue, soo many ways. And you clearly don't have the knowledge to do it properly. I'm sorry to say that, but you should contact someone who know how to program in C++. All of this can be done like in a week with libe57. export the image/coordinates of them.
Thanks Adam !

Can there be some section on this forum dedicated to the installation/setup of libe57, pye57, libE57Format

I know that it would be a huge benefit for the less experienced people here.

I'm 99% sure that my issue is some silly mistake I made during the setup phase
In this topic
https://laserscanningforum.com/forum/vi ... 800#p99800

We (smacl, me and the compiler) already told you what is your issue with libe57. You missed the xerces-c library.
jedfrechette
V.I.P Member
V.I.P Member
Posts: 1126
Joined: Mon Jan 04, 2010 7:51 pm
12
Full Name: Jed Frechette
Company Details: Lidar Guys
Company Position Title: CEO and Lidar Supervisor
Country: USA
Linkedin Profile: Yes
Location: Albuquerque, NM
Has thanked: 43 times
Been thanked: 143 times
Contact:

Re: How do I retrieve the positional coords of the scanner from e57

Post by jedfrechette »

It seems like you may be most comfortable using Python so I'll note that extracting scan positions and other metadata is pretty straightforward using pure Python. Below are a couple of functions that can be used to read the xml metadata from an e57 file. The resulting xml blob should be identical to what you would get using the e57xmldump utility from libe57.

Once you have the xml metadata you'll still need to apply the transforms that it defines to determine the scanner poses, but this approach has worked well for us in environments where we just had the standard Python library (and Numpy) and didn't want to add additional dependencies.

Code: Select all

# Standard Library Imports
from math import ceil
from struct import unpack
from xml.etree import ElementTree


def get_header(e57_path):
    """
    Read header data from e57 file.

    :param e57_path: Path to the e57 to extract header from.
    :return: {'file_signature': 'The file type signature. ' \
                                 'Shall contain the ASCII characters “ASTM-E57”',
              'version_major': 'The file format major version number. ' \
                               'The value shall be 1.'
              'version_minor': 'The file format minor version number. ' \
                               'The value shall be 0.'
              'file_length': 'The physical length of the file, in bytes. ' \
                             'Note that this length includes CRC bytes and ' \
                             'any zero padding as described in 6.2.2. ' \
                             'Shall be in the open interval (0, 2^63).'
              'xml_offset': 'The physical file offset, in bytes, to the ' \
                             'beginning of the XML section of the file. ' \
                             'As defined in 3.2.10, this value includes CRC ' \
                             'bytes. Shall be in the open interval (0, 2^63).'
              'xml_length': 'The logical length, in bytes, of the XML ' \
                            'section of the file, excluding CRC bytes and ' \
                            'zero padding. Shall be in the open ' \
                            'interval (0, 2^63).'
              'page_size': ' The size a page, in bytes, as defined in 6.2. ' \
                           'The value shall be 1024.'}
    """
    with open(e57_path, 'rb') as f_handle:
        values = unpack('<8sLLQQQQ', f_handle.read(48))

    return {'file_signature': values[0],
            'version_major': values[1],
            'version_minor': values[2],
            'file_length': values[3],
            'xml_offset': values[4],
            'xml_length': values[5],
            'page_size': values[6]}


def get_xml(e57_path):
    """
    Read xml metadata from e57 file.

    :param e57_path: Path to the e57 to extract metadata from.
    :return: xml metadata ElementTree
    """
    xml_data = []
    with open(e57_path, 'rb') as f_handle:
        header = get_header(e57_path)
        payload_size = header['page_size'] - 4
        xml_page_count = ceil(
            (header['file_length'] - header['xml_offset']) / header[
                'page_size'])

        for pn in range(xml_page_count):
            if pn == 0:
                # Handle first page
                f_handle.seek(header['xml_offset'], 0)
                next_page_offset = header['page_size'] * \
                                   (int(header['xml_offset'] /
                                        header['page_size']) + 1)
                remaining_page_size = next_page_offset - header['xml_offset']
                xml_data.append(unpack(f'{remaining_page_size - 4}sI',
                                       f_handle.read(remaining_page_size))[0])
            elif pn == xml_page_count - 1:
                # Handle last page
                xml_end = header['xml_offset'] + header['xml_length'] + 4 * pn
                xml_remaining = header['page_size'] - (
                    header['file_length'] - xml_end)
                xml_data.append(unpack(f'<{xml_remaining}s',
                                       f_handle.read(xml_remaining))[0])
            else:
                # Handle middle pages
                xml_data.append(unpack(f'{payload_size}sI',
                                       f_handle.read(header['page_size']))[0])

    ElementTree.register_namespace('',
                                   "http://www.astm.org/COMMIT/E57/2010-e57-v1.0")
    root = ElementTree.fromstring(''.join(str(s, 'utf-8') for s in xml_data))

    for elem in root.iter():
        if elem.text is not None:
            elem.text = elem.text.strip()
        if elem.tail is not None:
            elem.tail = elem.tail.strip()

    return root
Jed
frooms
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Wed Apr 25, 2018 3:01 pm
4
Full Name: Filip Rooms
Company Details: Bricsys NV
Company Position Title: Research and Development point clouds
Country: Belgium
Linkedin Profile: Yes

Re: How do I retrieve the positional coords of the scanner from e57

Post by frooms »

Just a small extra question: I am able to retrieve all kinds of information from e57 files, but I am still a bit in doubt to distinguish scans with structured data grouped per scan position from data without scanner data.

Points are grouped and have pose info. No problem there.

However, to decide whether these data can be considered as actual scanner positions, I rely on prototype.isDefined("rowIndex"); and prototype.isDefined("columnIndex");

Is this the right approach? Or should these blocks per transform de facto always be considered a scan position
Post Reply

Return to “Request Help With Projects”