Merge branch 'master' into better_png_transparency

* master: (468 commits)
  added suppression for TBB valgrind issue
  update CUDA architecture flags initialization
  increase minimal supported CUDA toolkit to 6.5
  check the CPU flag correctly
  opencv_visualization: check cmdline args
  provide better error messages
  stop search of markers in Exif reader to prevent infinite loop
  Fix calibration fail on python with CALIB_THIN_PRISM_MODEL flag
  clarify CUDA arithm operations usage with mask
  fixed empty image condition in resize
  fixed memory leak in flann tests
  fisheye: add CALIB_FIX_PRINCIPAL_POINT
  get/put: more type-safety and code unification using templates
  py_tutorials: fix cv2.findContours return val
  imgproc: speed up threshold of 64F version using NEON and SSE   * use NEON under aarch64 only   * check 64F version correctly
  bigdata: add test, resolve split/merge issue
  Improved Carotene library linear resize evaluation precision and enabled it as HAL implementation.
  persistence: fixing crash with space-only values
  Removed unnecessary check for Android API level and unused flags.
  Fix for median blur of 2-channel images
  ...
This commit is contained in:
thierry
2016-07-14 14:05:16 +02:00
597 changed files with 62455 additions and 8567 deletions

View File

@@ -267,13 +267,16 @@ int JpegDecoder::getOrientation()
{
int orientation = JPEG_ORIENTATION_TL;
ExifReader reader( m_filename );
if( reader.parse() )
if (m_filename.size() > 0)
{
ExifEntry_t entry = reader.getTag( ORIENTATION );
if (entry.tag != INVALID_TAG)
ExifReader reader( m_filename );
if( reader.parse() )
{
orientation = entry.field_u16; //orientation is unsigned short, so check field_u16
ExifEntry_t entry = reader.getTag( ORIENTATION );
if (entry.tag != INVALID_TAG)
{
orientation = entry.field_u16; //orientation is unsigned short, so check field_u16
}
}
}

View File

@@ -525,7 +525,7 @@ bool Jpeg2KEncoder::writeComponent16u( void *__img, const Mat& _img )
for( int y = 0; y < h; y++ )
{
const uchar* data = _img.ptr(y);
const ushort* data = _img.ptr<ushort>(y);
for( int i = 0; i < ncmpts; i++ )
{
for( int x = 0; x < w; x++)

View File

@@ -231,8 +231,6 @@ bool PngDecoder::readData( Mat& img )
AutoBuffer<uchar*> _buffer(m_height);
uchar** buffer = _buffer;
int color = img.channels() > 2;
uchar* data = img.ptr();
int step = (int)img.step;
if( m_png_ptr && m_info_ptr && m_end_info && m_width && m_height )
{
@@ -285,7 +283,7 @@ bool PngDecoder::readData( Mat& img )
png_read_update_info( png_ptr, info_ptr );
for( y = 0; y < m_height; y++ )
buffer[y] = data + y*step;
buffer[y] = img.data + y*img.step;
png_read_image( png_ptr, buffer );
png_read_end( png_ptr, end_info );
@@ -376,22 +374,23 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
}
int compression_level = -1; // Invalid value to allow setting 0-9 as valid
int compression_strategy = Z_RLE; // Default strategy
int compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
bool isBilevel = false;
for( size_t i = 0; i < params.size(); i += 2 )
{
if( params[i] == CV_IMWRITE_PNG_COMPRESSION )
if( params[i] == IMWRITE_PNG_COMPRESSION )
{
compression_strategy = IMWRITE_PNG_STRATEGY_DEFAULT; // Default strategy
compression_level = params[i+1];
compression_level = MIN(MAX(compression_level, 0), Z_BEST_COMPRESSION);
}
if( params[i] == CV_IMWRITE_PNG_STRATEGY )
if( params[i] == IMWRITE_PNG_STRATEGY )
{
compression_strategy = params[i+1];
compression_strategy = MIN(MAX(compression_strategy, 0), Z_FIXED);
}
if( params[i] == CV_IMWRITE_PNG_BILEVEL )
if( params[i] == IMWRITE_PNG_BILEVEL )
{
isBilevel = params[i+1] != 0;
}

View File

@@ -190,7 +190,6 @@ bool PxMDecoder::readData( Mat& img )
{
int color = img.channels() > 1;
uchar* data = img.ptr();
int step = (int)img.step;
PaletteEntry palette[256];
bool result = false;
int bit_depth = CV_ELEM_SIZE1(m_type)*8;
@@ -229,7 +228,7 @@ bool PxMDecoder::readData( Mat& img )
case 1:
if( !m_binary )
{
for( y = 0; y < m_height; y++, data += step )
for( y = 0; y < m_height; y++, data += img.step )
{
for( x = 0; x < m_width; x++ )
src[x] = ReadNumber( m_strm, 1 ) != 0;
@@ -242,7 +241,7 @@ bool PxMDecoder::readData( Mat& img )
}
else
{
for( y = 0; y < m_height; y++, data += step )
for( y = 0; y < m_height; y++, data += img.step )
{
m_strm.getBytes( src, src_pitch );
@@ -258,7 +257,7 @@ bool PxMDecoder::readData( Mat& img )
////////////////////////// 8 BPP /////////////////////////
case 8:
case 24:
for( y = 0; y < m_height; y++, data += step )
for( y = 0; y < m_height; y++, data += img.step )
{
if( !m_binary )
{
@@ -310,7 +309,7 @@ bool PxMDecoder::readData( Mat& img )
}
}
else
memcpy( data, src, m_width*(bit_depth/8) );
memcpy( data, src, m_width);
}
else
{

View File

@@ -128,6 +128,11 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
size_t count;
if (m_filename.size() == 0)
{
return m_exif;
}
FILE* f = fopen( m_filename.c_str(), "rb" );
if( !f )
@@ -135,8 +140,8 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
return m_exif; //Until this moment the map is empty
}
bool exifFound = false;
while( ( !feof( f ) ) && !exifFound )
bool exifFound = false, stopSearch = false;
while( ( !feof( f ) ) && !exifFound && !stopSearch )
{
count = fread( appMarker, sizeof(unsigned char), markerSize, f );
if( count < markerSize )
@@ -165,6 +170,7 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
case APP1: //actual Exif Marker
exifSize = getFieldSize(f);
if (exifSize <= offsetToTiffHeader) {
fclose(f);
throw ExifParsingError();
}
m_data.resize( exifSize - offsetToTiffHeader );
@@ -174,6 +180,7 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
break;
default: //No other markers are expected according to standard. May be a signal of error
stopSearch = true;
break;
}
}
@@ -245,7 +252,10 @@ void ExifReader::parseExif()
*/
Endianess_t ExifReader::getFormat() const
{
if( m_data[0] != m_data[1] )
if (m_data.size() < 1)
return NONE;
if( m_data.size() > 1 && m_data[0] != m_data[1] )
{
return NONE;
}

View File

@@ -43,9 +43,7 @@
#include "precomp.hpp"
#include "rgbe.hpp"
#include <math.h>
#if !defined(__APPLE__)
#include <malloc.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>