Skip to content

Commit

Permalink
v3.8.0 (bugfix integration with AutoStakkert!4, introduction of OpenCL)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcDelcroix committed Jan 10, 2024
1 parent 03797f4 commit cfe1f2c
Show file tree
Hide file tree
Showing 28 changed files with 263 additions and 223 deletions.
15 changes: 14 additions & 1 deletion DeTeCt-MFC/AutoUpdate.cpp
Expand Up @@ -659,7 +659,20 @@ BOOL AutoUpdate::Update_ini_parameters_resources_files(const SG_Version version_
update = TRUE;
}
if (!pre_update && ((SG_Version_number(version_current) == SG_Version_number(version_update)) || (force_all_updates && (SG_Version_number(version_current) <= SG_Version_number(version_update))))) {
WriteIni();
RemoveFile((CString)"opencv_ffmpeg2413_64.dll", log_cstring_lines);
update = TRUE;
}

version_update.Major = 3;
version_update.Minor = 8;
version_update.Revision = 0;
version_update.SubRevision = 0;
if (pre_update && (SG_Version_number(version_current) < SG_Version_number(version_update)) || (force_all_updates && (SG_Version_number(version_current) <= SG_Version_number(version_update)))) {
DownloadFile((CString)"opencv_world460.dll", log_cstring_lines);
DownloadFile((CString)"opencv_videoio_ffmpeg460_64.dll", log_cstring_lines);
update = TRUE;
}
if (!pre_update && ((SG_Version_number(version_current) == SG_Version_number(version_update)) || (force_all_updates && (SG_Version_number(version_current) <= SG_Version_number(version_update))))) {
RemoveFile((CString)"opencv_ffmpeg2413_64.dll", log_cstring_lines);
update = TRUE;
}
Expand Down
Binary file modified DeTeCt-MFC/DeTeCt-MFC.aps
Binary file not shown.
74 changes: 72 additions & 2 deletions DeTeCt-MFC/DeTeCt-MFC.cpp
Expand Up @@ -26,6 +26,11 @@ using namespace std;
std::string full_version;
std::string app_title;
std::string message[2048];
BOOL dev_mode = FALSE;
char dev_computer_name[MAX_STRING] = "Jupiter";
char dev_user_name[MAX_STRING] = "Marc";
char computer_name[MAX_STRING] = "";
char user_name[MAX_STRING] = "";

// CDeTeCtMFCApp

Expand Down Expand Up @@ -553,8 +558,8 @@ CreateQueueFileName(); // Also sets parent_instance - defines opts.DeTeCtQueueFi
if (opts.debug) MessageBox(NULL, _T("3 "), _T("Info 3"), MB_OK + MB_ICONWARNING + MB_SETFOREGROUND + MB_TOPMOST);
std::string folder_path;
// Defines folder path and logfilename
if (opts.autostakkert) folder_path = CString2string(DeTeCt_exe_folder()); //log directory when autostakkert mode is DeTeCt exe location
else folder_path = filename_acquisition.substr(0, filename_acquisition.find_last_of("\\"));
if ((opts.autostakkert) && (AS_IMPACT_DETECTION_DIR_DETECT)) folder_path = CString2string(DeTeCt_exe_folder()); //log directory when autostakkert mode is DeTeCt exe location if activvated
else folder_path = filename_acquisition.substr(0, filename_acquisition.find_last_of("\\"));
CT2A DeTeCtLogFilename(DeTeCt_additional_filename_from_folder((CString)folder_path.c_str(), DTC_LOG_SUFFIX));
std::string log_file(DeTeCtLogFilename);
// Pushed file to queue if to be processed
Expand Down Expand Up @@ -639,6 +644,71 @@ CreateQueueFileName(); // Also sets parent_instance - defines opts.DeTeCtQueueFi
message_lines[index_message] = "\0";
}


