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
d0344cd3
Commit
d0344cd3
authored
Aug 04, 2015
by
StevenPuttemans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add checks for valid input data given to parameters
make the software system dependent add LICENSE on top
parent
da0c1595
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
1 deletion
+81
-1
opencv_annotation.cpp
apps/annotation/opencv_annotation.cpp
+81
-1
No files found.
apps/annotation/opencv_annotation.cpp
View file @
d0344cd3
////////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
////////////////////////////////////////////////////////////////////////////////////////
/*****************************************************************************************************
USAGE:
./opencv_annotation -images <folder location> -annotations <ouput file>
Created by: Puttemans Steven
Created by: Puttemans Steven
- February 2015
*****************************************************************************************************/
#include <opencv2/core.hpp>
...
...
@@ -14,6 +57,12 @@ Created by: Puttemans Steven
#include <fstream>
#include <iostream>
#if defined(_WIN32)
#include <direct.h>
#else
#include <sys/stat.h>
#endif
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -178,8 +227,33 @@ int main( int argc, const char** argv )
}
}
// Check if the folder actually exists
// If -1 is returned then the folder actually exists, and thus you can continue
// In all other cases there was a folder creation and thus the folder did not exist
#if defined(_WIN32)
if
(
_mkdir
(
image_folder
.
c_str
())
!=
-
1
){
// Generate an error message
cerr
<<
"The image folder given does not exist. Please check again!"
<<
endl
;
// Remove the created folder again, to ensure a second run with same code fails again
_rmdir
(
image_folder
.
c_str
());
return
0
;
}
#else
if
(
mkdir
(
image_folder
.
c_str
(),
0777
)
!=
-
1
){
// Generate an error message
cerr
<<
"The image folder given does not exist. Please check again!"
<<
endl
;
// Remove the created folder again, to ensure a second run with same code fails again
remove
(
image_folder
.
c_str
());
return
0
;
}
#endif
// Create the outputfilestream
ofstream
output
(
annotations
.
c_str
());
if
(
!
output
.
is_open
()
){
cerr
<<
"The path for the output file contains an error and could not be opened. Please check again!"
<<
endl
;
return
0
;
}
// Return the image filenames inside the image folder
vector
<
String
>
filenames
;
...
...
@@ -193,6 +267,12 @@ int main( int argc, const char** argv )
// Read in an image
Mat
current_image
=
imread
(
filenames
[
i
]);
// Check if the image is actually read - avoid other files in the folder, because glob() takes them all
// If not then simply skip this iteration
if
(
current_image
.
empty
()){
continue
;
}
// Perform annotations & generate corresponding output
stringstream
output_stream
;
get_annotations
(
current_image
,
&
output_stream
);
...
...
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