Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a035d391
Commit
a035d391
authored
Apr 02, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3892 from MSOpenTech:imgcodecs-contrib
parents
246b7abe
75850a13
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
11 deletions
+106
-11
.gitignore
.gitignore
+7
-1
CMakeLists.txt
3rdparty/libjpeg/CMakeLists.txt
+7
-0
CMakeLists.txt
3rdparty/libtiff/CMakeLists.txt
+2
-2
CMakeLists.txt
modules/imgcodecs/CMakeLists.txt
+0
-4
MainPage.xaml.cpp
...t/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp
+81
-3
MainPage.xaml.h
...nrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.h
+5
-0
opencv.props
.../winrt/OcvImageProcessing/OcvImageProcessing/opencv.props
+4
-1
No files found.
.gitignore
View file @
a035d391
...
...
@@ -9,7 +9,6 @@ Thumbs.db
tags
tegra/
bin/
CMakeFiles/
*.sdf
*.opensdf
*.obj
...
...
@@ -17,3 +16,9 @@ CMakeFiles/
*.depend
*.rule
*.tmp
*/debug
*/CMakeFiles
CMakeCache.txt
*.suo
*.log
*.tlog
\ No newline at end of file
3rdparty/libjpeg/CMakeLists.txt
View file @
a035d391
...
...
@@ -15,6 +15,13 @@ else()
ocv_list_filterout
(
lib_srcs jmemnobs.c
)
endif
()
if
(
WINRT
)
add_definitions
(
-DNO_GETENV
)
get_directory_property
(
DirDefs COMPILE_DEFINITIONS
)
message
(
STATUS
"Adding NO_GETENV to compiler definitions for WINRT:"
)
message
(
STATUS
" COMPILE_DEFINITIONS =
${
DirDefs
}
"
)
endif
()
# ----------------------------------------------------------------------------------
# Define the library target:
# ----------------------------------------------------------------------------------
...
...
3rdparty/libtiff/CMakeLists.txt
View file @
a035d391
...
...
@@ -17,7 +17,7 @@ check_include_file(string.h HAVE_STRING_H)
check_include_file
(
sys/types.h HAVE_SYS_TYPES_H
)
check_include_file
(
unistd.h HAVE_UNISTD_H
)
if
(
WIN32
)
if
(
WIN32
AND NOT WINRT
)
set
(
USE_WIN32_FILEIO 1
)
endif
()
...
...
@@ -79,7 +79,7 @@ set(lib_srcs
"
${
CMAKE_CURRENT_BINARY_DIR
}
/tif_config.h"
)
if
(
WIN32
)
if
(
WIN32
AND NOT WINRT
)
list
(
APPEND lib_srcs tif_win32.c
)
else
()
list
(
APPEND lib_srcs tif_unix.c
)
...
...
modules/imgcodecs/CMakeLists.txt
View file @
a035d391
if
(
WINRT
)
ocv_module_disable
(
imgcodecs
)
endif
()
set
(
the_description
"Image codecs"
)
ocv_add_module
(
imgcodecs opencv_imgproc WRAP java python
)
...
...
samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp
View file @
a035d391
...
...
@@ -10,6 +10,10 @@
#include <Robuffer.h>
#include <vector>
#include <opencv2\imgproc\types_c.h>
#include <opencv2\imgcodecs\imgcodecs.hpp>
#include <opencv2\core\core.hpp>
#include <windows.storage.h>
using
namespace
OcvImageProcessing
;
...
...
@@ -18,6 +22,7 @@ using namespace concurrency;
using
namespace
Platform
;
using
namespace
Windows
::
Foundation
;
using
namespace
Windows
::
Storage
::
Streams
;
using
namespace
Windows
::
Storage
;
using
namespace
Windows
::
UI
::
Xaml
::
Media
::
Imaging
;
using
namespace
Windows
::
Graphics
::
Imaging
;
using
namespace
Windows
::
Foundation
::
Collections
;
...
...
@@ -37,6 +42,17 @@ MainPage::MainPage()
{
InitializeComponent
();
#ifdef __OPENCV_IMGCODECS_HPP__
// Image loading OpenCV way ... way more simple
cv
::
Mat
image
=
cv
::
imread
(
"Assets/Lena.png"
);
Lena
=
cv
::
Mat
(
image
.
rows
,
image
.
cols
,
CV_8UC4
);
cvtColor
(
image
,
Lena
,
CV_BGR2BGRA
);
UpdateImage
(
Lena
);
#else
// Image loading WinRT way
RandomAccessStreamReference
^
streamRef
=
RandomAccessStreamReference
::
CreateFromUri
(
InputImageUri
);
task
<
IRandomAccessStreamWithContentType
^>
(
streamRef
->
OpenReadAsync
()).
...
...
@@ -68,6 +84,67 @@ MainPage::MainPage()
memcpy
(
Lena
.
data
,
srcPixels
->
Data
,
4
*
frameWidth
*
frameHeight
);
UpdateImage
(
Lena
);
});
#endif
}
/// <summary>
/// Temporary file creation example. Will be created in WinRT application temporary directory
/// which usually is "C:\Users\{username}\AppData\Local\Packages\{package_id}\TempState\{random_name}.{suffix}"
/// </summary>
/// <param name="suffix">Temporary file suffix, e.g. "tmp"</param>
std
::
string
OcvImageProcessing
::
MainPage
::
CreateTempFile
(
const
std
::
string
&
suffix
)
{
return
cv
::
tempfile
(
suffix
.
c_str
());
}
/// <summary>
/// Creating/writing a file in the application local directory
/// </summary>
/// <param name="path">Image to save</param>
bool
OcvImageProcessing
::
MainPage
::
SaveImage
(
cv
::
Mat
image
)
{
StorageFolder
^
localFolderRT
=
ApplicationData
::
Current
->
LocalFolder
;
cv
::
String
localFile
=
ConvertPath
(
ApplicationData
::
Current
->
LocalFolder
->
Path
)
+
"
\\
Lena.png"
;
return
cv
::
imwrite
(
localFile
,
image
);
}
/// <summary>
/// Getting std::string from managed string via std::wstring.
/// Provides an example of three ways to do it.
/// Can't use this one: https://msdn.microsoft.com/en-us/library/bb384865.aspx, not available on WinRT.
/// </summary>
/// <param name="path">Path to be converted</param>
cv
::
String
OcvImageProcessing
::
MainPage
::
ConvertPath
(
Platform
::
String
^
path
)
{
std
::
wstring
localPathW
(
path
->
Begin
());
// Opt #1
//std::string localPath(localPathW.begin(), localPathW.end());
// Opt #2
//std::string localPath(StrToWStr(localPathW));
// Opt #3
size_t
outSize
=
localPathW
.
length
()
+
1
;
char
*
localPathC
=
new
char
[
outSize
];
size_t
charsConverted
=
0
;
wcstombs_s
(
&
charsConverted
,
localPathC
,
outSize
,
localPathW
.
c_str
(),
localPathW
.
length
());
cv
::
String
localPath
(
localPathC
);
// Implicit conversion from std::string to cv::String
return
localPath
;
}
std
::
string
OcvImageProcessing
::
MainPage
::
StrToWStr
(
const
std
::
wstring
&
input
)
{
if
(
input
.
empty
())
{
return
std
::
string
();
}
int
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
&
input
[
0
],
(
int
)
input
.
size
(),
NULL
,
0
,
NULL
,
NULL
);
std
::
string
result
(
size
,
0
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
&
input
[
0
],
(
int
)
input
.
size
(),
&
result
[
0
],
size
,
NULL
,
NULL
);
return
result
;
}
/// <summary>
...
...
@@ -91,15 +168,16 @@ void OcvImageProcessing::MainPage::UpdateImage(const cv::Mat& image)
// Obtain IBufferByteAccess
ComPtr
<
IBufferByteAccess
>
pBufferByteAccess
;
ComPtr
<
I
Unknown
>
pBuffer
((
IUnknown
*
)
buffer
);
ComPtr
<
I
Inspectable
>
pBuffer
((
IInspectable
*
)
buffer
);
pBuffer
.
As
(
&
pBufferByteAccess
);
// Get pointer to pixel bytes
pBufferByteAccess
->
Buffer
(
&
dstPixels
);
memcpy
(
dstPixels
,
image
.
data
,
4
*
image
.
cols
*
image
.
rows
);
memcpy
(
dstPixels
,
image
.
data
,
image
.
step
.
buf
[
1
]
*
image
.
cols
*
image
.
rows
);
// Set the bitmap to the Image element
PreviewWidget
->
Source
=
bitmap
;}
PreviewWidget
->
Source
=
bitmap
;
}
cv
::
Mat
OcvImageProcessing
::
MainPage
::
ApplyGrayFilter
(
const
cv
::
Mat
&
image
)
...
...
samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.h
View file @
a035d391
...
...
@@ -39,6 +39,11 @@ namespace OcvImageProcessing
cv
::
Mat
ApplySepiaFilter
(
const
cv
::
Mat
&
image
);
void
UpdateImage
(
const
cv
::
Mat
&
image
);
std
::
string
CreateTempFile
(
const
std
::
string
&
suffix
);
bool
SaveImage
(
cv
::
Mat
image
);
std
::
string
StrToWStr
(
const
std
::
wstring
&
wstr
);
cv
::
String
ConvertPath
(
Platform
::
String
^
path
);
cv
::
Mat
Lena
;
unsigned
int
frameWidth
,
frameHeight
;
...
...
samples/winrt/OcvImageProcessing/OcvImageProcessing/opencv.props
View file @
a035d391
...
...
@@ -17,6 +17,9 @@
<None
Include=
"$(OpenCV_Bin)opencv_imgproc300$(DebugSuffix).dll"
>
<DeploymentContent>
true
</DeploymentContent>
</None>
<None
Include=
"$(OpenCV_Bin)opencv_imgcodecs300$(DebugSuffix).dll"
>
<DeploymentContent>
true
</DeploymentContent>
</None>
<None
Include=
"$(OpenCV_Bin)opencv_features2d300$(DebugSuffix).dll"
>
<DeploymentContent>
true
</DeploymentContent>
</None>
...
...
@@ -33,7 +36,7 @@
</ClCompile>
<Link>
<!--Add required OpenCV libs here-->
<AdditionalDependencies>
opencv_core300$(DebugSuffix).lib;opencv_imgproc300$(DebugSuffix).lib;opencv_features2d300$(DebugSuffix).lib;opencv_flann300$(DebugSuffix).lib;opencv_ml300$(DebugSuffix).lib;%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalDependencies>
opencv_core300$(DebugSuffix).lib;opencv_imgproc300$(DebugSuffix).lib;opencv_features2d300$(DebugSuffix).lib;opencv_flann300$(DebugSuffix).lib;opencv_ml300$(DebugSuffix).lib;
opencv_imgcodecs300$(DebugSuffix).lib;
%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalLibraryDirectories>
$(OpenCV_Lib);%(AdditionalLibraryDirectories);
</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment