@ -0,0 +1,37 @@ |
||||
SET(OPENCV_ANNOTATION_DEPS opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio) |
||||
ocv_check_dependencies(${OPENCV_ANNOTATION_DEPS}) |
||||
|
||||
if(NOT OCV_DEPENDENCIES_FOUND) |
||||
return() |
||||
endif() |
||||
|
||||
project(annotation) |
||||
set(the_target opencv_annotation) |
||||
|
||||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") |
||||
ocv_target_include_modules(${the_target} ${OPENCV_ANNOTATION_DEPS}) |
||||
|
||||
file(GLOB SRCS *.cpp) |
||||
|
||||
set(annotation_files ${SRCS}) |
||||
ocv_add_executable(${the_target} ${annotation_files}) |
||||
ocv_target_link_libraries(${the_target} ${OPENCV_ANNOTATION_DEPS}) |
||||
|
||||
set_target_properties(${the_target} PROPERTIES |
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" |
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} |
||||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} |
||||
INSTALL_NAME_DIR lib |
||||
OUTPUT_NAME "opencv_annotation") |
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS) |
||||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") |
||||
endif() |
||||
|
||||
if(INSTALL_CREATE_DISTRIB) |
||||
if(BUILD_SHARED_LIBS) |
||||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) |
||||
endif() |
||||
else() |
||||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) |
||||
endif() |
@ -0,0 +1,198 @@ |
||||
/*****************************************************************************************************
|
||||
USAGE: |
||||
./opencv_annotation -images <folder location> -annotations <ouput file> |
||||
|
||||
Created by: Puttemans Steven |
||||
*****************************************************************************************************/ |
||||
|
||||
#include <opencv2/core.hpp> |
||||
#include <opencv2/highgui.hpp> |
||||
#include <opencv2/imgcodecs.hpp> |
||||
#include <opencv2/videoio.hpp> |
||||
#include <opencv2/imgproc.hpp> |
||||
|
||||
#include <fstream> |
||||
#include <iostream> |
||||
|
||||
using namespace std; |
||||
using namespace cv; |
||||
|
||||
// Function prototypes
|
||||
void on_mouse(int, int, int, int, void*); |
||||
string int2string(int); |
||||
void get_annotations(Mat, stringstream*); |
||||
|
||||
// Public parameters
|
||||
Mat image; |
||||
int roi_x0 = 0, roi_y0 = 0, roi_x1 = 0, roi_y1 = 0, num_of_rec = 0; |
||||
bool start_draw = false; |
||||
|
||||
// Window name for visualisation purposes
|
||||
const string window_name="OpenCV Based Annotation Tool"; |
||||
|
||||
// FUNCTION : Mouse response for selecting objects in images
|
||||
// If left button is clicked, start drawing a rectangle as long as mouse moves
|
||||
// Stop drawing once a new left click is detected by the on_mouse function
|
||||
void on_mouse(int event, int x, int y, int , void * ) |
||||
{ |
||||
// Action when left button is clicked
|
||||
if(event == EVENT_LBUTTONDOWN) |
||||
{ |
||||
if(!start_draw) |
||||
{ |
||||
roi_x0 = x; |
||||
roi_y0 = y; |
||||
start_draw = true; |
||||
} else { |
||||
roi_x1 = x; |
||||
roi_y1 = y; |
||||
start_draw = false; |
||||
} |
||||
} |
||||
// Action when mouse is moving
|
||||
if((event == EVENT_MOUSEMOVE) && start_draw) |
||||
{ |
||||
// Redraw bounding box for annotation
|
||||
Mat current_view; |
||||
image.copyTo(current_view); |
||||
rectangle(current_view, Point(roi_x0,roi_y0), Point(x,y), Scalar(0,0,255)); |
||||
imshow(window_name, current_view); |
||||
} |
||||
} |
||||
|
||||
// FUNCTION : snippet to convert an integer value to a string using a clean function
|
||||
// instead of creating a stringstream each time inside the main code
|
||||
string int2string(int num) |
||||
{ |
||||
stringstream temp_stream; |
||||
temp_stream << num; |
||||
return temp_stream.str(); |
||||
} |
||||
|
||||
// FUNCTION : given an image containing positive object instances, add all the object
|
||||
// annotations to a known stringstream
|
||||
void get_annotations(Mat input_image, stringstream* output_stream) |
||||
{ |
||||
// Make it possible to exit the annotation
|
||||
bool stop = false; |
||||
|
||||
// Reset the num_of_rec element at each iteration
|
||||
// Make sure the global image is set to the current image
|
||||
num_of_rec = 0; |
||||
image = input_image; |
||||
|
||||
// Init window interface and couple mouse actions
|
||||
namedWindow(window_name, WINDOW_AUTOSIZE); |
||||
setMouseCallback(window_name, on_mouse); |
||||
|
||||
imshow(window_name, image); |
||||
stringstream temp_stream; |
||||
int key_pressed = 0; |
||||
|
||||
do |
||||
{ |
||||
// Keys for processing
|
||||
// You need to select one for confirming a selection and one to continue to the next image
|
||||
// Based on the universal ASCII code of the keystroke: http://www.asciitable.com/
|
||||
// c = 99 add rectangle to current image
|
||||
// n = 110 save added rectangles and show next image
|
||||
// <ESC> = 27 exit program
|
||||
key_pressed = 0xFF & waitKey(0); |
||||
switch( key_pressed ) |
||||
{ |
||||
case 27: |
||||
destroyWindow(window_name); |
||||
stop = true; |
||||
case 99: |
||||
// Add a rectangle to the list
|
||||
num_of_rec++; |
||||
// Draw initiated from top left corner
|
||||
if(roi_x0<roi_x1 && roi_y0<roi_y1) |
||||
{ |
||||
temp_stream << " " << int2string(roi_x0) << " " << int2string(roi_y0) << " " << int2string(roi_x1-roi_x0) << " " << int2string(roi_y1-roi_y0); |
||||
} |
||||
// Draw initiated from bottom right corner
|
||||
if(roi_x0>roi_x1 && roi_y0>roi_y1) |
||||
{ |
||||
temp_stream << " " << int2string(roi_x1) << " " << int2string(roi_y1) << " " << int2string(roi_x0-roi_x1) << " " << int2string(roi_y0-roi_y1); |
||||
} |
||||
// Draw initiated from top right corner
|
||||
if(roi_x0>roi_x1 && roi_y0<roi_y1) |
||||
{ |
||||
temp_stream << " " << int2string(roi_x1) << " " << int2string(roi_y0) << " " << int2string(roi_x0-roi_x1) << " " << int2string(roi_y1-roi_y0); |
||||
} |
||||
// Draw initiated from bottom left corner
|
||||
if(roi_x0<roi_x1 && roi_y0>roi_y1) |
||||
{ |
||||
temp_stream << " " << int2string(roi_x0) << " " << int2string(roi_y1) << " " << int2string(roi_x1-roi_x0) << " " << int2string(roi_y0-roi_y1); |
||||
} |
||||
|
||||
rectangle(input_image, Point(roi_x0,roi_y0), Point(roi_x1,roi_y1), Scalar(0,255,0), 1); |
||||
|
||||
break; |
||||
} |
||||
|
||||
// Check if escape has been pressed
|
||||
if(stop) |
||||
{ |
||||
break; |
||||
} |
||||
} |
||||
// Continue as long as the next image key has not been pressed
|
||||
while(key_pressed != 110); |
||||
|
||||
// If there are annotations AND the next image key is pressed
|
||||
// Write the image annotations to the file
|
||||
if(num_of_rec>0 && key_pressed==110) |
||||
{ |
||||
*output_stream << " " << num_of_rec << temp_stream.str() << endl; |
||||
} |
||||
|
||||
// Close down the window
|
||||
destroyWindow(window_name); |
||||
} |
||||
|
||||
int main( int argc, const char** argv ) |
||||
{ |
||||
// Read in the input arguments
|
||||
string image_folder; |
||||
string annotations; |
||||
for(int i = 1; i < argc; ++i ) |
||||
{ |
||||
if( !strcmp( argv[i], "-images" ) ) |
||||
{ |
||||
image_folder = argv[++i]; |
||||
} |
||||
else if( !strcmp( argv[i], "-annotations" ) ) |
||||
{ |
||||
annotations = argv[++i]; |
||||
} |
||||
} |
||||
|
||||
// Create the outputfilestream
|
||||
ofstream output(annotations.c_str()); |
||||
|
||||
// Return the image filenames inside the image folder
|
||||
vector<String> filenames; |
||||
String folder(image_folder); |
||||
glob(folder, filenames); |
||||
|
||||
// Loop through each image stored in the images folder
|
||||
// Create and temporarily store the annotations
|
||||
// At the end write everything to the annotations file
|
||||
for (size_t i = 0; i < filenames.size(); i++){ |
||||
// Read in an image
|
||||
Mat current_image = imread(filenames[i]); |
||||
|
||||
// Perform annotations & generate corresponding output
|
||||
stringstream output_stream; |
||||
get_annotations(current_image, &output_stream); |
||||
|
||||
// Store the annotations, write to the output file
|
||||
if (output_stream.str() != ""){ |
||||
output << filenames[i] << output_stream.str(); |
||||
} |
||||
} |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,86 @@ |
||||
@echo off |
||||
|
||||
|
||||
set FOUND_VC=0 |
||||
|
||||
if defined VS120COMNTOOLS ( |
||||
set VSTOOLS="%VS120COMNTOOLS%" |
||||
set VC_VER=120 |
||||
set FOUND_VC=1 |
||||
) |
||||
|
||||
set VSTOOLS=%VSTOOLS:"=% |
||||
set "VSTOOLS=%VSTOOLS:\=/%" |
||||
|
||||
set VSVARS="%VSTOOLS%vsvars32.bat" |
||||
|
||||
if not defined VSVARS ( |
||||
echo Can't find VC2013 installed! |
||||
goto ERROR |
||||
) |
||||
|
||||
|
||||
echo./* |
||||
echo. * Building OpenCV |
||||
echo. */ |
||||
echo. |
||||
|
||||
|
||||
call %VSVARS% |
||||
|
||||
if %FOUND_VC%==1 ( |
||||
call:DoMSBuild ..\..\bin\WP\8.1\x86\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.1\x86\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.1\x86\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WP\8.1\x86\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WP\8.1\ARM\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.1\ARM\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.1\ARM\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WP\8.1\ARM\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WS\8.1\x86\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.1\x86\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.1\x86\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WS\8.1\x86\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WS\8.1\ARM\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.1\ARM\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.1\ARM\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WS\8.1\ARM\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WP\8.0\x86\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.0\x86\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.0\x86\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WP\8.0\x86\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WP\8.0\ARM\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.0\ARM\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WP\8.0\ARM\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WP\8.0\ARM\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WS\8.0\x86\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.0\x86\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.0\x86\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WS\8.0\x86\INSTALL.vcxproj Release |
||||
|
||||
call:DoMSBuild ..\..\bin\WS\8.0\ARM\OpenCV.sln Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.0\ARM\INSTALL.vcxproj Debug |
||||
call:DoMSBuild ..\..\bin\WS\8.0\ARM\OpenCV.sln Release |
||||
call:DoMSBuild ..\..\bin\WS\8.0\ARM\INSTALL.vcxproj Release |
||||
) |
||||
|
||||
echo.&goto:EOF |
||||
|
||||
|
||||
::-------------------------------------------------------- |
||||
::-- DoMSBuild |
||||
::-------------------------------------------------------- |
||||
:DoMSBuild |
||||
msbuild %~1 /p:Configuration="%~2" /m |
||||
@if errorlevel 1 goto :ERROR |
||||
goto:EOF |
||||
|
||||
:ERROR |
||||
pause |
||||
:EOF |
@ -0,0 +1,102 @@ |
||||
Building OpenCV from Source, using CMake and Command Line |
||||
========================================================= |
||||
|
||||
Requirements |
||||
============ |
||||
CMake 3.1.0 or higher |
||||
Windows Phone/Store 8.1 Visual Studio 2013 |
||||
Windows Phone/Store 8.0 Visual Studio 2012 |
||||
|
||||
For example, to be able to build all Windows Phone and Windows Store projects install the following: |
||||
|
||||
Install Visual Studio 2013 Community Edition |
||||
http://go.microsoft.com/?linkid=9863608 |
||||
|
||||
Install Visual Studio Express 2012 for Windows Desktop |
||||
http://www.microsoft.com/en-us/download/details.aspx?id=34673 |
||||
|
||||
|
||||
|
||||
To create all Windows Phone (8.0, 8.1) and Windows Store (8.0, 8.1) Visual Studio projects |
||||
========================================================================================== |
||||
cd opencv/platforms/winrt |
||||
setup_winrt.bat "WP,WS" "8.0,8.1" "x86,ARM" |
||||
|
||||
If everything's fine, a few minutes later you will get the following output in the opencv/bin directory: |
||||
|
||||
bin |
||||
WP |
||||
8.0 |
||||
ARM |
||||
x86 |
||||
8.1 |
||||
ARM |
||||
x86 |
||||
WS |
||||
8.0 |
||||
ARM |
||||
x86 |
||||
8.1 |
||||
ARM |
||||
x86 |
||||
|
||||
Build the OpenCV.sln for the particular platform you are targeting. Due to the current limitations of CMake, separate x86/x64/ARM projects must be generated for each platform. |
||||
|
||||
You can also target a single specific configuration |
||||
setup_winrt.bat "WP" "8.1" "x86" |
||||
|
||||
Or a subset of configurations |
||||
setup_winrt.bat "WP,WS" "8.1" "x86" |
||||
|
||||
To display the command line options for setup_winrt.bat |
||||
setup_winrt.bat -h |
||||
|
||||
Note that x64 CMake generation support is as follows: |
||||
------------------------------ |
||||
Platform\Version | 8.0 | 8.1 | |
||||
-----------------|-----|-----| |
||||
Windows Phone | No | No | |
||||
Windows Store | Yes | Yes | |
||||
|
||||
Note: setup_winrt.bat calls the unsigned PowerShell script with the -ExecutionPolicy Unrestricted option. |
||||
|
||||
|
||||
CMake command line options for Windows Phone and Store |
||||
====================================================== |
||||
|
||||
cmake [options] <path-to-source> |
||||
|
||||
Windows Phone 8.1 x86 |
||||
cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source> |
||||
|
||||
Windows Phone 8.1 ARM |
||||
cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source> |
||||
|
||||
Windows Store 8.1 x86 |
||||
cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source> |
||||
|
||||
Windows Store 8.1 ARM |
||||
cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source> |
||||
|
||||
Note: For Windows 8.0 Phone and Store you can specify either Visual Studio 11 2012 or Visual Studio 12 2013 as the generator |
||||
|
||||
Windows Phone 8.0 x86 |
||||
cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source> |
||||
|
||||
Windows Phone 8.0 ARM |
||||
cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source> |
||||
|
||||
Windows Store 8.0 x86 |
||||
cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source> |
||||
|
||||
Windows Store 8.0 ARM |
||||
cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source> |
||||
|
||||
Example |
||||
====================================================== |
||||
|
||||
To generate Windows Phone 8.1 x86 project files in the opencv/bin dir |
||||
|
||||
mkdir bin |
||||
cd bin |
||||
cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 ../ |
@ -0,0 +1,2 @@ |
||||
@echo off |
||||
Powershell.exe -ExecutionPolicy Unrestricted -File setup_winrt.ps1 %* |
@ -0,0 +1,331 @@ |
||||
<# |
||||
Copyright © Microsoft Open Technologies, Inc. |
||||
All Rights Reserved |
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
|
||||
You may obtain a copy of the License at |
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
||||
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, |
||||
FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. |
||||
|
||||
See the Apache 2 License for the specific language governing permissions and limitations under the License. |
||||
#> |
||||
|
||||
[CmdletBinding()] |
||||
Param( |
||||
[parameter(Mandatory=$False)] |
||||
[switch] |
||||
$HELP, |
||||
|
||||
[parameter(Mandatory=$False)] |
||||
[switch] |
||||
$BUILD, |
||||
|
||||
[parameter(Mandatory=$False)] |
||||
[Array] |
||||
[ValidateNotNull()] |
||||
$PLATFORMS_IN = "WP", |
||||
|
||||
[parameter(Mandatory=$False)] |
||||
[Array] |
||||
[ValidateNotNull()] |
||||
$VERSIONS_IN = "8.1", |
||||
|
||||
[parameter(Mandatory=$False)] |
||||
[Array] |
||||
[ValidateNotNull()] |
||||
$ARCHITECTURES_IN = "x86", |
||||
|
||||
[parameter(Mandatory=$False)] |
||||
[String] |
||||
[ValidateNotNull()] |
||||
[ValidateSet("Visual Studio 12 2013","Visual Studio 11 2012")] |
||||
$GENERATOR = "Visual Studio 12 2013", |
||||
|
||||
[parameter(Mandatory=$False)] |
||||
[String] |
||||
$INSTALL |
||||
) |
||||
|
||||
|
||||
Function L() { |
||||
Param( |
||||
[parameter(Mandatory=$true)] |
||||
[String] |
||||
[ValidateNotNull()] |
||||
$str |
||||
) |
||||
|
||||
Write-Host "INFO> $str" |
||||
} |
||||
|
||||
Function D() { |
||||
Param( |
||||
[parameter(Mandatory=$true)] |
||||
[String] |
||||
[ValidateNotNull()] |
||||
$str |
||||
) |
||||
|
||||
# Use this trigger to toggle debug output |
||||
[bool]$debug = $true |
||||
|
||||
if ($debug) { |
||||
Write-Host "DEBUG> $str" |
||||
} |
||||
} |
||||
|
||||
function Get-Batchfile ($file) { |
||||
$cmd = "`"$file`" & set" |
||||
cmd /c $cmd | Foreach-Object { |
||||
$p, $v = $_.split('=') |
||||
Set-Item -path env:$p -value $v |
||||
} |
||||
} |
||||
|
||||
# Enables access to Visual Studio variables via "vsvars32.bat" |
||||
function Set-VS12() |
||||
{ |
||||
Try { |
||||
$vs12comntools = (Get-ChildItem env:VS120COMNTOOLS).Value |
||||
$batchFile = [System.IO.Path]::Combine($vs12comntools, "vsvars32.bat") |
||||
Get-Batchfile $BatchFile |
||||
[System.Console]::Title = "Visual Studio 2010 Windows PowerShell" |
||||
} Catch { |
||||
$ErrorMessage = $_.Exception.Message |
||||
L "Error: $ErrorMessage" |
||||
return $false |
||||
} |
||||
return $true |
||||
} |
||||
|
||||
# Executes msbuild to build or install projects |
||||
# Throws Exception on error |
||||
function Call-MSBuild($path, $config) |
||||
{ |
||||
$command = "msbuild $path /p:Configuration='$config' /m" |
||||
L "Executing: $($command)" |
||||
msbuild $path /p:Configuration="$config" /m |
||||
|
||||
if(-Not $?) { |
||||
Throw "Failure executing command: $($command)" |
||||
} |
||||
|
||||
return $true |
||||
} |
||||
|
||||
Function Execute() { |
||||
If ($HELP.IsPresent) { |
||||
ShowHelp |
||||
} |
||||
|
||||
# Validating arguments. |
||||
# This type of validation (rather than using ValidateSet()) is required to make .bat wrapper work |
||||
|
||||
D "Input Platforms: $PLATFORMS_IN" |
||||
$platforms = New-Object System.Collections.ArrayList |
||||
$PLATFORMS_IN.Split("," ,[System.StringSplitOptions]::RemoveEmptyEntries) | ForEach { |
||||
$_ = $_.Trim() |
||||
if ("WP","WS" -Contains $_) { |
||||
[void]$platforms.Add($_) |
||||
D "$_ is valid" |
||||
} else { |
||||
Throw "$($_) is not valid! Please use WP, WS" |
||||
} |
||||
} |
||||
D "Processed Platforms: $platforms" |
||||
|
||||
D "Input Versions: $VERSIONS_IN" |
||||
$versions = New-Object System.Collections.ArrayList |
||||
$VERSIONS_IN.Split("," ,[System.StringSplitOptions]::RemoveEmptyEntries) | ForEach { |
||||
$_ = $_.Trim() |
||||
if ("8.0","8.1" -Contains $_) { |
||||
[void]$versions.Add($_) |
||||
D "$_ is valid" |
||||
} else { |
||||
Throw "$($_) is not valid! Please use 8.0, 8.1" |
||||
} |
||||
} |
||||
D "Processed Versions: $versions" |
||||
|
||||
D "Input Architectures: $ARCHITECTURES_IN" |
||||
$architectures = New-Object System.Collections.ArrayList |
||||
$ARCHITECTURES_IN.Split("," ,[System.StringSplitOptions]::RemoveEmptyEntries) | ForEach { |
||||
$_ = $_.Trim() |
||||
if ("x86","x64","ARM" -Contains $_) { |
||||
$architectures.Add($_) > $null |
||||
D "$_ is valid" |
||||
} else { |
||||
Throw "$($_) is not valid! Please use x86, x64, ARM" |
||||
} |
||||
} |
||||
D "Processed Architectures: $architectures" |
||||
|
||||
# Assuming we are in '<ocv-sources>/platforms/winrt' we should move up to sources root directory |
||||
Push-Location ../../ |
||||
|
||||
$SRC = Get-Location |
||||
|
||||
$def_architectures = @{ |
||||
"x86" = ""; |
||||
"x64" = " Win64" |
||||
"arm" = " ARM" |
||||
} |
||||
|
||||
# Setting up Visual Studio variables to enable build |
||||
$shouldBuid = $false |
||||
If ($BUILD.IsPresent) { |
||||
$shouldBuild = Set-VS12 |
||||
} |
||||
|
||||
foreach($plat in $platforms) { |
||||
# Set proper platform name. |
||||
$platName = "" |
||||
Switch ($plat) { |
||||
"WP" { $platName = "WindowsPhone" } |
||||
"WS" { $platName = "WindowsStore" } |
||||
} |
||||
|
||||
foreach($vers in $versions) { |
||||
|
||||
foreach($arch in $architectures) { |
||||
|
||||
# Set proper architecture. For MSVS this is done by selecting proper generator |
||||
$genName = $GENERATOR |
||||
Switch ($arch) { |
||||
"ARM" { $genName = $GENERATOR + $def_architectures['arm'] } |
||||
"x64" { $genName = $GENERATOR + $def_architectures['x64'] } |
||||
} |
||||
|
||||
# Constructing path to the install binaries |
||||
# Creating these binaries will be done by building CMake-generated INSTALL project from Visual Studio |
||||
$installPath = "$SRC\bin\install\$plat\$vers\$arch" |
||||
if ($INSTALL) { |
||||
# Do not add architrecture to the path since it will be added by OCV CMake logic |
||||
$installPath = "$SRC\$INSTALL\$plat\$vers" |
||||
} |
||||
|
||||
$path = "$SRC\bin\$plat\$vers\$arch" |
||||
|
||||
L "-----------------------------------------------" |
||||
L "Target:" |
||||
L " Directory: $path" |
||||
L " Platform: $platName" |
||||
L " Version: $vers" |
||||
L " Architecture: $arch" |
||||
L " Generator: $genName" |
||||
L " Install Directory: $installPath" |
||||
|
||||
# Delete target directory if exists to ensure that CMake cache is cleared out. |
||||
If (Test-Path $path) { |
||||
Remove-Item -Recurse -Force $path |
||||
} |
||||
|
||||
# Validate if required directory exists, create if it doesn't |
||||
New-Item -ItemType Directory -Force -Path $path |
||||
|
||||
# Change location to the respective subdirectory |
||||
Push-Location -Path $path |
||||
|
||||
L "Generating project:" |
||||
L "cmake -G $genName -DCMAKE_SYSTEM_NAME:String=$platName -DCMAKE_SYSTEM_VERSION:String=$vers -DCMAKE_VS_EFFECTIVE_PLATFORMS:String=$arch -DCMAKE_INSTALL_PREFIX:PATH=$installPath $SRC" |
||||
cmake -G $genName -DCMAKE_SYSTEM_NAME:String=$platName -DCMAKE_SYSTEM_VERSION:String=$vers -DCMAKE_VS_EFFECTIVE_PLATFORMS:String=$arch -DCMAKE_INSTALL_PREFIX:PATH=$installPath $SRC |
||||
L "-----------------------------------------------" |
||||
|
||||
# REFERENCE: |
||||
# Executed from '$SRC/bin' folder. |
||||
# Targeting x86 WindowsPhone 8.1. |
||||
# cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME:String=WindowsPhone -DCMAKE_SYSTEM_VERSION:String=8.1 .. |
||||
|
||||
|
||||
# Building and installing project |
||||
Try { |
||||
If ($shouldBuild) { |
||||
L "Building and installing project:" |
||||
|
||||
Call-MSBuild "OpenCV.sln" "Debug" |
||||
Call-MSBuild "INSTALL.vcxproj" "Debug" |
||||
|
||||
Call-MSBuild "OpenCV.sln" "Release" |
||||
Call-MSBuild "INSTALL.vcxproj" "Release" |
||||
} |
||||
} Catch { |
||||
$ErrorMessage = $_.Exception.Message |
||||
L "Error: $ErrorMessage" |
||||
|
||||
# Exiting at this point will leave command line pointing at the erroneous configuration directory |
||||
exit |
||||
} |
||||
|
||||
# Return back to Sources folder |
||||
Pop-Location |
||||
} |
||||
} |
||||
} |
||||
|
||||
# Return back to Script folder |
||||
Pop-Location |
||||
} |
||||
|
||||
Function ShowHelp() { |
||||
Write-Host "Configures OpenCV and generates projects for specified verion of Visual Studio/platforms/architectures." |
||||
Write-Host "Must be executed from the sources folder containing main CMakeLists configuration." |
||||
Write-Host "Parameter keys can be shortened down to a single symbol (e.g. '-a') and are not case sensitive." |
||||
Write-Host "Proper parameter sequencing is required when omitting keys." |
||||
Write-Host "Generates the following folder structure, depending on the supplied parameters: " |
||||
Write-Host " bin/ " |
||||
Write-Host " | " |
||||
Write-Host " |-WP " |
||||
Write-Host " | ... " |
||||
Write-Host " |-WinRT " |
||||
Write-Host " | |-8.0 " |
||||
Write-Host " | |-8.1 " |
||||
Write-Host " | | |-x86 " |
||||
Write-Host " | | |-x64 " |
||||
Write-Host " | | |-ARM " |
||||
Write-Host " " |
||||
Write-Host " USAGE: " |
||||
Write-Host " Calling:" |
||||
Write-Host " PS> setup_winrt.ps1 [params]" |
||||
Write-Host " cmd> setup_winrt.bat [params]" |
||||
Write-Host " cmd> PowerShell.exe -ExecutionPolicy Unrestricted -File setup_winrt.ps1 [params]" |
||||
Write-Host " Parameters:" |
||||
Write-Host " setup_winrt [options] [platform] [version] [architecture] [generator] [install-path]" |
||||
Write-Host " setup_winrt -b 'WP' 'x86,ARM' " |
||||
Write-Host " setup_winrt -architecture x86 -platform WP " |
||||
Write-Host " setup_winrt -arc x86 -plat 'WP,WS' " |
||||
Write-Host " setup_winrt -a x86 -g 'Visual Studio 11 2012' -pl WP " |
||||
Write-Host " WHERE: " |
||||
Write-Host " options - Options to call " |
||||
Write-Host " -h: diplays command line help " |
||||
Write-Host " -b: builds BUILD_ALL and INSTALL projects for each generated configuration in both Debug and Release modes." |
||||
Write-Host " platform - Array of target platforms. " |
||||
Write-Host " Default: WP " |
||||
Write-Host " Example: 'WS,WP' " |
||||
Write-Host " Options: WP, WS ('WindowsPhone', 'WindowsStore'). " |
||||
Write-Host " Note that you'll need to use quotes to specify more than one platform. " |
||||
Write-Host " version - Array of platform versions. " |
||||
Write-Host " Default: 8.1 " |
||||
Write-Host " Example: '8.0,8.1' " |
||||
Write-Host " Options: 8.0, 8.1. Available options may be limited depending on your local setup (e.g. SDK availability). " |
||||
Write-Host " Note that you'll need to use quotes to specify more than one version. " |
||||
Write-Host " architecture - Array of target architectures to build for. " |
||||
Write-Host " Default: x86 " |
||||
Write-Host " Example: 'ARM,x64' " |
||||
Write-Host " Options: x86, ARM, x64. Available options may be limited depending on your local setup. " |
||||
Write-Host " Note that you'll need to use quotes to specify more than one architecture. " |
||||
Write-Host " generator - Visual Studio instance used to generate the projects. " |
||||
Write-Host " Default: Visual Studio 12 2013 " |
||||
Write-Host " Example: 'Visual Studio 11 2012' " |
||||
Write-Host " Use 'cmake --help' to find all available option on your machine. " |
||||
Write-Host " install-path - Path to install binaries (relative to the sources directory). " |
||||
Write-Host " Default: <src-dir>\bin\install\<platform>\<version>\<architecture> " |
||||
Write-Host " Example: '../install' " |
||||
|
||||
Exit |
||||
} |
||||
|
||||
Execute |
@ -0,0 +1,87 @@ |
||||
# Ignore thumbnails created by windows |
||||
Thumbs.db |
||||
|
||||
#ignore winrt copies of opencv files |
||||
opencl_kernels.cpp |
||||
opencl_kernels.hpp |
||||
|
||||
# Ignore files build by Visual Studio |
||||
*.obj |
||||
*.exe |
||||
*.pdb |
||||
*.aps |
||||
*.vcproj.*.user |
||||
*.vcxproj.user |
||||
*.vspscc |
||||
*_i.c |
||||
*.i |
||||
*.icf |
||||
*_p.c |
||||
*.ncb |
||||
*.suo |
||||
*.tlb |
||||
*.tlh |
||||
*.bak |
||||
*.cache |
||||
*.ilk |
||||
*.log |
||||
*.winmd |
||||
[Bb]in |
||||
[Dd]ebug*/ |
||||
*.sbr |
||||
*.sdf |
||||
obj/ |
||||
[Rr]elease*/ |
||||
_ReSharper*/ |
||||
[Tt]est[Rr]esult* |
||||
ipch/ |
||||
*.opensdf |
||||
Generated Files |
||||
AppPackages |
||||
SubmissionInfo |
||||
*.hps |
||||
|
||||
# Ignore files build by ndk and eclipse |
||||
libs/ |
||||
bin/ |
||||
obj/ |
||||
gen/ |
||||
local.properties |
||||
|
||||
# Ignore python compiled files |
||||
*.pyc |
||||
|
||||
# Ignore files build by airplay and marmalade |
||||
build_*_xcode/ |
||||
build_*_vc10/ |
||||
|
||||
# Ignore files built by xcode |
||||
*.mode*v* |
||||
*.pbxuser |
||||
*.xcbkptlist |
||||
*.xcscheme |
||||
*.xcworkspacedata |
||||
*.xcuserstate |
||||
xcschememanagement.plist |
||||
build/ |
||||
.DS_Store |
||||
._.* |
||||
xcuserdata/ |
||||
DerivedData/ |
||||
*.xccheckout |
||||
|
||||
# Ignore files built by bada |
||||
.Simulator-Debug/ |
||||
.Target-Debug/ |
||||
.Target-Release/ |
||||
|
||||
# Ignore files built by blackberry |
||||
Simulator/ |
||||
Device-Debug/ |
||||
Device-Release/ |
||||
|
||||
# Ignore vim swaps |
||||
*.swp |
||||
|
||||
# CTags |
||||
tags |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,6 @@ |
||||
Building OpenCV WinRT Samples |
||||
============================= |
||||
|
||||
Samples are created to run against x86 architecture OpenCV binaries. |
||||
|
||||
Please follow the instructions in "platforms/winrt/readme.txt" to generate and build OpenCV for WinRT. |
@ -0,0 +1,87 @@ |
||||
# Ignore thumbnails created by windows |
||||
Thumbs.db |
||||
|
||||
#ignore winrt copies of opencv files |
||||
opencl_kernels.cpp |
||||
opencl_kernels.hpp |
||||
|
||||
# Ignore files build by Visual Studio |
||||
*.obj |
||||
*.exe |
||||
*.pdb |
||||
*.aps |
||||
*.vcproj.*.user |
||||
*.vcxproj.user |
||||
*.vspscc |
||||
*_i.c |
||||
*.i |
||||
*.icf |
||||
*_p.c |
||||
*.ncb |
||||
*.suo |
||||
*.tlb |
||||
*.tlh |
||||
*.bak |
||||
*.cache |
||||
*.ilk |
||||
*.log |
||||
*.winmd |
||||
[Bb]in |
||||
[Dd]ebug*/ |
||||
*.sbr |
||||
*.sdf |
||||
obj/ |
||||
[Rr]elease*/ |
||||
_ReSharper*/ |
||||
[Tt]est[Rr]esult* |
||||
ipch/ |
||||
*.opensdf |
||||
Generated Files |
||||
AppPackages |
||||
SubmissionInfo |
||||
*.hps |
||||
|
||||
# Ignore files build by ndk and eclipse |
||||
libs/ |
||||
bin/ |
||||
obj/ |
||||
gen/ |
||||
local.properties |
||||
|
||||
# Ignore python compiled files |
||||
*.pyc |
||||
|
||||
# Ignore files build by airplay and marmalade |
||||
build_*_xcode/ |
||||
build_*_vc10/ |
||||
|
||||
# Ignore files built by xcode |
||||
*.mode*v* |
||||
*.pbxuser |
||||
*.xcbkptlist |
||||
*.xcscheme |
||||
*.xcworkspacedata |
||||
*.xcuserstate |
||||
xcschememanagement.plist |
||||
build/ |
||||
.DS_Store |
||||
._.* |
||||
xcuserdata/ |
||||
DerivedData/ |
||||
*.xccheckout |
||||
|
||||
# Ignore files built by bada |
||||
.Simulator-Debug/ |
||||
.Target-Debug/ |
||||
.Target-Release/ |
||||
|
||||
# Ignore files built by blackberry |
||||
Simulator/ |
||||
Device-Debug/ |
||||
Device-Release/ |
||||
|
||||
# Ignore vim swaps |
||||
*.swp |
||||
|
||||
# CTags |
||||
tags |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 753 B |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 483 KiB |