Merge branch 'master' of git://code.opencv.org/opencv

This commit is contained in:
Marius Muja 2012-09-28 10:40:51 -07:00
commit ae4ff999d7
14 changed files with 78 additions and 25 deletions

View File

@ -50,10 +50,10 @@ namespace cv { namespace gpu { namespace device
__device__ uchar4 int_to_uchar4(unsigned int in)
{
uchar4 bytes;
bytes.x = (in && 0x000000ff) >> 0;
bytes.y = (in && 0x0000ff00) >> 8;
bytes.z = (in && 0x00ff0000) >> 16;
bytes.w = (in && 0xff000000) >> 24;
bytes.x = (in & 0x000000ff) >> 0;
bytes.y = (in & 0x0000ff00) >> 8;
bytes.z = (in & 0x00ff0000) >> 16;
bytes.w = (in & 0xff000000) >> 24;
return bytes;
}

View File

@ -548,12 +548,16 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
cudaStream_t stream = StreamAccessor::getStream(s);
DeviceInfo info;
cv::Size whole;
cv::Point offset;
if (info.supports(WARP_SHUFFLE_FUNCTIONS))
src.locateROI(whole, offset);
if (info.supports(WARP_SHUFFLE_FUNCTIONS) )
{
GpuMat srcAlligned;
if (src.cols % 16 == 0 && src.rows % 8 == 0)
if (src.cols % 16 == 0 && src.rows % 8 == 0 && offset.x % 16 == 0 && offset.y % 8 == 0)
srcAlligned = src;
else
{
@ -575,19 +579,18 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
srcAlligned = buffer;
}
sum.create(srcAlligned.rows + 1, srcAlligned.cols + 1, CV_32SC1);
sum.create(srcAlligned.rows + 1, srcAlligned.cols + 4, CV_32SC1);
if (s)
s.enqueueMemSet(sum, Scalar::all(0));
else
sum.setTo(Scalar::all(0));
GpuMat inner = sum(Rect(1, 1, srcAlligned.cols, srcAlligned.rows));
GpuMat inner = sum(Rect(4, 1, srcAlligned.cols, srcAlligned.rows));
cv::gpu::device::imgproc::shfl_integral_gpu(srcAlligned, inner, stream);
if (srcAlligned.data != src.data)
sum = sum(Rect(0, 0, src.cols + 1, src.rows + 1));
sum = sum(Rect(3, 0, src.cols + 1, src.rows + 1));
}
else
{

View File

@ -156,25 +156,45 @@ template<> struct ColorChannel<float>
///////////////////////////// Top-level template function ////////////////////////////////
template<class Cvt> void CvtColorLoop(const Mat& srcmat, Mat& dstmat, const Cvt& cvt)
template <typename Cvt>
class CvtColorLoop_Invoker :
public ParallelLoopBody
{
typedef typename Cvt::channel_type _Tp;
Size sz = srcmat.size();
const uchar* src = srcmat.data;
uchar* dst = dstmat.data;
size_t srcstep = srcmat.step, dststep = dstmat.step;
if( srcmat.isContinuous() && dstmat.isContinuous() )
public:
CvtColorLoop_Invoker(const Mat& _src, Mat& _dst, const Cvt& _cvt) :
ParallelLoopBody(), src(_src), dst(_dst), cvt(_cvt)
{
sz.width *= sz.height;
sz.height = 1;
}
virtual void operator()(const Range& range) const
{
int i = range.start;
const uchar* yS = src.data + src.step * i;
uchar* yD = dst.data + dst.step * i;
for( ; sz.height--; src += srcstep, dst += dststep )
cvt((const _Tp*)src, (_Tp*)dst, sz.width);
for ( ; i < range.end; ++i, yS += src.step, yD += dst.step )
cvt((const _Tp*)yS, (_Tp*)yD, src.cols);
}
private:
const Mat src;
Mat dst;
const Cvt cvt;
CvtColorLoop_Invoker(const CvtColorLoop_Invoker&);
const CvtColorLoop_Invoker& operator= (const CvtColorLoop_Invoker&);
};
template <typename Cvt>
void CvtColorLoop(const Mat& src, Mat& dst, const Cvt& cvt)
{
Range range(0, src.rows);
CvtColorLoop_Invoker<Cvt> invoker(src, dst, cvt);
parallel_for_(range, invoker);
}
////////////////// Various 3/4-channel to 3/4-channel RGB transformations /////////////////
template<typename _Tp> struct RGB2RGB

View File

@ -1,6 +1,7 @@
package org.opencv.test.highgui;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfInt;
import org.opencv.highgui.Highgui;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
@ -19,7 +20,20 @@ public class HighguiTest extends OpenCVTestCase {
}
public void testImencodeStringMatListOfByteListOfInteger() {
fail("Not yet implemented");
MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
/* or
MatOfInt params = new MatOfInt();
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
*/
MatOfByte buff40 = new MatOfByte();
MatOfByte buff90 = new MatOfByte();
assertTrue( Highgui.imencode(".jpg", rgbLena, buff40, params40) );
assertTrue( Highgui.imencode(".jpg", rgbLena, buff90, params90) );
assertTrue(buff40.total() > 0);
assertTrue(buff40.total() < buff90.total());
}
public void testImreadString() {

View File

@ -52,6 +52,11 @@ void cv::fastNlMeansDenoising( InputArray _src, OutputArray _dst, float h,
_dst.create(src.size(), src.type());
Mat dst = _dst.getMat();
#ifdef HAVE_TEGRA_OPTIMIZATION
if(tegra::fastNlMeansDenoising(src, dst, h, templateWindowSize, searchWindowSize))
return;
#endif
switch (src.type()) {
case CV_8U:
parallel_for(cv::BlockedRange(0, src.rows),

View File

@ -43,10 +43,14 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/photo/photo.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "opencv2/photo/photo_tegra.hpp"
#endif
#endif

View File

@ -764,7 +764,7 @@ vector<int> leaveBiggestComponent(vector<ImageFeatures> &features, vector<Match
for (size_t i = 1; i < indices_removed.size(); ++i)
LOG(", " << indices_removed[i]+1);
LOGLN(").");
LOGLN("Try to decrease --match_conf value and/or check if you're stitching duplicates.");
LOGLN("Try to decrease the match confidence threshold and/or check if you're stitching duplicates.");
features = features_subset;
pairwise_matches = pairwise_matches_subset;

View File

@ -105,6 +105,7 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}

View File

@ -110,6 +110,7 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()) / 2, null);
mFps.draw(canvas, (canvas.getWidth() - bmp.getWidth()) / 2, 0);
mHolder.unlockCanvasAndPost(canvas);

View File

@ -111,6 +111,7 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()), null);
mFps.draw(canvas, (canvas.getWidth() - bmp.getWidth()) / 2, 0);
mHolder.unlockCanvasAndPost(canvas);

View File

@ -218,6 +218,7 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - getFrameWidth()) / 2, (canvas.getHeight() - getFrameHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}

View File

@ -218,6 +218,7 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - getFrameWidth()) / 2, (canvas.getHeight() - getFrameHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}

View File

@ -218,6 +218,7 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - getFrameWidth()) / 2, (canvas.getHeight() - getFrameHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}

View File

@ -218,6 +218,7 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
canvas.drawBitmap(bmp, (canvas.getWidth() - getFrameWidth()) / 2, (canvas.getHeight() - getFrameHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}