Skip to content

Commit

Permalink
'fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
xuncv committed Oct 11, 2021
1 parent f40b1f8 commit 8113231
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/OpenCvSharpExtern.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ copy "$(SolutionDir)opencv_files\opencv452_win_x64\x64\vc16\bin\opencv_videoio_f
<ClCompile Include="imgproc.cpp" />
<ClCompile Include="img_hash.cpp" />
<ClCompile Include="line_descriptor.cpp" />
<ClCompile Include="logger.cpp" />
<ClCompile Include="ml.cpp" />
<ClCompile Include="objdetect.cpp" />
<ClCompile Include="flann.cpp" />
Expand Down Expand Up @@ -299,6 +300,7 @@ copy "$(SolutionDir)opencv_files\opencv452_win_x64\x64\vc16\bin\opencv_videoio_f
<ClInclude Include="img_hash.h" />
<ClInclude Include="include_opencv.h" />
<ClInclude Include="line_descriptor.h" />
<ClInclude Include="logger.h" />
<ClInclude Include="ml.h" />
<ClInclude Include="ml_ANN_MLP.h" />
<ClInclude Include="ml_Boost.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/OpenCvSharpExtern.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<ClCompile Include="custom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="logger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="bgsegm.h">
Expand Down Expand Up @@ -384,6 +387,9 @@
<ClInclude Include="custom.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="logger.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
Expand Down
2 changes: 1 addition & 1 deletion src/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void putTextZH(Mat dst, const char* str, Point org, Scalar color, int fontSize,
{
for (int n = 0; n < dst.channels(); ++n) {
double vtxt = subStr[n] / 255.0;
int cvv = vtxt * color.val[n] + (1 - vtxt) * subImg[n];
int cvv = (int)(vtxt * color.val[n] + (1 - vtxt) * subImg[n]);
subImg[n] = cvv > 255 ? 255 : (cvv < 0 ? 0 : cvv);
}

Expand Down
14 changes: 7 additions & 7 deletions src/imgproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,10 @@ CVAPI(ExceptionStatus) imgproc_connectedComponentsWithStats(cv::_InputArray *ima
}

CVAPI(ExceptionStatus) imgproc_findContours1_vector(cv::_InputArray *image, std::vector<std::vector<cv::Point> > *contours,
std::vector<cv::Vec4i> *hierarchy, int mode, int method, MyCvPoint offset)
std::vector<cv::Vec4i> *hierarchy, int mode, int method, MyCvPoint *offset)
{
BEGIN_WRAP
cv::findContours(*image, *contours, *hierarchy, mode, method, cpp(offset));
cv::findContours(*image, *contours, *hierarchy, mode, method, cpp(*offset));
END_WRAP
}
CVAPI(ExceptionStatus) imgproc_findContours1_OutputArray(cv::_InputArray *image, std::vector<cv::Mat> *contours,
Expand All @@ -694,10 +694,10 @@ CVAPI(ExceptionStatus) imgproc_findContours1_OutputArray(cv::_InputArray *image,
END_WRAP
}
CVAPI(ExceptionStatus) imgproc_findContours2_vector(cv::_InputArray *image, std::vector<std::vector<cv::Point> > *contours,
int mode, int method, MyCvPoint offset)
int mode, int method, MyCvPoint *offset)
{
BEGIN_WRAP
cv::findContours(*image, *contours, mode, method, cpp(offset));
cv::findContours(*image, *contours, mode, method, cpp(*offset));
END_WRAP
}
CVAPI(ExceptionStatus) imgproc_findContours2_OutputArray(cv::_InputArray *image, std::vector<cv::Mat> *contours,
Expand Down Expand Up @@ -1306,8 +1306,8 @@ CVAPI(ExceptionStatus) imgproc_polylines_InputOutputArray(

CVAPI(ExceptionStatus) imgproc_drawContours_vector(cv::_InputOutputArray *image,
cv::Point **contours, int contoursSize1, int *contoursSize2,
int contourIdx, MyCvScalar color, int thickness, int lineType,
cv::Vec4i *hierarchy, int hiearchyLength, int maxLevel, MyCvPoint offset)
int contourIdx, MyCvScalar *color, int thickness, int lineType,
cv::Vec4i *hierarchy, int hiearchyLength, int maxLevel, MyCvPoint *offset)
{
BEGIN_WRAP
std::vector<std::vector<cv::Point> > contoursVec;
Expand All @@ -1323,7 +1323,7 @@ CVAPI(ExceptionStatus) imgproc_drawContours_vector(cv::_InputOutputArray *image,
}

cv::drawContours(
*image, contoursVec, contourIdx, cpp(color), thickness, lineType, hierarchyVec, maxLevel, cpp(offset));
*image, contoursVec, contourIdx, cpp(*color), thickness, lineType, hierarchyVec, maxLevel, cpp(*offset));
END_WRAP
}
CVAPI(ExceptionStatus) imgproc_drawContours_InputArray(cv::_InputOutputArray *image,
Expand Down
26 changes: 26 additions & 0 deletions src/logger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>


void ShowDbgInfo(const char* data, ...)
{
char temp[2048];

auto logFile = fopen("debug.log", "a+");

SYSTEMTIME st;
GetLocalTime(&st);
sprintf(temp, "DLLÈÕÖ¾Êä³ö: %d-%d-%d %02d£º%02d£º%02d£º%03d ", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
OutputDebugStringA(temp);
fprintf(logFile, "%s", temp);

va_list ap;
va_start(ap, data);
vsprintf(temp, data, ap);
OutputDebugStringA(temp);
va_end(ap);

fprintf(logFile, "%s \n", temp);
fflush(logFile);
}
2 changes: 2 additions & 0 deletions src/logger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
void ShowDbgInfo(const char* data, ...);
19 changes: 17 additions & 2 deletions src/my_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

#include <opencv2/opencv.hpp>

#include "logger.h"

#ifdef _WIN32
#ifdef _DEBUG
Expand Down Expand Up @@ -171,12 +171,27 @@ template <typename T>
static void copyFromVectorToArray(std::vector<std::vector<T> >* src, T** dst)
{
for (size_t i = 0; i < src->size(); ++i)
{
{
const auto& srcI = src->at(i);
const auto dstI = dst[i];
for (size_t j = 0; j < srcI.size(); ++j)
{
dstI[j] = srcI[j];
}
}
}

template <typename T>
static void copyFromVectorToArray2(std::vector<std::vector<T> >* src, T* dst)
{
size_t index = 0;
for (size_t i = 0; i < src->size(); ++i)
{
const auto& srcI = src->at(i);
for (size_t j = 0; j < srcI.size(); ++j)
{
dst[index] = srcI[j];
index++;
}
}
}

0 comments on commit 8113231

Please sign in to comment.