Project

General

Profile

Actions

Support Request #5661

closed

DAT Tool Processor example not working

Added by hidden about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Customer:
BOSCH
Department:
Requester's Priority:
Normal
Support Level:
3rd Level
Resolution:
Workaround Available
Product Issue Numbers:
Platform:
Windows 7 64bit
Topic:
ADTF::Guides
FAQ Links:

Description

*Supportanfrage

I have tried to build and run the following example:
https://support.digitalwerk.net/adtf/v3/guides/tutorial_dat_tool_processor.html

But when the adtf_dattool_gui tool tried to load the processor files, I got the error message attached.
The processor does not appear in the list, I have tried it with the example_file.adtfdat as well.

Thank you for your help!

Lösung

The interfaces from ADTF File Library are changed in v0.4.0 which is required by ADTF DAT GUI Tools.
You are facing two problems:

Firtst it is not working with ADTF 3.3.3 because it delivers ADTF File Library 0.2.1.
You have to build ADTF File Library 0.4.0 by yourself
Or wait for ADTF 3.4.0 which delivers ADTF File Library 0.4.0.

Second problem, the guide is out of date, will be solved by ADTF 3.4.0 delivery.
The code must be adapted as follows:

image_processor.cpp

Now I can choose the image processor in the drop down box inside the ADTF DAT Tool GUI.
A last note:
Make sure that the folder "bin/plugins/imageformats" contains the qjpeg.dll plugin. Otherwise Qt can't create jpg images.


Files

2019-01-11_14h18_25.png (28.4 KB) 2019-01-11_14h18_25.png Error message hidden, 2019-01-11 14:21
Actions #1

Updated by hidden about 5 years ago

  • Project changed from Public Support to 5
  • Status changed from New to In Progress
  • Topic set to ADTF::Guides

Hi Gergo,

thanks for your feedback.

Please keep in mind the Dat Tools 0.1 are the initial delivery and maybe some relations are not working yet.

Regarding your use case, i guess the Online version of ADTF 3.x Guides are out of date, because we are currently rework them for ADTF 3.4 (in which they we also be delivered).
Maybe some relations with ADTF File Library and ADTF/Dat Tools are no longer supported.

@Volker: Can you please check the issue with the combination ADTF 3.3.3, Dat Tools 0.1.0 and the documentation.
Please give the customer a hint how to solve the problem or provide the current and working guide page as attachment.

Actions #2

Updated by hidden about 5 years ago

1. Installed ADTF 3.3.3 and adtfdatguitools-0.1.0 from the digitalwerk download pages.
2. Tried to follow the steps from the online Guides
3. Setup with CMake - okay
4. Building source code with Visual Studio in debug mode - okay, but we need to build in release mode, because the download of adtfdatguitools-0.1.0 has no debug version
5. Building source code with Visual Studio in release mode - failed with this error message:

