Skip to content

Commit 8113231

Browse files
committed
'fix'
1 parent f40b1f8 commit 8113231

File tree

7 files changed

+61
-10
lines changed

7 files changed

+61
-10
lines changed

src/OpenCvSharpExtern.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ copy "$(SolutionDir)opencv_files\opencv452_win_x64\x64\vc16\bin\opencv_videoio_f
238238
<ClCompile Include="imgproc.cpp" />
239239
<ClCompile Include="img_hash.cpp" />
240240
<ClCompile Include="line_descriptor.cpp" />
241+
<ClCompile Include="logger.cpp" />
241242
<ClCompile Include="ml.cpp" />
242243
<ClCompile Include="objdetect.cpp" />
243244
<ClCompile Include="flann.cpp" />
@@ -299,6 +300,7 @@ copy "$(SolutionDir)opencv_files\opencv452_win_x64\x64\vc16\bin\opencv_videoio_f
299300
<ClInclude Include="img_hash.h" />
300301
<ClInclude Include="include_opencv.h" />
301302
<ClInclude Include="line_descriptor.h" />
303+
<ClInclude Include="logger.h" />
302304
<ClInclude Include="ml.h" />
303305
<ClInclude Include="ml_ANN_MLP.h" />
304306
<ClInclude Include="ml_Boost.h" />

src/OpenCvSharpExtern.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
<ClCompile Include="custom.cpp">
107107
<Filter>Source Files</Filter>
108108
</ClCompile>
109+
<ClCompile Include="logger.cpp">
110+
<Filter>Source Files</Filter>
111+
</ClCompile>
109112
</ItemGroup>
110113
<ItemGroup>
111114
<ClInclude Include="bgsegm.h">
@@ -384,6 +387,9 @@
384387
<ClInclude Include="custom.h">
385388
<Filter>Header Files</Filter>
386389
</ClInclude>
390+
<ClInclude Include="logger.h">
391+
<Filter>Header Files</Filter>
392+
</ClInclude>
387393
</ItemGroup>
388394
<ItemGroup>
389395
<Filter Include="Source Files">

