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
de9f659f
Commit
de9f659f
authored
Jun 10, 2013
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Several transforms added to sample IMFTransform.
parent
9e062871
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
26 deletions
+82
-26
AdvancedCapture.xaml
samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml
+2
-1
AdvancedCapture.xaml.cpp
...les/winrt/ImageManipulations/C++/AdvancedCapture.xaml.cpp
+7
-2
AdvancedCapture.xaml.h
samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml.h
+1
-0
MainPage.xaml
samples/winrt/ImageManipulations/C++/MainPage.xaml
+1
-11
Grayscale.cpp
...Manipulations/C++/MediaExtensions/Grayscale/Grayscale.cpp
+65
-6
Grayscale.h
...geManipulations/C++/MediaExtensions/Grayscale/Grayscale.h
+6
-6
No files found.
samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml
View file @
de9f659f
...
...
@@ -40,7 +40,8 @@
<Button x:Name="btnTakePhoto2" Click="btnTakePhoto_Click" IsEnabled="false" Margin="0,0,10,0">TakePhoto</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,10,0,0">
<CheckBox x:Name="chkAddRemoveEffect" Margin="0,0,10,0" Content="Grayscale Effect" IsEnabled="False" Checked="chkAddRemoveEffect_Checked" Unchecked="chkAddRemoveEffect_Unchecked"/>
<CheckBox x:Name="chkAddRemoveEffect" Margin="0,0,10,0" Content="Add Effect" IsEnabled="False" Checked="chkAddRemoveEffect_Checked" Unchecked="chkAddRemoveEffect_Unchecked"/>
<ComboBox Width="120"/>
</StackPanel>
</Grid>
...
...
samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml.cpp
View file @
de9f659f
...
...
@@ -596,7 +596,7 @@ void AdvancedCapture::AddEffectToImageStream()
Windows
::
Foundation
::
Collections
::
IVectorView
<
Windows
::
Media
::
MediaProperties
::
IMediaEncodingProperties
^>^
supportedPropsList
=
mediaCapture
->
VideoDeviceController
->
GetAvailableMediaStreamProperties
(
Windows
::
Media
::
Capture
::
MediaStreamType
::
Photo
);
{
unsigned
int
i
=
0
;
while
(
i
<
supportedPropsList
->
Size
)
while
(
i
<
supportedPropsList
->
Size
)
{
Windows
::
Media
::
MediaProperties
::
IMediaEncodingProperties
^
props
=
supportedPropsList
->
GetAt
(
i
);
...
...
@@ -634,7 +634,6 @@ void AdvancedCapture::AddEffectToImageStream()
ShowExceptionMessage
(
e
);
chkAddRemoveEffect
->
IsEnabled
=
true
;
chkAddRemoveEffect
->
IsChecked
=
false
;
}
});
...
...
@@ -1032,3 +1031,9 @@ Windows::Media::Capture::VideoRotation AdvancedCapture::VideoRotationLookup(
}
}
void
SDKSample
::
MediaCapture
::
AdvancedCapture
::
EffectType_SelectionChanged
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
Controls
::
SelectionChangedEventArgs
^
e
)
{
}
samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml.h
View file @
de9f659f
...
...
@@ -98,6 +98,7 @@ namespace SDKSample
bool
m_bRotateVideoOnOrientationChange
;
bool
m_bReversePreviewRotation
;
Windows
::
Foundation
::
EventRegistrationToken
m_orientationChangedEventToken
;
void
EffectType_SelectionChanged
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
Controls
::
SelectionChangedEventArgs
^
e
);
};
}
}
samples/winrt/ImageManipulations/C++/MainPage.xaml
View file @
de9f659f
...
...
@@ -116,17 +116,7 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Source="Assets/microsoft-sdk.png" AutomationProperties.Name="Microsoft Logo" Stretch="None" HorizontalAlignment="Left"/>
<TextBlock Style="{StaticResource FooterStyle}" Text="© Microsoft Corporation. All rights reserved." TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Left"/>
<StackPanel x:Name="FooterPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right">
<HyperlinkButton Content="Terms of use" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Copyright/default.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Trademarks" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Trademarks/EN-US.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Privacy Statement" Tag="http://privacy.microsoft.com" Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
</StackPanel>
<StackPanel x:Name="FooterPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right"/>
</Grid>
...
...
samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.cpp
View file @
de9f659f
...
...
@@ -1350,10 +1350,13 @@ HRESULT CGrayscale::BeginStreaming()
goto
done
;
}
// Get the chroma transformations.
// Get the effect type
UINT32
effect
=
MFGetAttributeUINT32
(
m_pAttributes
,
MFT_IMAGE_EFFECT
,
1
);
// float scale = (float)MFGetAttributeDouble(m_pAttributes, MFT_GRAYSCALE_SATURATION, 0.0f);
// float angle = (float)MFGetAttributeDouble(m_pAttributes, MFT_GRAYSCALE_CHROMA_ROTATION, 0.0f);
if
((
effect
>=
0
)
&&
(
effect
<
InvalidEffect
))
{
m_TransformType
=
(
ProcessingType
)
effect
;
}
m_bStreamingInitialized
=
true
;
}
...
...
@@ -1414,16 +1417,72 @@ HRESULT CGrayscale::OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuffer *pOut)
return
hr
;
}
//(*m_pTransformFn)(m_transform, m_rcDest, pDest, lDestStride, pSrc, lSrcStride,
// m_imageWidthInPixels, m_imageHeightInPixels);
cv
::
Mat
InputFrame
(
m_imageHeightInPixels
+
m_imageHeightInPixels
/
2
,
m_imageWidthInPixels
,
CV_8UC1
,
pSrc
,
lSrcStride
);
cv
::
Mat
InputGreyScale
(
InputFrame
,
cv
::
Range
(
0
,
m_imageHeightInPixels
),
cv
::
Range
(
0
,
m_imageWidthInPixels
));
cv
::
Mat
OutputFrame
(
m_imageHeightInPixels
+
m_imageHeightInPixels
/
2
,
m_imageWidthInPixels
,
CV_8UC1
,
pDest
,
lDestStride
);
switch
(
m_TransformType
)
{
case
Preview
:
{
InputFrame
.
copyTo
(
OutputFrame
);
}
break
;
case
GrayScale
:
{
OutputFrame
.
setTo
(
cv
::
Scalar
(
128
));
cv
::
Mat
OutputGreyScale
(
OutputFrame
,
cv
::
Range
(
0
,
m_imageHeightInPixels
),
cv
::
Range
(
0
,
m_imageWidthInPixels
));
InputGreyScale
.
copyTo
(
OutputGreyScale
);
}
break
;
case
Canny
:
{
OutputFrame
.
setTo
(
cv
::
Scalar
(
128
));
cv
::
Mat
OutputGreyScale
(
OutputFrame
,
cv
::
Range
(
0
,
m_imageHeightInPixels
),
cv
::
Range
(
0
,
m_imageWidthInPixels
));
cv
::
Canny
(
InputGreyScale
,
OutputGreyScale
,
80
,
90
);
}
break
;
case
Sobel
:
{
OutputFrame
.
setTo
(
cv
::
Scalar
(
128
));
cv
::
Mat
OutputGreyScale
(
OutputFrame
,
cv
::
Range
(
0
,
m_imageHeightInPixels
),
cv
::
Range
(
0
,
m_imageWidthInPixels
));
cv
::
Sobel
(
InputGreyScale
,
OutputGreyScale
,
CV_8U
,
1
,
1
);
}
break
;
case
Histogram
:
{
const
int
mHistSizeNum
=
25
;
const
int
channels
[
3
][
1
]
=
{{
0
},
{
1
},
{
2
}};
const
int
mHistSize
[]
=
{
25
};
const
float
baseRabge
[]
=
{
0.
f
,
256.
f
};
const
float
*
ranges
[]
=
{
baseRabge
};
const
cv
::
Scalar
mColorsRGB
[]
=
{
cv
::
Scalar
(
200
,
0
,
0
,
255
),
cv
::
Scalar
(
0
,
200
,
0
,
255
),
cv
::
Scalar
(
0
,
0
,
200
,
255
)
};
cv
::
Mat
BgrFrame
;
cv
::
cvtColor
(
InputFrame
,
BgrFrame
,
cv
::
COLOR_YUV420sp2BGR
);
int
thikness
=
(
int
)
(
BgrFrame
.
cols
/
(
mHistSizeNum
+
10
)
/
5
);
if
(
thikness
>
5
)
thikness
=
5
;
int
offset
=
(
int
)
((
BgrFrame
.
cols
-
(
5
*
mHistSizeNum
+
4
*
10
)
*
thikness
)
/
2
);
// RGB
for
(
int
c
=
0
;
c
<
3
;
c
++
)
{
std
::
vector
<
int
>
hist
;
cv
::
calcHist
(
&
BgrFrame
,
1
,
channels
[
c
],
cv
::
Mat
(),
hist
,
1
,
mHistSize
,
ranges
);
cv
::
normalize
(
hist
,
hist
,
BgrFrame
.
rows
/
2
,
0
,
cv
::
NORM_INF
);
for
(
int
h
=
0
;
h
<
mHistSizeNum
;
h
++
)
{
cv
::
Point
mP1
,
mP2
;
mP1
.
x
=
mP2
.
x
=
offset
+
(
c
*
(
mHistSizeNum
+
10
)
+
h
)
*
thikness
;
mP1
.
y
=
BgrFrame
.
rows
-
1
;
mP2
.
y
=
mP1
.
y
-
2
-
(
int
)
hist
[
h
];
cv
::
line
(
BgrFrame
,
mP1
,
mP2
,
mColorsRGB
[
c
],
thikness
);
}
}
cv
::
cvtColor
(
BgrFrame
,
OutputFrame
,
cv
::
COLOR_BGR2YUV_I420
);
}
break
;
default
:
break
;
}
// Set the data size on the output buffer.
hr
=
pOut
->
SetCurrentLength
(
m_cbImageSize
);
...
...
samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.h
View file @
de9f659f
...
...
@@ -37,18 +37,18 @@ DEFINE_GUID(CLSID_GrayscaleMFT,
// Configuration attributes
// {698649BE-8EAE-4551-A4CB-3EC98FBD3D86}
DEFINE_GUID
(
MFT_IMAGE_EFFECT
,
0x698649be
,
0x8eae
,
0x4551
,
0xa4
,
0xcb
,
0x3e
,
0xc9
,
0x8f
,
0xbd
,
0x3d
,
0x86
);
// {7BBBB051-133B-41F5-B6AA-5AFF9B33A2CB}
DEFINE_GUID
(
MFT_GRAYSCALE_DESTINATION_RECT
,
0x7bbbb051
,
0x133b
,
0x41f5
,
0xb6
,
0xaa
,
0x5a
,
0xff
,
0x9b
,
0x33
,
0xa2
,
0xcb
);
enum
ProcessingType
{
Preview
,
GrayScale
,
Canny
,
Zoom
,
Sepia
Sobel
,
Histogram
,
InvalidEffect
};
template
<
class
T
>
void
SafeRelease
(
T
**
ppT
)
...
...
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