/* openCL configuration */
BOOL IsOpenCL_ok = TRUE;
cv::ocl::Context context = cv::ocl::Context::getDefault();
if (!context.ptr()) {
message_lines[index_message++] = "OpenCL not available";
message_lines[index_message] = "\0";
IsOpenCL_ok = FALSE;
}
else { //OpenCL available
cv::ocl::Device device = cv::ocl::Device::getDefault();
if (!device.compilerAvailable()) {
message_lines[index_message++] = "OpenCL not available (no compiler)";
message_lines[index_message] = "\0";
IsOpenCL_ok = FALSE;
}
else {
std::vector<cv::ocl::PlatformInfo> platforms;
cv::ocl::getPlatfomsInfo(platforms);
if (platforms.size() > 0) {
message_lines[index_message] = "OpenCL available: ";
for (size_t i = 0; i < platforms.size(); i++)
{
//Access to Platform
const cv::ocl::PlatformInfo* platform = &platforms[i];

//Platform Name
//std::cout << "Platform Name: " << platform->name().c_str() << "\n" << endl;
message_lines[index_message] += platform->name().c_str();
//Access Device within Platform
cv::ocl::Device current_device;
for (int j = 0; j < platform->deviceNumber(); j++)
{
//Access Device
platform->getDevice(current_device, j);
int deviceType = current_device.type();
message_lines[index_message] += ", device " + current_device.name();
switch (deviceType)
{
case 2:
message_lines[index_message] += " (" + to_string(context.ndevices()) + " CPU)\n";
//cout << "CPU device\n";
if (context.create(deviceType))
//opencl_mat(loc);//With OpenCL Mat
break;
case 4:
message_lines[index_message] += " (" + to_string(context.ndevices()) + " GPU)\n";
//cout << "GPU device\n";
if (context.create(deviceType))
//opencl_mat(loc);//With OpenCL UMat
break;
}
index_message++;
message_lines[index_message] = "\0";
cin.ignore(1);
}
}
}
}
}
if (IsOpenCL_ok) cv::ocl::setUseOpenCL(true);
message_lines[index_message] = "\0";
/* end of openCL configuration*/