1>------ Build started: Project: ZERO_CHECK, Configuration: Release x64 ------
1>  Checking Build System
1>  CMake does not need to re-run because E:/tmp/Ticket5661/build/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: image_processor, Configuration: Release x64 ------
2>  Building Custom Rule E:/tmp/Ticket5661/CMakeLists.txt
2>  CMake does not need to re-run because E:/tmp/Ticket5661/build/CMakeFiles/generate.stamp is up-to-date.
2>  image_processor.cpp
2>adtf_filed_x64_msvc140.lib(object.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in image_processor.obj
2>adtf_filed_x64_msvc140.lib(object.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in image_processor.obj
2>adtf_filed_x64_msvc140.lib(object_plugin.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in image_processor.obj
2>adtf_filed_x64_msvc140.lib(object_plugin.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in image_processor.obj
2>a_util_filesystemd_x64_msvc140.lib(path.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in image_processor.obj
2>a_util_filesystemd_x64_msvc140.lib(path.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in image_processor.obj
2>a_util_filesystemd_x64_msvc140.lib(filesystem.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in image_processor.obj
2>a_util_filesystemd_x64_msvc140.lib(filesystem.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in image_processor.obj
2>a_util_stringsd_x64_msvc140.lib(unicode.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in image_processor.obj
2>a_util_stringsd_x64_msvc140.lib(unicode.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in image_processor.obj
2>     Creating library E:/tmp/Ticket5661/build/Release/image_processor.lib and object E:/tmp/Ticket5661/build/Release/image_processor.exp
2>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
2>adtf_filed_x64_msvc140.lib(object.obj) : error LNK2019: unresolved external symbol __imp__invalid_parameter referenced in function "void * __cdecl std::_Allocate(unsigned __int64,unsigned __int64,bool)" (?_Allocate@std@@YAPEAX_K0_N@Z)
2>a_util_filesystemd_x64_msvc140.lib(path.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
2>a_util_filesystemd_x64_msvc140.lib(filesystem.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
2>a_util_stringsd_x64_msvc140.lib(unicode.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
2>adtf_filed_x64_msvc140.lib(object.obj) : error LNK2019: unresolved external symbol __imp__CrtDbgReportW referenced in function "void * __cdecl std::_Allocate(unsigned __int64,unsigned __int64,bool)" (?_Allocate@std@@YAPEAX_K0_N@Z)
2>a_util_filesystemd_x64_msvc140.lib(path.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
2>a_util_filesystemd_x64_msvc140.lib(filesystem.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
2>a_util_stringsd_x64_msvc140.lib(unicode.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
2>E:\tmp\Ticket5661\build\Release\image_processor.adtffileplugin : fatal error LNK1120: 2 unresolved externals
3>------ Build started: Project: ALL_BUILD, Configuration: Release x64 ------
3>  Building Custom Rule E:/tmp/Ticket5661/CMakeLists.txt
3>  CMake does not need to re-run because E:/tmp/Ticket5661/build/CMakeFiles/generate.stamp is up-to-date.
4>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
4>Project not selected to build for this solution configuration 
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

Lösung für das obige Linkerproblem:
In Visual Studio im Modus "RelWithDebInfo" anstselle von "Release" bauen.

Weiters Vorgehen:
- Abhängigkeiten zu a_util, ddl und adtfdat_processing aktualisieren
Dazu die adtf_file-library in Version beta-0.4.0 hier herunterladen
- Jetzt die heruntergeladenen Sourcen mit CMake konfigurieren und mit Visual Studio im Modus ReleaseWithDebInfo bauen
Reihenfolge:
a_util
ddl
adtf_file
- CMake-Cache und build-Verzeichnis vom ursprünglichen Processor-Projekt löschen
- CMake-Pfade zu a_util, ddl und adtfdat_processing aktualisieren
- image_processor.cpp akutalisieren (Hier haben sich die Groß-/Kleinschreibung einiger Interface-Methoden und ein paar Import-Anweisungen geändert)

#include <adtf_file/stream_type.h>
#include <adtf_file/sample.h>
#include <ddl.h>
#include <iostream>
#include <string>
#include <unordered_map>

#include <QImage>
#include <QString>

#include "image_processor.h" 

// Some how this call implemetns adtf_file_is_debug_plugin and adtf_file_set_objects
static adtf_file::PluginInitializer initializer([] {
    adtf_file::getObjects().push_back(
        std::make_shared<adtf::dat::ProcessorFactoryImplementation<ImageProcessor>>());
});

ImageProcessor::ImageProcessor()
{
    sampleCounter = 0ULL;
    height = 0;
    width = 0;

    int dummy_argc = 0;
    char** dummy_argv = new char*[0];

    // To save images with the help of Qt we needed to
    // load the plugins for different image formats and
    // this is what QCoreApplication does for us.
    app = QCoreApplication::instance();
    if (app == nullptr)
    {
        app = new QCoreApplication(dummy_argc, dummy_argv);
    }

    // Set all configuration options
    setConfiguration({
        { "output_path",{ "images", "string" } },
        { "output_img_format",{ "JPG", "string" } },
        { "extraction_interval",{ "100", "uint64" } }
    });

}

ImageProcessor::~ImageProcessor()
{
}

std::string ImageProcessor::getProcessorIdentifier() const
{
    return "image";
}

bool ImageProcessor::isCompatible(const adtf_file::Stream& stream) const
{
    auto tmp = std::dynamic_pointer_cast<const adtf_file::DefaultStreamType>(stream.initial_type);
    if (tmp)
    {
        return tmp->getMetaType().compare("adtf/image") == 0;
    }
    else {
        return false;
    }
}

void ImageProcessor::open(const adtf_file::Stream& stream, const std::string& destination_file_name)
{
    auto property_type = std::dynamic_pointer_cast<const adtf_file::PropertyStreamType>(stream.initial_type);
    if (!property_type)
    {
        throw std::runtime_error("The stream " + stream.name +
            " could not cast initial_type of stream to PropertyStreamType");
    }
    std::cout << "Stream type: " << property_type->getMetaType() << std::endl;

    // Some debug output
    property_type->IterateProperties([](const char* a, const char* b, const char* c) {std::cout << a << ": " << c << "  -  Datatype: " << b << std::endl; });
    std::string w = property_type->getProperty("pixel_width").second;
    std::string h = property_type->getProperty("pixel_height").second;
    width = std::stoi(w);
    height = std::stoi(h);

    // Make use of the settings
    extraction_interval = adtf::dat::getPropertyValue<uint64_t>(getConfiguration(), "extraction_interval");
    output_path = adtf::dat::getPropertyValue<std::string>(getConfiguration(), "output_path");
    // Does the folder exist?
    if (!a_util::filesystem::exists(output_path))
    {
        a_util::filesystem::createDirectory(output_path);
    }
    output_img_format = adtf::dat::getPropertyValue<std::string>(getConfiguration(), "output_img_format");
}

void ImageProcessor::process(const adtf_file::FileItem& item)
{
    auto sample = std::dynamic_pointer_cast<const adtf_file::WriteSample>(item.stream_item);
    if (sample)
    {
        if (sampleCounter > 0 && (sampleCounter % extraction_interval == 0)) {
            auto buffer = sample->beginBufferRead();
            uchar* dest = new uchar[buffer.second];
            std::memcpy(dest, buffer.first, buffer.second);
            // Extract the image from the sample
            QImage img = QImage(dest, width, height, QImage::Format_Grayscale8);

            std::string ts = output_path + "/" + std::to_string(sample->getTimeStamp().count()) + "." + output_img_format;
            const QString generated_image_name(ts.c_str());
            img.save(generated_image_name, output_img_format.c_str());
        }
    }
    sampleCounter++;
}

Now I can choose the image processor in the drop down box inside the ADTF DAT Tool GUI.
A last note:
Make sure that the folder "bin/plugins/imageformats" contains the qjpeg.dll plugin. Otherwise Qt can't create jpg images.

Do these instructions work for you as well?

Actions #3

Updated by hidden about 5 years ago

  • Support Level changed from 2nd Level to 3rd Level
Actions #4

Updated by hidden about 5 years ago

Hi guys!

Yes, updating the libraries to the newest versions solved the issue.

Thanks for your help!

Actions #5

Updated by hidden about 5 years ago

  • Description updated (diff)
  • Status changed from In Progress to To Be Closed
  • Resolution set to Workaround Available
Actions #6

Updated by hidden about 5 years ago

  • Project changed from 5 to Public Support
  • Status changed from To Be Closed to Closed
  • Private changed from Yes to No
Actions #7

Updated by hidden about 5 years ago

  • Description updated (diff)
Actions

Also available in: Atom PDF