src/custom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void putTextZH(Mat dst, const char* str, Point org, Scalar color, int fontSize,
120120
{
121121
for (int n = 0; n < dst.channels(); ++n) {
122122
double vtxt = subStr[n] / 255.0;
123-
int cvv = vtxt * color.val[n] + (1 - vtxt) * subImg[n];
123+
int cvv = (int)(vtxt * color.val[n] + (1 - vtxt) * subImg[n]);
124124
subImg[n] = cvv > 255 ? 255 : (cvv < 0 ? 0 : cvv);
125125
}
126126

src/imgproc.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,10 @@ CVAPI(ExceptionStatus) imgproc_connectedComponentsWithStats(cv::_InputArray *ima
680680
}
681681

682682
CVAPI(ExceptionStatus) imgproc_findContours1_vector(cv::_InputArray *image, std::vector<std::vector<cv::Point> > *contours,
683-
std::vector<cv::Vec4i> *hierarchy, int mode, int method, MyCvPoint offset)
683+
std::vector<cv::Vec4i> *hierarchy, int mode, int method, MyCvPoint *offset)
684684
{
685685
BEGIN_WRAP
686-
cv::findContours(*image, *contours, *hierarchy, mode, method, cpp(offset));
686+
cv::findContours(*image, *contours, *hierarchy, mode, method, cpp(*offset));
687687
END_WRAP
688688
}
689689
CVAPI(ExceptionStatus) imgproc_findContours1_OutputArray(cv::_InputArray *image, std::vector<cv::Mat> *contours,
@@ -694,10 +694,10 @@ CVAPI(ExceptionStatus) imgproc_findContours1_OutputArray(cv::_InputArray *image,
694694
END_WRAP
695695
}
696696
CVAPI(ExceptionStatus) imgproc_findContours2_vector(cv::_InputArray *image, std::vector<std::vector<cv::Point> > *contours,
697-
int mode, int method, MyCvPoint offset)
697+
int mode, int method, MyCvPoint *offset)
698698
{
699699
BEGIN_WRAP
700-
cv::findContours(*image, *contours, mode, method, cpp(offset));
700+
cv::findContours(*image, *contours, mode, method, cpp(*offset));
701701
END_WRAP
702702
}
703703
CVAPI(ExceptionStatus) imgproc_findContours2_OutputArray(cv::_InputArray *image, std::vector<cv::Mat> *contours,
@@ -1306,8 +1306,8 @@ CVAPI(ExceptionStatus) imgproc_polylines_InputOutputArray(
13061306

13071307
CVAPI(ExceptionStatus) imgproc_drawContours_vector(cv::_InputOutputArray *image,
13081308
cv::Point **contours, int contoursSize1, int *contoursSize2,
1309-
int contourIdx, MyCvScalar color, int thickness, int lineType,
1310-
cv::Vec4i *hierarchy, int hiearchyLength, int maxLevel, MyCvPoint offset)
1309+
int contourIdx, MyCvScalar *color, int thickness, int lineType,
1310+
cv::Vec4i *hierarchy, int hiearchyLength, int maxLevel, MyCvPoint *offset)
13111311
{
13121312
BEGIN_WRAP
13131313
std::vector<std::vector<cv::Point> > contoursVec;
@@ -1323,7 +1323,7 @@ CVAPI(ExceptionStatus) imgproc_drawContours_vector(cv::_InputOutputArray *image,
13231323
}
13241324

13251325
cv::drawContours(
1326-
*image, contoursVec, contourIdx, cpp(color), thickness, lineType, hierarchyVec, maxLevel, cpp(offset));
1326+
*image, contoursVec, contourIdx, cpp(*color), thickness, lineType, hierarchyVec, maxLevel, cpp(*offset));
13271327
END_WRAP
13281328
}
13291329
CVAPI(ExceptionStatus) imgproc_drawContours_InputArray(cv::_InputOutputArray *image,

src/logger.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <windows.h>
2+
#include <stdio.h>
3+
#include <stdarg.h>
4+
5+
6+
void ShowDbgInfo(const char* data, ...)
7+
{
8+
char temp[2048];
9+
10+
auto logFile = fopen("debug.log", "a+");
11+
12+
SYSTEMTIME st;
13+
GetLocalTime(&st);
14+
sprintf(temp, "DLLÈÕÖ¾Êä³ö: %d-%d-%d %02d£º%02d£º%02d£º%03d ", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
15+
OutputDebugStringA(temp);
16+
fprintf(logFile, "%s", temp);
17+
18+
va_list ap;
19+
va_start(ap, data);
20+
vsprintf(temp, data, ap);
21+
OutputDebugStringA(temp);
22+
va_end(ap);
23+
24+
fprintf(logFile, "%s \n", temp);
25+
fflush(logFile);
26+
}

src/logger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
void ShowDbgInfo(const char* data, ...);

src/my_functions.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
#include <opencv2/opencv.hpp>
10-
10+
#include "logger.h"
1111

1212
#ifdef _WIN32
1313
#ifdef _DEBUG
@@ -171,12 +171,27 @@ template <typename T>
171171
static void copyFromVectorToArray(std::vector<std::vector<T> >* src, T** dst)
172172
{
173173
for (size_t i = 0; i < src->size(); ++i)
174-
{
174+
{
175175
const auto& srcI = src->at(i);
176176
const auto dstI = dst[i];
177177
for (size_t j = 0; j < srcI.size(); ++j)
178178
{
179179
dstI[j] = srcI[j];
180180
}
181181
}
182+
}
183+
184+
template <typename T>
185+
static void copyFromVectorToArray2(std::vector<std::vector<T> >* src, T* dst)
186+
{
187+
size_t index = 0;
188+
for (size_t i = 0; i < src->size(); ++i)
189+
{
190+
const auto& srcI = src->at(i);
191+
for (size_t j = 0; j < srcI.size(); ++j)
192+
{
193+
dst[index] = srcI[j];
194+
index++;
195+
}
196+
}
182197
}

0 commit comments

Comments
 (0)