// **********************************************************
// *********************** TEST *************************
// **********************************************************
Expand Down
Binary file modified DeTeCt-MFC/DeTeCt-MFC.rc
Binary file not shown.
6 changes: 3 additions & 3 deletions DeTeCt-MFC/DeTeCt-MFC.vcxproj
Expand Up @@ -141,7 +141,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>AFX_DESIGN_TIME;_WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>G:\opencv2\build\include;C:\ffmpeg\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>G:\opencv460\build\include;C:\ffmpeg\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>Default</CompileAs>
<FunctionLevelLinking>true</FunctionLevelLinking>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
Expand All @@ -153,8 +153,8 @@
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>G:\opencv2\build\x64\bin;G:\opencv2\build\x64\vc14\lib;G:\opencv2\build\x64\vc14\staticlib;G:\ffmpeg\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>opencv_core2413d.lib;opencv_highgui2413d.lib;opencv_imgproc2413d.lib;opencv_video2413d.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>G:\opencv460\build\x64\vc15\lib;%(AdditionalLibraryDirectories);G:\ffmpeg\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>opencv_world460.lib;opencv_world460d.lib;uafxcw.lib;libcmt.lib;vfw32.lib;shell32.lib;kernel32.lib</AdditionalDependencies>
<OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
<IgnoreSpecificDefaultLibraries>
Expand Down
6 changes: 3 additions & 3 deletions DeTeCt-MFC/DeTeCt-MFCDlg.cpp
Expand Up @@ -1093,7 +1093,7 @@ if (opts.debug) MessageBox(_T("Exit Child instance from AutoStakkert PID ") + CS
// ********* Ignores PIPP with no integrity
(!Is_PIPP(file) || ((Is_PIPP(file) && Is_PIPP_OK(file, &pipp_info, &ss))))) {
std::string folder_path;
if (!opts.autostakkert) folder_path = filename_acquisition.substr(0, filename_acquisition.find_last_of("\\"));
if ((!opts.autostakkert) || (!AS_IMPACT_DETECTION_DIR_DETECT)) folder_path = filename_acquisition.substr(0, filename_acquisition.find_last_of("\\"));
else {
//log directory when autostakkert mode or multi instance mode
folder_path = CString2string(DeTeCt_exe_folder());
Expand Down Expand Up @@ -1245,7 +1245,7 @@ void CDeTeCtMFCDlg::OnFileOpenFolder()
// ********* Ignores PIPP with no integrity
(!Is_PIPP(filename) || ((Is_PIPP(filename) && Is_PIPP_OK(filename, &pipp_info, &ss3))))) {
std::string folder_path_consolidated;
if (!opts.autostakkert) folder_path_consolidated = std::string (folder_path.begin(), folder_path.end());
if ((!opts.autostakkert) || (!AS_IMPACT_DETECTION_DIR_DETECT)) folder_path_consolidated = std::string (folder_path.begin(), folder_path.end());
else {
//log directory when autostakkert mode or multi instance mode
folder_path_consolidated = CString2string(DeTeCt_exe_folder());
Expand Down Expand Up @@ -2379,7 +2379,7 @@ void PrefDialog::OnDeltaposSpin12(NMHDR* pNMHDR, LRESULT* pResult)
void PrefDialog::OnDeltaposSpin13(NMHDR* pNMHDR, LRESULT* pResult)
{
float fMin = 0.0f;
float fMax = 1.0f;
float fMax = 2.0f;
float fStep = 0.05f;

LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
Expand Down
16 changes: 14 additions & 2 deletions DeTeCt-MFC/Version history.txt
Expand Up @@ -80,7 +80,7 @@ Algorithm: attempt to match impact candidates with brightest point in max-mean
check distance criteria (not working ?)
ignore bad centered images (part of ROI outside of fullframe)

ROI: Scan of 90 from cog to edge (for Saturn)
ROI: Scan of 90 from cog to edge (for Saturn)
Increase size of ROI (Martin)
TBD: Use as3 ROI

Expand Down Expand Up @@ -115,6 +115,18 @@ Autostakkert: Use of as3 file compatibility with AS3 subfolder default option (A
===============================================================================================================
VERSION HISTORY
===============================================================================================================
v3.8.1
Dev: Detection of developper to use specific configurations (eg no zip file)

v3.8.0 (bugfix integration with AutoStakkert!4, introduction of OpenCL)
Autostakkert: Info in log if launched from AS!
OpenCL: Check if available
OpenCL: First easy migrations from Mat to UMat
GUI: select folder button more understandable
GUI: instances "running" display
Bugfix: Space in full filename handling in AutoStakkert! session file
Bugfix: Bugfix security factor spin button

v3.7.3 (integration with Autostakkert 4)
Autostakkert: Integration with Autostakkert 4
Autostakkert: Force autoprocessing, no reprocessing and single instance in Autostakkert mode
Expand Down Expand Up @@ -363,7 +375,7 @@ Command line:-nozip option
Bugfix: zip file empty in automatic mode (L.Keith)
Bugfix: zip file empty when relative path use as parameter for directory or file
Bugfix: *.exe file tested when detect exe launched without the upper cases
Bugfix: accents (ie ) in directory name prevents image / directory creation
Bugfix: accents (ie ) in directory name prevents image / directory creation
--------------------------------------------------------------------------------------
v3.2 (/v3.1.12):
Algorithm: Check #of frames calculated from fps for impacts (duration 0.6s)
Expand Down
7 changes: 7 additions & 0 deletions DeTeCt-MFC/common2.cpp
Expand Up @@ -69,6 +69,13 @@ void lowercase_string(std::string *source) {
});
}

void trim_string(std::string& line) {
//while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
//while (line.find(' ') == 0) line.erase(line.find(' '), 1);
line.erase(0, line.find_first_not_of(' '));
line.erase(line.find_last_not_of(' ') + 1);
}

std::vector<std::string> read_txt(std::string path) {
std::ifstream file(path);
std::string line;
Expand Down
2 changes: 2 additions & 0 deletions DeTeCt-MFC/common2.hpp
Expand Up @@ -5,6 +5,7 @@
#include "dtc.h"
#include <vector>
//#include <string> // not needed
#include "opencv2/core/ocl.hpp"

#define FILEACCESS_WAIT_MS 50

Expand All @@ -28,6 +29,7 @@ std::string wstring2string(const std::wstring& wstr);
bool starts_with(const std::string& s1, const std::string& s2);
bool replace(std::string& str, const std::string& from, const std::string& to);
void lowercase_string(std::string* source);
void trim_string(std::string& line);
bool duplicate_txtfile(const CString InputFileName, const CString OutputFileName);
CString GetLine(HANDLE QueueFileHandle);
std::string StringPlural(const int number);
Expand Down
9 changes: 5 additions & 4 deletions DeTeCt-MFC/dtc.h
Expand Up @@ -6,7 +6,7 @@

#define PROGNAME "DeTeCt"
#define LONGNAME "jovian impact DeTeCtion"
#define VERSION_NB "3.7.3"
#define VERSION_NB "3.8.0"
#define VERSION_DATE "(Aug.26,2020)"

//#define VERSION_MSVC ""
Expand Down Expand Up @@ -61,10 +61,11 @@
#define PIPP_STRING "_pipp"
#define WJ_DEROT_STRING "-DeRot."

#define IGNORE_WJ_DEROTATION FALSE
#define IGNORE_PIPP FALSE
#define IGNORE_DARK TRUE
#define IGNORE_WJ_DEROTATION FALSE
#define IGNORE_PIPP FALSE
#define IGNORE_DARK TRUE

#define AS_IMPACT_DETECTION_DIR_DETECT FALSE
#ifdef __cplusplus
//extern "C" {
#endif
Expand Down
17 changes: 8 additions & 9 deletions DeTeCt-MFC/dtcas3.cpp
Expand Up @@ -72,32 +72,33 @@ void read_autostakkert_session_config_line(std::string line, std::string *filena
std::vector<std::string> lines;
float x, y;

while (line.find(' ') == 0) line.erase(line.find(' '), 1);
trim_string(line);
if (starts_with(line, "file")) {
line = line.substr(strlen("file"), line.length());
while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
// while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
trim_string(line);
*filename = line;
} else if (starts_with(line, "_frames_count")) {
line = line.substr(strlen("_frames_count"), line.length());
while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
trim_string(line);
std::istringstream ss(line);
ss >> x;
(*cm_frame_count) = (int)x;
} else if (starts_with(line, "_limit_min")) {
line = line.substr(strlen("_limit_min"), line.length());
while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
trim_string(line);
std::istringstream ss(line);
ss >> x;
(*cm_list_start) = (int) x;
} else if (starts_with(line, "_limit_max")) {
line = line.substr(strlen("_limit_max"), line.length());
while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
trim_string(line);
std::istringstream ss(line);
ss >> x;
(*cm_list_end) = (int)x;
} else if (starts_with(line, "_limit_active")) {
line = line.substr(strlen("_limit_active"), line.length());
while (line.find(' ') != std::string::npos) line.erase(line.find(' '), 1);
trim_string(line);
if (line == "False") {
(*cm_list_start) = 0;
(*cm_list_end) = 999999;
Expand Down Expand Up @@ -250,6 +251,4 @@ BOOL IsParentDeTeCt(DWORD *pASpid)
BOOL IsParentAutostakkertRunning(const DWORD ASpid)
{
return IsProcessRunning(ASpid);
}


}

0 comments on commit cfe1f2c

Please sign in to comment.