Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
[![License](https://img.shields.io/github/license/SolARFramework/Sample-Slam?style=flat-square&label=License)](https://www.apache.org/licenses/LICENSE-2.0)


This project is a tool that allows to create a fbow vocabulary from a set of images
This project is a tool that allows to create a fbow vocabulary from a set of images.

## How to run

### Data installation

You can run installData.bat (under windows) or installData.sh (under linux) to download a small example dataset of about 1000 images, as well as two camera calibration files necessary to run the code. The file camera_calibration_1344x756.json corresponds to the original image resolution. If you use the other file camera_calibration_640x480.json, the input images will be resized to 640x480 before the FBOW generation. Note that in both cases, only the width and height are used. In fact, without such a calibration file, **SolARImagesAsCameraOpencv** will not work. That is why we need these two calibration files.

### Configuration

Open the configuration file and set the **imagesDirectoryPath** value of the **SolARImagesAsCameraOpencv** to your path to images.
You can also configure the type of feature (e.g. AKAZE2, ORB, SIFT,...) that you want to use to create your fbow vocabulary.
Go to the binary directory and open the configuration file SolARTool_FBOWCreator_conf.xml. You can set the **imagesDirectoryPath** value of the **SolARImagesAsCameraOpencv** to your path to images. By default, it has already been set to the downloaded dataset folder (after running installData.bat or installData.sh).
You can also configure the type of feature (e.g. AKAZE2, ORB, SIFT, PopSift, ...) that you want to use to create your fbow vocabulary.

### More Datasets

It is recommanded to use a larger database in order to generate better vocabularies. You can download public image databases or use your own datasets. For example, you can download the 7-Scenes dataset (https://www.microsoft.com/en-us/research/project/rgb-d-dataset-7-scenes/). Please remember to modify **imagesDirectoryPath** in SolARTool_FBOWCreator_conf.xml beforing running the code.


### Run samples

Expand All @@ -20,6 +29,9 @@ You can also configure the type of feature (e.g. AKAZE2, ORB, SIFT,...) that you
* To see more details run:
<pre><code>SolARTool_FBOWCreator.exe -h</code></pre>

* For example, if you want to generate fbow dictionary for PopSift:
<pre><code>.\SolARTool_FBOWCreator.exe --config=.\SolARTool_FBOWCreator_PopSift_conf.xml --out=popsift_uint8.fbow --v=1</code></pre>

## Contact
Website https://solarframework.github.io/

Expand Down
24 changes: 13 additions & 11 deletions tools/SolARTool_FBOWCreator/SolARTool_FBOWCreator.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
QT -= core gui
CONFIG -= qt

QMAKE_PROJECT_DEPTH = 0

## global defintions : target lib name, version
TARGET = SolARTool_FBOWCreator
VERSION=1.0.0
PROJECTDEPLOYDIR = $${PWD}/../deploy

DEFINES += MYVERSION=$${VERSION}
CONFIG += c++1z
Expand All @@ -13,18 +16,16 @@ CONFIG += console
include(findremakenrules.pri)

CONFIG(debug,debug|release) {
TARGETDEPLOYDIR = $${PWD}/../bin/Debug
DEFINES += _DEBUG=1
DEFINES += DEBUG=1
}

CONFIG(release,debug|release) {
TARGETDEPLOYDIR = $${PWD}/../bin/Release
DEFINES += _NDEBUG=1
DEFINES += NDEBUG=1
}

DEPENDENCIESCONFIG = sharedlib install_recurse
DEPENDENCIESCONFIG = shared install_recurse

win32:CONFIG -= static
win32:CONFIG += shared
Expand All @@ -35,17 +36,17 @@ PROJECTCONFIG = QTVS
#NOTE : CONFIG as staticlib or sharedlib, DEPENDENCIESCONFIG as staticlib or sharedlib, QMAKE_TARGET.arch and PROJECTDEPLOYDIR MUST BE DEFINED BEFORE templatelibconfig.pri inclusion
include ($$shell_quote($$shell_path($${QMAKE_REMAKEN_RULES_ROOT}/templateappconfig.pri))) # Shell_quote & shell_path required for visual on windows

#DEFINES += BOOST_ALL_NO_LIB
DEFINES += BOOST_ALL_DYN_LINK
DEFINES += BOOST_AUTO_LINK_NOMANGLE
DEFINES += BOOST_LOG_DYN_LINK
HEADERS += \

SOURCES += \
main.cpp

unix {
LIBS += -ldl
QMAKE_CXXFLAGS += -DBOOST_LOG_DYN_LINK

# Avoids adding install steps manually. To be commented to have a better control over them.
QMAKE_POST_LINK += "make install install_deps"
}

linux {
Expand All @@ -69,7 +70,7 @@ win32 {
INCLUDEPATH += $$(WINDOWSSDKDIR)lib/winv6.3/um/x64
}

unix {
linux {
run_install.path = $${TARGETDEPLOYDIR}
run_install.files = $${PWD}/../run.sh
CONFIG(release,debug|release) {
Expand All @@ -83,12 +84,13 @@ unix {

configfile.path = $${TARGETDEPLOYDIR}/
configfile.files = $$files($${PWD}/SolARTool_FBOWCreator_conf.xml)\
$$files($${PWD}/camera_calibration.json)
$$files($${PWD}/SolARTool_FBOWCreator_PopSift_conf.xml)
INSTALLS += configfile

OTHER_FILES += \
DISTFILES += \
packagedependencies.txt \
SolARTool_FBOWCreator_conf.xml
SolARTool_FBOWCreator_conf.xml \
SolARTool_FBOWCreator_PopSift_conf.xml

#NOTE : Must be placed at the end of the .pro
include ($$shell_quote($$shell_path($${QMAKE_REMAKEN_RULES_ROOT}/remaken_install_target.pri)))) # Shell_quote & shell_path required for visual on windows
93 changes: 93 additions & 0 deletions tools/SolARTool_FBOWCreator/SolARTool_FBOWCreator_PopSift_conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<xpcf-registry autoAlias="true">
<module uuid="15e1990b-86b2-445c-8194-0cbe80ede970" name="SolARModuleOpenCV" description="SolARModuleOpenCV" path="$XPCF_MODULE_ROOT/SolARBuild/SolARModuleOpenCV/1.0.0/lib/x86_64/shared">
<component uuid="5B7396F4-A804-4F3C-A0EB-FB1D56042BB4" name="SolARCameraOpencv" description="SolARCameraOpencv">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="5DDC7DF0-8377-437F-9C81-3643F7676A5B" name="ICamera" description="ICamera"/>
</component>
<component uuid="b8a8b963-ba55-4ea4-b045-d9e7e8f6db02" name="SolARImagesAsCameraOpencv" description="SolARImagesAsCameraOpencv">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="5DDC7DF0-8377-437F-9C81-3643F7676A5B" name="ICamera" description="ICamera"/>
</component>
<component uuid="fa4a780a-9720-11e8-9eb6-529269fb1459" name="SolARVideoAsCameraOpencv" description="SolARVideoAsCameraOpencv">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="5DDC7DF0-8377-437F-9C81-3643F7676A5B" name="ICamera" description="ICamera"/>
</component>
<component uuid="cc51d685-9797-4ffd-a9dd-cec4f367fa6a" name="SolAR2DOverlayOpencv" description="SolAR2DOverlayOpencv">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="62b8b0b5-9344-40e6-a288-e609eb3ff0f1" name="I2DOverlay" description="I2DOverlay"/>
</component>
<component uuid="19ea4e13-7085-4e3f-92ca-93f200ffb01b" name="SolARImageViewerOpencv" description="SolARImageViewerOpencv">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="b05f3dbb-f93d-465c-aee1-fb58e1480c42" name="IImageViewer" description="IImageViewer"/>
</component>
<component uuid="fd7fb607-144f-418c-bcf2-f7cf71532c22" name="SolARImageConvertorOpencv" description="SolARImageConvertorOpencv">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="9c982719-6cb4-4831-aa88-9e01afacbd16" name="IImageConvertor" description="IImageLoader"/>
</component>
</module>
<module uuid="4a43732c-a1b2-11eb-bcbc-0242ac130002" name="SolARModulePopSift" description="SolARModulePopSift" path="$XPCF_MODULE_ROOT/SolARBuild/SolARModulePopSift/1.0.0/lib/x86_64/shared">
<component uuid="7fb2aace-a1b1-11eb-bcbc-0242ac130002" name="SolARDescritorsExtractorFromImagePopSift" description="SolARDescritorsExtractorFromImagePopSift">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="1cd4f5f1-6b74-413b-9725-69653aee48ef" name="IDescriptorsExtractorFromImage" description="IDescriptorsExtractorFromImage"/>
</component>
</module>

<factory>
<bindings>
<!--bind interface="ICamera" to="SolARCameraOpencv"/-->
<bind interface="ICamera" to="SolARImagesAsCameraOpencv"/>
<!--bind interface="ICamera" to="SolARVideoAsCameraOpencv"/-->
<bind interface="IDescriptorsExtractorFromImage" to="SolARDescritorsExtractorFromImagePopSift" />
</bindings>
<injects>
<inject to="SolARDescritorsExtractorFromImagePopSift">
<bind interface="IImageConvertor" to="SolARImageConvertorOpencv"/>
</inject>
</injects>
</factory>

<properties>
<configure component="SolARCameraOpencv">
<property name="calibrationFile" type="string" value="../../../../../data/camera_calibration_640x480.json"/>
<property name="deviceID" type="uint" value="1"/>
</configure>
<configure component="SolARImagesAsCameraOpencv">
<property name="calibrationFile" type="string" value="../../../../../data/camera_calibration_640x480.json"/>
<property name="imagesDirectoryPath" type="string" value="../../../../../data/datafbow/%08d.jpg"/>
<property name="delayTime" type="int" value="30"/>
</configure>
<configure component="SolARVideoAsCameraOpencv">
<property name="calibrationFile" type="string" value="../../../../../data/camera_calibration_640x480.json"/>
<property name="videoPath" type="string" value="path to video"/>
<property name="delayTime" type="int" value="30"/>
</configure>
<configure component="SolARDescritorsExtractorFromImagePopSift">
<property name="mode" type="string" value="PopSift"/>
<property name="imageMode" type="string" value="Unsigned Char"/>
<property name="nbOctaves" type="int" value="3"/>
<property name="nbLevelPerOctave" type="int" value="3"/>
<property name="sigma" type="float" value="1.6"/>
<property name="threshold" type="float" value="0.001"/>
<property name="edgeLimit" type="float" value="10.0"/>
<property name="downsampling" type="float" value="-1.0"/>
<property name="initialBlur" type="float" value="-1.0"/>
<property name="maxTotalKeypoints" type="uint" value="1000"/>
</configure>
<configure component="SolAR2DOverlayOpencv">
<property name="thickness" type="uint" value="1"/>
<property name="radius" type="uint" value="2"/>
<property name="color" type="uint">
<value>0</value>
<value>255</value>
<value>0</value>
</property>
</configure>
<configure component="SolARImageViewerOpencv">
<property name="title" type="string" value="AR device mapping. Green = inliers, Red = outliers"/>
<property name="exitKey" type="int" value="27"/>
<property name="width" type="int" value="640"/>
<property name="height" type="int" value="480"/>
</configure>
</properties>
</xpcf-registry>
26 changes: 4 additions & 22 deletions tools/SolARTool_FBOWCreator/SolARTool_FBOWCreator_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@
<interface uuid="9c982719-6cb4-4831-aa88-9e01afacbd16" name="IImageConvertor" description="IImageLoader"/>
</component>
</module>
<module uuid="4a43732c-a1b2-11eb-bcbc-0242ac130002" name="SolARModulePopSift" description="SolARModulePopSift" path="$XPCF_MODULE_ROOT/SolARBuild/SolARModulePopSift/1.0.0/lib/x86_64/shared">
<component uuid="7fb2aace-a1b1-11eb-bcbc-0242ac130002" name="SolARDescritorsExtractorFromImagePopSift" description="SolARDescritorsExtractorFromImagePopSift">
<interface uuid="125f2007-1bf9-421d-9367-fbdc1210d006" name="IComponentIntrospect" description="IComponentIntrospect"/>
<interface uuid="1cd4f5f1-6b74-413b-9725-69653aee48ef" name="IDescriptorsExtractorFromImage" description="IDescriptorsExtractorFromImage"/>
</component>
</module>

<factory>
<bindings>
Expand All @@ -74,16 +68,16 @@

<properties>
<configure component="SolARCameraOpencv">
<property name="calibrationFile" type="string" value="camera_calibration.json"/>
<property name="calibrationFile" type="string" value="../../../../../data/camera_calibration_640x480.json"/>
<property name="deviceID" type="uint" value="1"/>
</configure>
<configure component="SolARImagesAsCameraOpencv">
<property name="calibrationFile" type="string" value="camera_calibration.json"/> <!--path to calibration file"/-->
<property name="imagesDirectoryPath" type="string" value="../../../datafbow/%06d.png"/> <!--path to images"/-->
<property name="calibrationFile" type="string" value="../../../../../data/camera_calibration_640x480.json"/>
<property name="imagesDirectoryPath" type="string" value="../../../../../data/datafbow/%08d.jpg"/>
<property name="delayTime" type="int" value="30"/>
</configure>
<configure component="SolARVideoAsCameraOpencv">
<property name="calibrationFile" type="string" value="camera_calibration.json"/>
<property name="calibrationFile" type="string" value="../../../../../data/camera_calibration_640x480.json"/>
<property name="videoPath" type="string" value="path to video"/>
<property name="delayTime" type="int" value="30"/>
</configure>
Expand All @@ -107,18 +101,6 @@
<property name="nbFeatures" type="int" value="3000"/>
<property name="nbOctaveLayers" type="int" value="3"/>
</configure>
<configure component="SolARDescritorsExtractorFromImagePopSift">
<property name="mode" type="string" value="PopSift"/>
<property name="imageMode" type="string" value="Unsigned Char"/>
<property name="nbOctaves" type="int" value="3"/>
<property name="nbLevelPerOctave" type="int" value="3"/>
<property name="sigma" type="float" value="1.0"/>
<property name="threshold" type="float" value="0.005"/>
<property name="edgeLimit" type="float" value="10.0"/>
<property name="downsampling" type="float" value="1.0"/>
<property name="initialBlur" type="float" value="-1.0"/>
<property name="maxTotalKeypoints" type="uint" value="10000"/>
</configure>
<configure component="SolAR2DOverlayOpencv">
<property name="thickness" type="uint" value="1"/>
<property name="radius" type="uint" value="2"/>
Expand Down
29 changes: 0 additions & 29 deletions tools/SolARTool_FBOWCreator/camera_calibration.json

This file was deleted.

23 changes: 12 additions & 11 deletions tools/SolARTool_FBOWCreator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const cv::String keys =
"{k|10| number of cluster at each node}"
"{l|6| number of levels}"
"{t|8| number of threads to accelerate}"
"{maxIters|5000| number of maximal iterations at each node}"
"{maxIters|2000| number of maximal iterations at each node}"
"{v|0| verbose}"
;

Expand Down Expand Up @@ -102,14 +102,6 @@ int main(int argc, char *argv[])
return -1;
}

// Start camera capture
if (camera->start() == FrameworkReturnCode::_ERROR_)
{
LOG_ERROR("Cannot start loader");
return -1;
}
LOG_INFO("Data loader started!");

// Get and set camera intrinsics parameters
CameraParameters camParams;
camParams = camera->getParameters();
Expand All @@ -118,6 +110,15 @@ int main(int argc, char *argv[])
LOG_INFO("Resolution of image: {} x {}", width, height);
std::string descName = descriptorExtractorFromImage->getTypeString();
LOG_INFO("Feature type: {}", descName);
camera->setResolution({width, height});

// Start camera capture
if (camera->start() == FrameworkReturnCode::_ERROR_)
{
LOG_ERROR("Cannot start loader");
return -1;
}
LOG_INFO("Data loader started!");

// Feature extraction
std::vector<SRef<DescriptorBuffer>> imageDescriptors;
Expand All @@ -143,8 +144,8 @@ int main(int argc, char *argv[])
if (descriptorExtractorFromImage->extract(greyImage, keypoints, descriptors) != FrameworkReturnCode::_SUCCESS)
continue;
imageDescriptors.push_back(descriptors);
//LOG_INFO("Image {} - Number of features: {}\r", count, keypoints.size());
std::cout << "Process frame " << count << "\r";
if (bVerbose)
LOG_INFO("Image {} - Size {}x{} - Number of features: {}\r", count, greyImage->getWidth(), greyImage->getHeight(), keypoints.size());
count++;
// display image
overlay2D->drawCircles(keypoints, image);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
opencv|4.5.5|opencv|conan-solar@conan|conan-solar|default|dnn=False#world=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

world=True no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked at moduleopencv
opencv|4.5.5|opencv|conan-solar@conan|conan-solar#https://repository.solarframework.org/conan#0|default|dnn=False#with_ade=False

We replace world=True by with_ade=False here ?

opencv|4.5.5|opencv|conan-solar@conan|conan-solar#https://repository.solarframework.org/conan#0|default|dnn=False#world=True
5 changes: 1 addition & 4 deletions tools/SolARTool_FBOWCreator/packagedependencies-linux.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
libgtk2.0-dev||libgtk2.0-dev|apt-get@system|apt-get
libva-dev||libva-dev|apt-get@system|apt-get
libvdpau-dev||libvdpau-dev|apt-get@system|apt-get
opencv|4.5.5|opencv|conan-solar@conan|conan-solar|default|with_gtk=True#gtk_version=system#with_ffmpeg=True
opencv|4.5.5|opencv|conan-solar@conan|conan-solar|default|
2 changes: 1 addition & 1 deletion tools/SolARTool_FBOWCreator/packagedependencies-mac.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
opencv|4.5.5|opencv|conan-solar@conan|conan-solar
opencv|4.5.5|opencv|conan-solar@conan|conan-solar#https://repository.solarframework.org/conan#0

2 changes: 1 addition & 1 deletion tools/SolARTool_FBOWCreator/packagedependencies-win.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
opencv|4.5.5|opencv|conan-solar@conan|conan-solar
opencv|4.5.5|opencv|conan-solar@conan|conan-solar|default|with_ffmpeg=False
1 change: 1 addition & 0 deletions tools/SolARTool_FBOWCreator/packagedependencies.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SolARFramework|1.0.0|SolARFramework|SolARBuild@github|https://github.com/SolarFramework/SolarFramework/releases/download
SolARModuleOpenCV|1.0.0|SolARModuleOpenCV|SolARBuild@github|https://github.com/SolarFramework/SolarModuleOpenCV/releases/download
SolARModulePopSift|1.0.0|SolARModulePopSift|SolARBuild@github|https://github.com/SolarFramework/SolARModulePopSift/releases/download
fbowSolAR|1.0.0|fbowSolAR|thirdParties@github|https://github.com/SolarFramework/fbow/releases/download
7 changes: 7 additions & 0 deletions tools/installData.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off
:: Download fbow data
echo Download fbow database for vocabulary generation
curl https://repository.solarframework.org/generic/data-solar/datafbowLoopDesktopA.zip -L -o datafbowLoopDesktopA.zip
echo Unzip fbow data
powershell Expand-Archive datafbowLoopDesktopA.zip -DestinationPath .\data -F
del datafbowLoopDesktopA.zip
6 changes: 3 additions & 3 deletions tools/installData.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Download image dataset
curl https://repository.solarframework.org/generic/data-solar/datafbow.zip -L -o datafbow.zip
unzip -o datafbow.zip -d ./
rm datafbow.zip
curl https://repository.solarframework.org/generic/data-solar/datafbowLoopDesktopA.zip -L -o datafbowLoopDesktopA.zip
unzip -o datafbowLoopDesktopA.zip -d ./data
rm datafbowLoopDesktopA.zip