Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -53,7 +53,7 @@ enum
|
||||
RBS_THROW_EOS=-123, // <end of stream> exception code
|
||||
RBS_THROW_FORB=-124, // <forrbidden huffman code> exception code
|
||||
RBS_HUFF_FORB=2047, // forrbidden huffman code "value"
|
||||
RBS_BAD_HEADER=-125, // invalid header
|
||||
RBS_BAD_HEADER=-125 // invalid header
|
||||
};
|
||||
|
||||
typedef unsigned long ulong;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "cap_intelperc.hpp"
|
||||
|
||||
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
|
||||
#pragma optimize("",off)
|
||||
@@ -155,6 +156,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#endif
|
||||
#ifdef HAVE_GIGE_API
|
||||
CV_CAP_GIGANETIX,
|
||||
#endif
|
||||
#ifdef HAVE_INTELPERC
|
||||
CV_CAP_INTELPERC,
|
||||
#endif
|
||||
-1
|
||||
};
|
||||
@@ -193,6 +197,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_ANDROID_NATIVE_CAMERA) || \
|
||||
defined(HAVE_GIGE_API) || \
|
||||
defined(HAVE_INTELPERC) || \
|
||||
(0)
|
||||
// local variable to memorize the captured device
|
||||
CvCapture *capture;
|
||||
@@ -341,7 +346,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
return capture;
|
||||
break; // CV_CAP_GIGANETIX
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,6 +490,7 @@ VideoCapture::VideoCapture(int device)
|
||||
|
||||
VideoCapture::~VideoCapture()
|
||||
{
|
||||
icap.release();
|
||||
cap.release();
|
||||
}
|
||||
|
||||
@@ -499,24 +504,36 @@ bool VideoCapture::open(const String& filename)
|
||||
bool VideoCapture::open(int device)
|
||||
{
|
||||
if (isOpened()) release();
|
||||
icap = createCameraCapture(device);
|
||||
if (!icap.empty())
|
||||
return true;
|
||||
cap.reset(cvCreateCameraCapture(device));
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
bool VideoCapture::isOpened() const { return !cap.empty(); }
|
||||
bool VideoCapture::isOpened() const
|
||||
{
|
||||
return (!cap.empty() || !icap.empty());
|
||||
}
|
||||
|
||||
void VideoCapture::release()
|
||||
{
|
||||
icap.release();
|
||||
cap.release();
|
||||
}
|
||||
|
||||
bool VideoCapture::grab()
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->grabFrame();
|
||||
return cvGrabFrame(cap) != 0;
|
||||
}
|
||||
|
||||
bool VideoCapture::retrieve(Mat& image, int channel)
|
||||
bool VideoCapture::retrieve(OutputArray image, int channel)
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->retrieveFrame(channel, image);
|
||||
|
||||
IplImage* _img = cvRetrieveFrame(cap, channel);
|
||||
if( !_img )
|
||||
{
|
||||
@@ -524,7 +541,7 @@ bool VideoCapture::retrieve(Mat& image, int channel)
|
||||
return false;
|
||||
}
|
||||
if(_img->origin == IPL_ORIGIN_TL)
|
||||
image = cv::cvarrToMat(_img);
|
||||
cv::cvarrToMat(_img).copyTo(image);
|
||||
else
|
||||
{
|
||||
Mat temp = cv::cvarrToMat(_img);
|
||||
@@ -533,7 +550,7 @@ bool VideoCapture::retrieve(Mat& image, int channel)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VideoCapture::read(Mat& image)
|
||||
bool VideoCapture::read(OutputArray image)
|
||||
{
|
||||
if(grab())
|
||||
retrieve(image);
|
||||
@@ -548,16 +565,70 @@ VideoCapture& VideoCapture::operator >> (Mat& image)
|
||||
return *this;
|
||||
}
|
||||
|
||||
VideoCapture& VideoCapture::operator >> (UMat& image)
|
||||
{
|
||||
read(image);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool VideoCapture::set(int propId, double value)
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->setProperty(propId, value);
|
||||
return cvSetCaptureProperty(cap, propId, value) != 0;
|
||||
}
|
||||
|
||||
double VideoCapture::get(int propId)
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->getProperty(propId);
|
||||
return cvGetCaptureProperty(cap, propId);
|
||||
}
|
||||
|
||||
Ptr<IVideoCapture> VideoCapture::createCameraCapture(int index)
|
||||
{
|
||||
int domains[] =
|
||||
{
|
||||
#ifdef HAVE_INTELPERC
|
||||
CV_CAP_INTELPERC,
|
||||
#endif
|
||||
-1, -1
|
||||
};
|
||||
|
||||
// interpret preferred interface (0 = autodetect)
|
||||
int pref = (index / 100) * 100;
|
||||
if (pref)
|
||||
{
|
||||
domains[0]=pref;
|
||||
index %= 100;
|
||||
domains[1]=-1;
|
||||
}
|
||||
|
||||
// try every possibly installed camera API
|
||||
for (int i = 0; domains[i] >= 0; i++)
|
||||
{
|
||||
#if defined(HAVE_INTELPERC) || \
|
||||
(0)
|
||||
Ptr<IVideoCapture> capture;
|
||||
|
||||
switch (domains[i])
|
||||
{
|
||||
#ifdef HAVE_INTELPERC
|
||||
case CV_CAP_INTELPERC:
|
||||
capture = Ptr<IVideoCapture>(new cv::VideoCapture_IntelPerC());
|
||||
if (capture)
|
||||
return capture;
|
||||
break; // CV_CAP_INTEL_PERC
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// failed open a camera
|
||||
return Ptr<IVideoCapture>();
|
||||
}
|
||||
|
||||
|
||||
VideoWriter::VideoWriter()
|
||||
{}
|
||||
|
||||
|
||||
@@ -289,6 +289,10 @@ double CvCapture_Android::getProperty( int propIdx )
|
||||
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_OPTIMAL);
|
||||
case CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR:
|
||||
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_FAR);
|
||||
case CV_CAP_PROP_ANDROID_EXPOSE_LOCK:
|
||||
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_EXPOSE_LOCK);
|
||||
case CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK:
|
||||
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_WHITEBALANCE_LOCK);
|
||||
default:
|
||||
CV_Error( CV_StsOutOfRange, "Failed attempt to GET unsupported camera property." );
|
||||
break;
|
||||
@@ -327,14 +331,23 @@ bool CvCapture_Android::setProperty( int propIdx, double propValue )
|
||||
case CV_CAP_PROP_ANDROID_ANTIBANDING:
|
||||
m_activity->setProperty(ANDROID_CAMERA_PROPERTY_ANTIBANDING, propValue);
|
||||
break;
|
||||
case CV_CAP_PROP_ANDROID_EXPOSE_LOCK:
|
||||
m_activity->setProperty(ANDROID_CAMERA_PROPERTY_EXPOSE_LOCK, propValue);
|
||||
break;
|
||||
case CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK:
|
||||
m_activity->setProperty(ANDROID_CAMERA_PROPERTY_WHITEBALANCE_LOCK, propValue);
|
||||
break;
|
||||
default:
|
||||
CV_Error( CV_StsOutOfRange, "Failed attempt to SET unsupported camera property." );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propIdx != CV_CAP_PROP_AUTOGRAB) {// property for highgui class CvCapture_Android only
|
||||
// Only changes in frame size require camera restart
|
||||
if ((propIdx == CV_CAP_PROP_FRAME_WIDTH) || (propIdx == CV_CAP_PROP_FRAME_HEIGHT))
|
||||
{ // property for highgui class CvCapture_Android only
|
||||
m_CameraParamsChanged = true;
|
||||
}
|
||||
|
||||
res = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -296,11 +296,7 @@ static CvCaptureCAM_DC1394 * icvCaptureFromCAM_DC1394 (int index)
|
||||
if (pcap->format!=FORMAT_SCALABLE_IMAGE_SIZE) { // everything except Format 7
|
||||
if (dc1394_dma_setup_capture(pcap->handle, pcap->camera->node, index+1 /*channel*/,
|
||||
pcap->format, pcap->mode, SPEED_400,
|
||||
pcap->frame_rate, NUM_BUFFERS,
|
||||
#ifdef HAVE_DC1394_095
|
||||
0 /*do_extra_buffering*/,
|
||||
#endif
|
||||
1 /*DROP_FRAMES*/,
|
||||
pcap->frame_rate, NUM_BUFFERS, 1 /*drop_frames*/,
|
||||
pcap->device_name, pcap->camera) != DC1394_SUCCESS) {
|
||||
fprintf(stderr,"%s:%d: Failed to setup DMA capture with VIDEO1394\n",__FILE__,__LINE__);
|
||||
goto ERROR;
|
||||
@@ -311,11 +307,7 @@ static CvCaptureCAM_DC1394 * icvCaptureFromCAM_DC1394 (int index)
|
||||
pcap->mode, SPEED_400, QUERY_FROM_CAMERA,
|
||||
(unsigned int)QUERY_FROM_CAMERA, (unsigned int)QUERY_FROM_CAMERA,
|
||||
(unsigned int)QUERY_FROM_CAMERA, (unsigned int)QUERY_FROM_CAMERA,
|
||||
NUM_BUFFERS,
|
||||
#ifdef HAVE_DC1394_095
|
||||
0 /*do_extra_buffering*/,
|
||||
#endif
|
||||
1 /*DROP_FRAMES*/,
|
||||
NUM_BUFFERS, 1 /*drop_frames*/,
|
||||
pcap->device_name, pcap->camera) != DC1394_SUCCESS) {
|
||||
fprintf(stderr,"%s:%d: Failed to setup DMA capture with VIDEO1394\n",__FILE__,__LINE__);
|
||||
goto ERROR;
|
||||
@@ -661,11 +653,7 @@ icvSetModeCAM_DC1394( CvCaptureCAM_DC1394 * capture, int mode ){
|
||||
dc1394_dma_unlisten(capture->handle, capture->camera);
|
||||
if (dc1394_dma_setup_capture(capture->handle, capture->camera->node, capture->camera->channel /*channel*/,
|
||||
format, mode, SPEED_400,
|
||||
frame_rate, NUM_BUFFERS,
|
||||
#ifdef HAVE_DC1394_095
|
||||
0 /*do_extra_buffering*/,
|
||||
#endif
|
||||
1 /*DROP_FRAMES*/,
|
||||
frame_rate, NUM_BUFFERS, 1 /*drop_frames*/,
|
||||
capture->device_name, capture->camera) != DC1394_SUCCESS) {
|
||||
fprintf(stderr,"%s:%d: Failed to setup DMA capture with VIDEO1394\n",__FILE__,__LINE__);
|
||||
return 0;
|
||||
|
||||
@@ -554,7 +554,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
|
||||
goto exit_func;
|
||||
}
|
||||
err =
|
||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 3, 0)
|
||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
|
||||
avformat_find_stream_info(ic, NULL);
|
||||
#else
|
||||
av_find_stream_info(ic);
|
||||
@@ -2096,7 +2096,7 @@ enum
|
||||
VideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,V,U (4:2:0)
|
||||
VideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,UV (4:2:0)
|
||||
VideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), // YUYV/YUY2 (4:2:2)
|
||||
VideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')), // UYVY (4:2:2)
|
||||
VideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) // UYVY (4:2:2)
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -2104,7 +2104,7 @@ enum
|
||||
VideoChromaFormat_Monochrome = 0,
|
||||
VideoChromaFormat_YUV420,
|
||||
VideoChromaFormat_YUV422,
|
||||
VideoChromaFormat_YUV444,
|
||||
VideoChromaFormat_YUV444
|
||||
};
|
||||
|
||||
struct InputMediaStream_FFMPEG
|
||||
@@ -2144,7 +2144,7 @@ bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma
|
||||
if (err < 0)
|
||||
return false;
|
||||
|
||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 3, 0)
|
||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
|
||||
err = avformat_find_stream_info(ctx_, 0);
|
||||
#else
|
||||
err = av_find_stream_info(ctx_);
|
||||
|
||||
@@ -134,7 +134,7 @@ protected:
|
||||
void startPipeline();
|
||||
void stopPipeline();
|
||||
void restartPipeline();
|
||||
void setFilter(const char* prop, int type, int v1, int v2 = NULL);
|
||||
void setFilter(const char* prop, int type, int v1, int v2 = 0);
|
||||
void removeFilter(const char *filter);
|
||||
static void newPad(GstElement *myelement,
|
||||
GstPad *pad,
|
||||
|
||||
@@ -200,10 +200,20 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
|
||||
}
|
||||
else // no pattern filename was given - extract the pattern
|
||||
{
|
||||
for(at = name; *at && !isdigit(*at); at++)
|
||||
;
|
||||
at = name;
|
||||
|
||||
if(!at)
|
||||
// ignore directory names
|
||||
char *slash = strrchr(at, '/');
|
||||
if (slash) at = slash + 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
slash = strrchr(at, '\\');
|
||||
if (slash) at = slash + 1;
|
||||
#endif
|
||||
|
||||
while (*at && !isdigit(*at)) at++;
|
||||
|
||||
if(!*at)
|
||||
return 0;
|
||||
|
||||
sscanf(at, "%u", offset);
|
||||
|
||||
634
modules/highgui/src/cap_intelperc.cpp
Normal file
634
modules/highgui/src/cap_intelperc.cpp
Normal file
@@ -0,0 +1,634 @@
|
||||
#ifdef HAVE_INTELPERC
|
||||
|
||||
#include "cap_intelperc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
///////////////// IntelPerCStreamBase //////////////////
|
||||
|
||||
IntelPerCStreamBase::IntelPerCStreamBase()
|
||||
: m_profileIdx(-1)
|
||||
, m_frameIdx(0)
|
||||
, m_timeStampStartNS(0)
|
||||
{
|
||||
}
|
||||
IntelPerCStreamBase::~IntelPerCStreamBase()
|
||||
{
|
||||
}
|
||||
|
||||
bool IntelPerCStreamBase::isValid()
|
||||
{
|
||||
return (m_device.IsValid() && m_stream.IsValid());
|
||||
}
|
||||
bool IntelPerCStreamBase::grabFrame()
|
||||
{
|
||||
if (!m_stream.IsValid())
|
||||
return false;
|
||||
if (-1 == m_profileIdx)
|
||||
{
|
||||
if (!setProperty(CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0))
|
||||
return false;
|
||||
}
|
||||
PXCSmartSP sp;
|
||||
m_pxcImage.ReleaseRef();
|
||||
if (PXC_STATUS_NO_ERROR > m_stream->ReadStreamAsync(&m_pxcImage, &sp))
|
||||
return false;
|
||||
if (PXC_STATUS_NO_ERROR > sp->Synchronize())
|
||||
return false;
|
||||
if (0 == m_timeStampStartNS)
|
||||
m_timeStampStartNS = m_pxcImage->QueryTimeStamp();
|
||||
m_timeStamp = (double)((m_pxcImage->QueryTimeStamp() - m_timeStampStartNS) / 10000);
|
||||
m_frameIdx++;
|
||||
return true;
|
||||
}
|
||||
int IntelPerCStreamBase::getProfileIDX() const
|
||||
{
|
||||
return m_profileIdx;
|
||||
}
|
||||
double IntelPerCStreamBase::getProperty(int propIdx)
|
||||
{
|
||||
double ret = 0.0;
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_PROFILE_COUNT:
|
||||
ret = (double)m_profiles.size();
|
||||
break;
|
||||
case CV_CAP_PROP_FRAME_WIDTH :
|
||||
if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size()))
|
||||
ret = (double)m_profiles[m_profileIdx].imageInfo.width;
|
||||
break;
|
||||
case CV_CAP_PROP_FRAME_HEIGHT :
|
||||
if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size()))
|
||||
ret = (double)m_profiles[m_profileIdx].imageInfo.height;
|
||||
break;
|
||||
case CV_CAP_PROP_FPS :
|
||||
if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size()))
|
||||
{
|
||||
ret = ((double)m_profiles[m_profileIdx].frameRateMin.numerator / (double)m_profiles[m_profileIdx].frameRateMin.denominator
|
||||
+ (double)m_profiles[m_profileIdx].frameRateMax.numerator / (double)m_profiles[m_profileIdx].frameRateMax.denominator) / 2.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_POS_FRAMES:
|
||||
ret = (double)m_frameIdx;
|
||||
break;
|
||||
case CV_CAP_PROP_POS_MSEC:
|
||||
ret = m_timeStamp;
|
||||
break;
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
bool IntelPerCStreamBase::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
bool isSet = false;
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_PROFILE_IDX:
|
||||
{
|
||||
int propValInt = (int)propVal;
|
||||
if (0 > propValInt)
|
||||
{
|
||||
m_profileIdx = propValInt;
|
||||
isSet = true;
|
||||
}
|
||||
else if (propValInt < m_profiles.size())
|
||||
{
|
||||
if (m_profileIdx != propValInt)
|
||||
{
|
||||
m_profileIdx = propValInt;
|
||||
if (m_stream.IsValid())
|
||||
m_stream->SetProfile(&m_profiles[m_profileIdx]);
|
||||
m_frameIdx = 0;
|
||||
m_timeStampStartNS = 0;
|
||||
}
|
||||
isSet = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
return isSet;
|
||||
}
|
||||
bool IntelPerCStreamBase::initDevice(PXCSession *session)
|
||||
{
|
||||
if (NULL == session)
|
||||
return false;
|
||||
|
||||
pxcStatus sts = PXC_STATUS_NO_ERROR;
|
||||
PXCSession::ImplDesc templat;
|
||||
memset(&templat,0,sizeof(templat));
|
||||
templat.group = PXCSession::IMPL_GROUP_SENSOR;
|
||||
templat.subgroup= PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE;
|
||||
|
||||
for (int modidx = 0; PXC_STATUS_NO_ERROR <= sts; modidx++)
|
||||
{
|
||||
PXCSession::ImplDesc desc;
|
||||
sts = session->QueryImpl(&templat, modidx, &desc);
|
||||
if (PXC_STATUS_NO_ERROR > sts)
|
||||
break;
|
||||
|
||||
PXCSmartPtr<PXCCapture> capture;
|
||||
sts = session->CreateImpl<PXCCapture>(&desc, &capture);
|
||||
if (!capture.IsValid())
|
||||
continue;
|
||||
|
||||
/* enumerate devices */
|
||||
for (int devidx = 0; PXC_STATUS_NO_ERROR <= sts; devidx++)
|
||||
{
|
||||
PXCSmartPtr<PXCCapture::Device> device;
|
||||
sts = capture->CreateDevice(devidx, &device);
|
||||
if (PXC_STATUS_NO_ERROR <= sts)
|
||||
{
|
||||
m_device = device.ReleasePtr();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void IntelPerCStreamBase::initStreamImpl(PXCImage::ImageType type)
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return;
|
||||
|
||||
pxcStatus sts = PXC_STATUS_NO_ERROR;
|
||||
/* enumerate streams */
|
||||
for (int streamidx = 0; PXC_STATUS_NO_ERROR <= sts; streamidx++)
|
||||
{
|
||||
PXCCapture::Device::StreamInfo sinfo;
|
||||
sts = m_device->QueryStream(streamidx, &sinfo);
|
||||
if (PXC_STATUS_NO_ERROR > sts)
|
||||
break;
|
||||
if (PXCCapture::VideoStream::CUID != sinfo.cuid)
|
||||
continue;
|
||||
if (type != sinfo.imageType)
|
||||
continue;
|
||||
|
||||
sts = m_device->CreateStream<PXCCapture::VideoStream>(streamidx, &m_stream);
|
||||
if (PXC_STATUS_NO_ERROR == sts)
|
||||
break;
|
||||
m_stream.ReleaseRef();
|
||||
}
|
||||
}
|
||||
bool IntelPerCStreamBase::validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void IntelPerCStreamBase::enumProfiles()
|
||||
{
|
||||
m_profiles.clear();
|
||||
if (!m_stream.IsValid())
|
||||
return;
|
||||
pxcStatus sts = PXC_STATUS_NO_ERROR;
|
||||
for (int profidx = 0; PXC_STATUS_NO_ERROR <= sts; profidx++)
|
||||
{
|
||||
PXCCapture::VideoStream::ProfileInfo pinfo;
|
||||
sts = m_stream->QueryProfile(profidx, &pinfo);
|
||||
if (PXC_STATUS_NO_ERROR > sts)
|
||||
break;
|
||||
if (validProfile(pinfo))
|
||||
m_profiles.push_back(pinfo);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////// IntelPerCStreamImage //////////////////
|
||||
|
||||
IntelPerCStreamImage::IntelPerCStreamImage()
|
||||
{
|
||||
}
|
||||
IntelPerCStreamImage::~IntelPerCStreamImage()
|
||||
{
|
||||
}
|
||||
|
||||
bool IntelPerCStreamImage::initStream(PXCSession *session)
|
||||
{
|
||||
if (!initDevice(session))
|
||||
return false;
|
||||
initStreamImpl(PXCImage::IMAGE_TYPE_COLOR);
|
||||
if (!m_stream.IsValid())
|
||||
return false;
|
||||
enumProfiles();
|
||||
return true;
|
||||
}
|
||||
double IntelPerCStreamImage::getProperty(int propIdx)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_BRIGHTNESS:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_BRIGHTNESS, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_CONTRAST:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_CONTRAST, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_SATURATION:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_SATURATION, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_HUE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_HUE, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_GAMMA:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_GAMMA, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_SHARPNESS:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_SHARPNESS, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_GAIN:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_GAIN, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_BACKLIGHT:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_BACK_LIGHT_COMPENSATION, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_EXPOSURE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_EXPOSURE, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
//Add image stream specific properties
|
||||
}
|
||||
return IntelPerCStreamBase::getProperty(propIdx);
|
||||
}
|
||||
bool IntelPerCStreamImage::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_BRIGHTNESS:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_BRIGHTNESS, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_CONTRAST:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_CONTRAST, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_SATURATION:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_SATURATION, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_HUE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_HUE, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_GAMMA:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_GAMMA, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_SHARPNESS:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_SHARPNESS, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_GAIN:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_GAIN, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_BACKLIGHT:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_BACK_LIGHT_COMPENSATION, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_EXPOSURE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_EXPOSURE, (float)propVal));
|
||||
}
|
||||
break;
|
||||
//Add image stream specific properties
|
||||
}
|
||||
return IntelPerCStreamBase::setProperty(propIdx, propVal);
|
||||
}
|
||||
bool IntelPerCStreamImage::retrieveAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
if (!m_pxcImage.IsValid())
|
||||
return false;
|
||||
PXCImage::ImageInfo info;
|
||||
m_pxcImage->QueryInfo(&info);
|
||||
|
||||
PXCImage::ImageData data;
|
||||
m_pxcImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::COLOR_FORMAT_RGB24, &data);
|
||||
|
||||
if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type)
|
||||
return false;
|
||||
|
||||
cv::Mat temp(info.height, info.width, CV_8UC3, data.planes[0], data.pitches[0]);
|
||||
temp.copyTo(image);
|
||||
|
||||
m_pxcImage->ReleaseAccess(&data);
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////// IntelPerCStreamDepth //////////////////
|
||||
|
||||
IntelPerCStreamDepth::IntelPerCStreamDepth()
|
||||
{
|
||||
}
|
||||
IntelPerCStreamDepth::~IntelPerCStreamDepth()
|
||||
{
|
||||
}
|
||||
|
||||
bool IntelPerCStreamDepth::initStream(PXCSession *session)
|
||||
{
|
||||
if (!initDevice(session))
|
||||
return false;
|
||||
initStreamImpl(PXCImage::IMAGE_TYPE_DEPTH);
|
||||
if (!m_stream.IsValid())
|
||||
return false;
|
||||
enumProfiles();
|
||||
return true;
|
||||
}
|
||||
double IntelPerCStreamDepth::getProperty(int propIdx)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0;
|
||||
float fret = 0.0f;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, &fret))
|
||||
return (double)fret;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0f;
|
||||
PXCPointF32 ptf;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH, &ptf))
|
||||
return (double)ptf.x;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return 0.0f;
|
||||
PXCPointF32 ptf;
|
||||
if (PXC_STATUS_NO_ERROR == m_device->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH, &ptf))
|
||||
return (double)ptf.y;
|
||||
return 0.0;
|
||||
}
|
||||
break;
|
||||
//Add depth stream sepcific properties
|
||||
}
|
||||
return IntelPerCStreamBase::getProperty(propIdx);
|
||||
}
|
||||
bool IntelPerCStreamDepth::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE, (float)propVal));
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD:
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return false;
|
||||
return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, (float)propVal));
|
||||
}
|
||||
break;
|
||||
//Add depth stream sepcific properties
|
||||
}
|
||||
return IntelPerCStreamBase::setProperty(propIdx, propVal);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retrieveDepthAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
return retriveFrame(CV_16SC1, 0, image);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retrieveIRAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
return retriveFrame(CV_16SC1, 1, image);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retrieveUVAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
return retriveFrame(CV_32FC2, 2, image);
|
||||
}
|
||||
bool IntelPerCStreamDepth::validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo)
|
||||
{
|
||||
return (PXCImage::COLOR_FORMAT_DEPTH == pinfo.imageInfo.format);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retriveFrame(int type, int planeIdx, cv::OutputArray frame)
|
||||
{
|
||||
if (!m_pxcImage.IsValid())
|
||||
return false;
|
||||
PXCImage::ImageInfo info;
|
||||
m_pxcImage->QueryInfo(&info);
|
||||
|
||||
PXCImage::ImageData data;
|
||||
m_pxcImage->AcquireAccess(PXCImage::ACCESS_READ, &data);
|
||||
|
||||
if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type)
|
||||
return false;
|
||||
|
||||
cv::Mat temp(info.height, info.width, type, data.planes[planeIdx], data.pitches[planeIdx]);
|
||||
temp.copyTo(frame);
|
||||
|
||||
m_pxcImage->ReleaseAccess(&data);
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////// VideoCapture_IntelPerC //////////////////
|
||||
|
||||
VideoCapture_IntelPerC::VideoCapture_IntelPerC()
|
||||
: m_contextOpened(false)
|
||||
{
|
||||
pxcStatus sts = PXCSession_Create(&m_session);
|
||||
if (PXC_STATUS_NO_ERROR > sts)
|
||||
return;
|
||||
m_contextOpened = m_imageStream.initStream(m_session);
|
||||
m_contextOpened &= m_depthStream.initStream(m_session);
|
||||
}
|
||||
VideoCapture_IntelPerC::~VideoCapture_IntelPerC(){}
|
||||
|
||||
double VideoCapture_IntelPerC::getProperty(int propIdx)
|
||||
{
|
||||
double propValue = 0;
|
||||
int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK;
|
||||
if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
|
||||
{
|
||||
propValue = m_imageStream.getProperty(purePropIdx);
|
||||
}
|
||||
else if (CV_CAP_INTELPERC_DEPTH_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
|
||||
{
|
||||
propValue = m_depthStream.getProperty(purePropIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
propValue = m_depthStream.getProperty(purePropIdx);
|
||||
}
|
||||
return propValue;
|
||||
}
|
||||
bool VideoCapture_IntelPerC::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
bool isSet = false;
|
||||
int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK;
|
||||
if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
|
||||
{
|
||||
isSet = m_imageStream.setProperty(purePropIdx, propVal);
|
||||
}
|
||||
else if (CV_CAP_INTELPERC_DEPTH_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
|
||||
{
|
||||
isSet = m_depthStream.setProperty(purePropIdx, propVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
isSet = m_depthStream.setProperty(purePropIdx, propVal);
|
||||
}
|
||||
return isSet;
|
||||
}
|
||||
|
||||
bool VideoCapture_IntelPerC::grabFrame()
|
||||
{
|
||||
if (!isOpened())
|
||||
return false;
|
||||
|
||||
bool isGrabbed = false;
|
||||
if (m_depthStream.isValid())
|
||||
isGrabbed = m_depthStream.grabFrame();
|
||||
if ((m_imageStream.isValid()) && (-1 != m_imageStream.getProfileIDX()))
|
||||
isGrabbed &= m_imageStream.grabFrame();
|
||||
|
||||
return isGrabbed;
|
||||
}
|
||||
bool VideoCapture_IntelPerC::retrieveFrame(int outputType, cv::OutputArray frame)
|
||||
{
|
||||
switch (outputType)
|
||||
{
|
||||
case CV_CAP_INTELPERC_DEPTH_MAP:
|
||||
return m_depthStream.retrieveDepthAsOutputArray(frame);
|
||||
case CV_CAP_INTELPERC_UVDEPTH_MAP:
|
||||
return m_depthStream.retrieveUVAsOutputArray(frame);
|
||||
case CV_CAP_INTELPERC_IR_MAP:
|
||||
return m_depthStream.retrieveIRAsOutputArray(frame);
|
||||
case CV_CAP_INTELPERC_IMAGE:
|
||||
return m_imageStream.retrieveAsOutputArray(frame);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int VideoCapture_IntelPerC::getCaptureDomain()
|
||||
{
|
||||
return CV_CAP_INTELPERC;
|
||||
}
|
||||
|
||||
bool VideoCapture_IntelPerC::isOpened() const
|
||||
{
|
||||
return m_contextOpened;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //HAVE_INTELPERC
|
||||
115
modules/highgui/src/cap_intelperc.hpp
Normal file
115
modules/highgui/src/cap_intelperc.hpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef _CAP_INTELPERC_HPP_
|
||||
#define _CAP_INTELPERC_HPP_
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_INTELPERC
|
||||
|
||||
#include "pxcsession.h"
|
||||
#include "pxcsmartptr.h"
|
||||
#include "pxccapture.h"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
class IntelPerCStreamBase
|
||||
{
|
||||
public:
|
||||
IntelPerCStreamBase();
|
||||
virtual ~IntelPerCStreamBase();
|
||||
|
||||
bool isValid();
|
||||
bool grabFrame();
|
||||
int getProfileIDX() const;
|
||||
public:
|
||||
virtual bool initStream(PXCSession *session) = 0;
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
protected:
|
||||
PXCSmartPtr<PXCCapture::Device> m_device;
|
||||
bool initDevice(PXCSession *session);
|
||||
|
||||
PXCSmartPtr<PXCCapture::VideoStream> m_stream;
|
||||
void initStreamImpl(PXCImage::ImageType type);
|
||||
protected:
|
||||
std::vector<PXCCapture::VideoStream::ProfileInfo> m_profiles;
|
||||
int m_profileIdx;
|
||||
int m_frameIdx;
|
||||
pxcU64 m_timeStampStartNS;
|
||||
double m_timeStamp;
|
||||
PXCSmartPtr<PXCImage> m_pxcImage;
|
||||
|
||||
virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/);
|
||||
void enumProfiles();
|
||||
};
|
||||
|
||||
class IntelPerCStreamImage
|
||||
: public IntelPerCStreamBase
|
||||
{
|
||||
public:
|
||||
IntelPerCStreamImage();
|
||||
virtual ~IntelPerCStreamImage();
|
||||
|
||||
virtual bool initStream(PXCSession *session);
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
public:
|
||||
bool retrieveAsOutputArray(OutputArray image);
|
||||
};
|
||||
|
||||
class IntelPerCStreamDepth
|
||||
: public IntelPerCStreamBase
|
||||
{
|
||||
public:
|
||||
IntelPerCStreamDepth();
|
||||
virtual ~IntelPerCStreamDepth();
|
||||
|
||||
virtual bool initStream(PXCSession *session);
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
public:
|
||||
bool retrieveDepthAsOutputArray(OutputArray image);
|
||||
bool retrieveIRAsOutputArray(OutputArray image);
|
||||
bool retrieveUVAsOutputArray(OutputArray image);
|
||||
protected:
|
||||
virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo);
|
||||
protected:
|
||||
bool retriveFrame(int type, int planeIdx, OutputArray frame);
|
||||
};
|
||||
|
||||
class VideoCapture_IntelPerC : public IVideoCapture
|
||||
{
|
||||
public:
|
||||
VideoCapture_IntelPerC();
|
||||
virtual ~VideoCapture_IntelPerC();
|
||||
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
|
||||
virtual bool grabFrame();
|
||||
virtual bool retrieveFrame(int outputType, OutputArray frame);
|
||||
virtual int getCaptureDomain();
|
||||
bool isOpened() const;
|
||||
protected:
|
||||
bool m_contextOpened;
|
||||
|
||||
PXCSmartPtr<PXCSession> m_session;
|
||||
IntelPerCStreamImage m_imageStream;
|
||||
IntelPerCStreamDepth m_depthStream;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HAVE_INTELPERC
|
||||
#endif //_CAP_INTELPERC_HPP_
|
||||
@@ -278,8 +278,20 @@
|
||||
{
|
||||
self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
|
||||
|
||||
if ([self.captureVideoPreviewLayer isOrientationSupported]) {
|
||||
[self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation];
|
||||
if ([self.captureVideoPreviewLayer respondsToSelector:@selector(connection)])
|
||||
{
|
||||
if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported])
|
||||
{
|
||||
[self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Deprecated in 6.0; here for backward compatibility
|
||||
if ([self.captureVideoPreviewLayer isOrientationSupported])
|
||||
{
|
||||
[self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation];
|
||||
}
|
||||
}
|
||||
|
||||
if (parentView != nil) {
|
||||
@@ -290,9 +302,6 @@
|
||||
NSLog(@"[Camera] created AVCaptureVideoPreviewLayer");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (void)setDesiredCameraPosition:(AVCaptureDevicePosition)desiredPosition;
|
||||
{
|
||||
for (AVCaptureDevice *device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#import <AssetsLibrary/AssetsLibrary.h>
|
||||
|
||||
|
||||
static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}
|
||||
|
||||
#pragma mark - Private Interface
|
||||
|
||||
|
||||
@@ -321,7 +321,6 @@ typedef struct CvCaptureCAM_V4L
|
||||
struct v4l2_control control;
|
||||
enum v4l2_buf_type type;
|
||||
struct v4l2_queryctrl queryctrl;
|
||||
struct v4l2_querymenu querymenu;
|
||||
|
||||
/* V4L2 control variables */
|
||||
v4l2_ctrl_range** v4l2_ctrl_ranges;
|
||||
@@ -491,25 +490,6 @@ static int try_init_v4l2(CvCaptureCAM_V4L* capture, char *deviceName)
|
||||
}
|
||||
|
||||
|
||||
static void v4l2_scan_controls_enumerate_menu(CvCaptureCAM_V4L* capture)
|
||||
{
|
||||
// printf (" Menu items:\n");
|
||||
CLEAR (capture->querymenu);
|
||||
capture->querymenu.id = capture->queryctrl.id;
|
||||
for (capture->querymenu.index = capture->queryctrl.minimum;
|
||||
(int)capture->querymenu.index <= capture->queryctrl.maximum;
|
||||
capture->querymenu.index++)
|
||||
{
|
||||
if (0 == xioctl (capture->deviceHandle, VIDIOC_QUERYMENU,
|
||||
&capture->querymenu))
|
||||
{
|
||||
//printf (" %s\n", capture->querymenu.name);
|
||||
} else {
|
||||
perror ("VIDIOC_QUERYMENU");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void v4l2_free_ranges(CvCaptureCAM_V4L* capture) {
|
||||
int i;
|
||||
if (capture->v4l2_ctrl_ranges != NULL) {
|
||||
@@ -590,9 +570,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) {
|
||||
if(capture->queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
|
||||
continue;
|
||||
}
|
||||
if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) {
|
||||
v4l2_scan_controls_enumerate_menu(capture);
|
||||
}
|
||||
if(capture->queryctrl.type != V4L2_CTRL_TYPE_INTEGER &&
|
||||
capture->queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN &&
|
||||
capture->queryctrl.type != V4L2_CTRL_TYPE_MENU) {
|
||||
@@ -613,9 +590,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) {
|
||||
if(capture->queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
|
||||
continue;
|
||||
}
|
||||
if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) {
|
||||
v4l2_scan_controls_enumerate_menu(capture);
|
||||
}
|
||||
if(capture->queryctrl.type != V4L2_CTRL_TYPE_INTEGER &&
|
||||
capture->queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN &&
|
||||
capture->queryctrl.type != V4L2_CTRL_TYPE_MENU) {
|
||||
@@ -637,9 +611,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU) {
|
||||
v4l2_scan_controls_enumerate_menu(capture);
|
||||
}
|
||||
|
||||
if(capture->queryctrl.type != V4L2_CTRL_TYPE_INTEGER &&
|
||||
capture->queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN &&
|
||||
@@ -856,8 +827,7 @@ static int _capture_V4L (CvCaptureCAM_V4L *capture, char *deviceName)
|
||||
|
||||
detect_v4l = try_init_v4l(capture, deviceName);
|
||||
|
||||
if ((detect_v4l == -1)
|
||||
)
|
||||
if (detect_v4l == -1)
|
||||
{
|
||||
fprintf (stderr, "HIGHGUI ERROR: V4L"
|
||||
": device %s: Unable to open for READ ONLY\n", deviceName);
|
||||
@@ -865,8 +835,7 @@ static int _capture_V4L (CvCaptureCAM_V4L *capture, char *deviceName)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((detect_v4l <= 0)
|
||||
)
|
||||
if (detect_v4l <= 0)
|
||||
{
|
||||
fprintf (stderr, "HIGHGUI ERROR: V4L"
|
||||
": device %s: Unable to query number of channels\n", deviceName);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
3187
modules/highgui/src/cap_msmf.hpp
Normal file
3187
modules/highgui/src/cap_msmf.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -105,7 +105,9 @@ public:
|
||||
context(_context), depthGenerator(_depthGenerator), imageGenerator(_imageGenerator),
|
||||
maxBufferSize(_maxBufferSize), isCircleBuffer(_isCircleBuffer), maxTimeDuration(_maxTimeDuration)
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
task = 0;
|
||||
#endif
|
||||
|
||||
CV_Assert( depthGenerator.IsValid() );
|
||||
CV_Assert( imageGenerator.IsValid() );
|
||||
@@ -150,7 +152,7 @@ public:
|
||||
task = new( tbb::task::allocate_root() ) TBBApproximateSynchronizerTask( *this );
|
||||
tbb::task::enqueue(*task);
|
||||
#else
|
||||
task = new ApproximateSynchronizer( *this );
|
||||
task.reset( new ApproximateSynchronizer( *this ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -171,6 +173,9 @@ public:
|
||||
xn::ImageGenerator &imageGenerator;
|
||||
|
||||
private:
|
||||
ApproximateSyncGrabber(const ApproximateSyncGrabber&);
|
||||
ApproximateSyncGrabber& operator=(const ApproximateSyncGrabber&);
|
||||
|
||||
int maxBufferSize;
|
||||
bool isCircleBuffer;
|
||||
int maxTimeDuration;
|
||||
@@ -214,7 +219,7 @@ private:
|
||||
virtual bool grab( xn::DepthMetaData& depthMetaData,
|
||||
xn::ImageMetaData& imageMetaData )
|
||||
{
|
||||
while(1)
|
||||
for(;;)
|
||||
{
|
||||
if( !isDepthFilled )
|
||||
isDepthFilled = popDepthMetaData(depth);
|
||||
@@ -270,13 +275,13 @@ private:
|
||||
|
||||
virtual inline void pushDepthMetaData( xn::DepthMetaData& depthMetaData )
|
||||
{
|
||||
cv::Ptr<xn::DepthMetaData> depthPtr = new xn::DepthMetaData;
|
||||
cv::Ptr<xn::DepthMetaData> depthPtr = cv::makePtr<xn::DepthMetaData>();
|
||||
depthPtr->CopyFrom(depthMetaData);
|
||||
depthQueue.push(depthPtr);
|
||||
}
|
||||
virtual inline void pushImageMetaData( xn::ImageMetaData& imageMetaData )
|
||||
{
|
||||
cv::Ptr<xn::ImageMetaData> imagePtr = new xn::ImageMetaData;
|
||||
cv::Ptr<xn::ImageMetaData> imagePtr = cv::makePtr<xn::ImageMetaData>();
|
||||
imagePtr->CopyFrom(imageMetaData);
|
||||
imageQueue.push(imagePtr);
|
||||
}
|
||||
@@ -309,15 +314,15 @@ private:
|
||||
class TBBApproximateSynchronizer: public ApproximateSynchronizerBase
|
||||
{
|
||||
public:
|
||||
TBBApproximateSynchronizer( ApproximateSyncGrabber& approxSyncGrabber ) :
|
||||
ApproximateSynchronizerBase(approxSyncGrabber)
|
||||
TBBApproximateSynchronizer( ApproximateSyncGrabber& _approxSyncGrabber ) :
|
||||
ApproximateSynchronizerBase(_approxSyncGrabber)
|
||||
{
|
||||
setMaxBufferSize();
|
||||
}
|
||||
|
||||
void setMaxBufferSize()
|
||||
{
|
||||
int maxBufferSize = ApproximateSynchronizerBase::approxSyncGrabber.getMaxBufferSize();
|
||||
int maxBufferSize = approxSyncGrabber.getMaxBufferSize();
|
||||
if( maxBufferSize >= 0 )
|
||||
{
|
||||
depthQueue.set_capacity( maxBufferSize );
|
||||
@@ -329,7 +334,7 @@ private:
|
||||
|
||||
virtual inline void pushDepthMetaData( xn::DepthMetaData& depthMetaData )
|
||||
{
|
||||
cv::Ptr<xn::DepthMetaData> depthPtr = new xn::DepthMetaData, tmp;
|
||||
cv::Ptr<xn::DepthMetaData> depthPtr = cv::makePtr<xn::DepthMetaData>(), tmp;
|
||||
depthPtr->CopyFrom(depthMetaData);
|
||||
|
||||
tbb::mutex mtx;
|
||||
@@ -347,7 +352,7 @@ private:
|
||||
|
||||
virtual inline void pushImageMetaData( xn::ImageMetaData& imageMetaData )
|
||||
{
|
||||
cv::Ptr<xn::ImageMetaData> imagePtr = new xn::ImageMetaData, tmp;
|
||||
cv::Ptr<xn::ImageMetaData> imagePtr = cv::makePtr<xn::ImageMetaData>(), tmp;
|
||||
imagePtr->CopyFrom(imageMetaData);
|
||||
|
||||
tbb::mutex mtx;
|
||||
@@ -872,7 +877,7 @@ bool CvCapture_OpenNI::setCommonProperty( int propIdx, double propValue )
|
||||
// start synchronization
|
||||
if( approxSyncGrabber.empty() )
|
||||
{
|
||||
approxSyncGrabber = new ApproximateSyncGrabber( context, depthGenerator, imageGenerator, maxBufferSize, isCircleBuffer, maxTimeDuration );
|
||||
approxSyncGrabber.reset(new ApproximateSyncGrabber( context, depthGenerator, imageGenerator, maxBufferSize, isCircleBuffer, maxTimeDuration ));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -951,7 +956,7 @@ double CvCapture_OpenNI::getDepthGeneratorProperty( int propIdx )
|
||||
propValue = depthGenerator.GetAlternativeViewPointCap().IsViewPointAs(imageGenerator) ? 1.0 : 0.0;
|
||||
break;
|
||||
case CV_CAP_PROP_POS_MSEC :
|
||||
propValue = depthGenerator.GetTimestamp();
|
||||
propValue = (double)depthGenerator.GetTimestamp();
|
||||
break;
|
||||
case CV_CAP_PROP_POS_FRAMES :
|
||||
propValue = depthGenerator.GetFrameID();
|
||||
@@ -1039,10 +1044,10 @@ double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx )
|
||||
propValue = mode.nFPS;
|
||||
break;
|
||||
case CV_CAP_PROP_POS_MSEC :
|
||||
propValue = imageGenerator.GetTimestamp();
|
||||
propValue = (double)imageGenerator.GetTimestamp();
|
||||
break;
|
||||
case CV_CAP_PROP_POS_FRAMES :
|
||||
propValue = imageGenerator.GetFrameID();
|
||||
propValue = (double)imageGenerator.GetFrameID();
|
||||
break;
|
||||
default :
|
||||
CV_Error( CV_StsBadArg, cv::format("Image generator does not support such parameter (propIdx=%d) for getting.\n", propIdx) );
|
||||
@@ -1175,8 +1180,8 @@ IplImage* CvCapture_OpenNI::retrievePointCloudMap()
|
||||
int cols = depthMetaData.XRes(), rows = depthMetaData.YRes();
|
||||
cv::Mat pointCloud_XYZ( rows, cols, CV_32FC3, cv::Scalar::all(badPoint) );
|
||||
|
||||
cv::Ptr<XnPoint3D> proj = new XnPoint3D[cols*rows];
|
||||
cv::Ptr<XnPoint3D> real = new XnPoint3D[cols*rows];
|
||||
std::vector<XnPoint3D> proj(cols*rows);
|
||||
std::vector<XnPoint3D> real(cols*rows);
|
||||
for( int y = 0; y < rows; y++ )
|
||||
{
|
||||
for( int x = 0; x < cols; x++ )
|
||||
@@ -1187,7 +1192,7 @@ IplImage* CvCapture_OpenNI::retrievePointCloudMap()
|
||||
proj[ind].Z = depth.at<unsigned short>(y, x);
|
||||
}
|
||||
}
|
||||
depthGenerator.ConvertProjectiveToRealWorld(cols*rows, proj, real);
|
||||
depthGenerator.ConvertProjectiveToRealWorld(cols*rows, &proj.front(), &real.front());
|
||||
|
||||
for( int y = 0; y < rows; y++ )
|
||||
{
|
||||
|
||||
@@ -254,6 +254,11 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
||||
case CV_CAP_PROP_FRAME_HEIGHT:
|
||||
PvAttrUint32Get(Camera.Handle, "Height", &nTemp);
|
||||
return (double)nTemp;
|
||||
case CV_CAP_PROP_MONOCROME:
|
||||
if (monocrome)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
case CV_CAP_PROP_EXPOSURE:
|
||||
PvAttrUint32Get(Camera.Handle,"ExposureValue",&nTemp);
|
||||
return (double)nTemp;
|
||||
@@ -280,6 +285,21 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
||||
case CV_CAP_PROP_GAIN:
|
||||
PvAttrUint32Get(Camera.Handle, "GainValue", &nTemp);
|
||||
return (double)nTemp;
|
||||
case CV_CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE:
|
||||
char triggerMode[256];
|
||||
PvAttrEnumGet(Camera.Handle, "FrameStartTriggerMode", triggerMode, 256, NULL);
|
||||
if (strcmp(triggerMode, "Freerun")==0)
|
||||
return 0.0;
|
||||
else if (strcmp(triggerMode, "SyncIn1")==0)
|
||||
return 1.0;
|
||||
else if (strcmp(triggerMode, "SyncIn2")==0)
|
||||
return 2.0;
|
||||
else if (strcmp(triggerMode, "FixedRate")==0)
|
||||
return 3.0;
|
||||
else if (strcmp(triggerMode, "Software")==0)
|
||||
return 4.0;
|
||||
else
|
||||
return -1.0;
|
||||
}
|
||||
return -1.0;
|
||||
}
|
||||
@@ -368,6 +388,24 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE:
|
||||
tPvErr error;
|
||||
if (value==0)
|
||||
error = PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun");
|
||||
else if (value==1)
|
||||
error = PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "SyncIn1");
|
||||
else if (value==2)
|
||||
error = PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "SyncIn2");
|
||||
else if (value==3)
|
||||
error = PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "FixedRate");
|
||||
else if (value==4)
|
||||
error = PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Software");
|
||||
else
|
||||
error = ePvErrOutOfRange;
|
||||
if(error==ePvErrSuccess)
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ private:
|
||||
int changedPos;
|
||||
|
||||
int started;
|
||||
QTTime endOfMovie;
|
||||
};
|
||||
|
||||
|
||||
@@ -287,11 +288,17 @@ bool CvCaptureCAM::grabFrame(double timeOut) {
|
||||
double sleepTime = 0.005;
|
||||
double total = 0;
|
||||
|
||||
NSDate *loopUntil = [NSDate dateWithTimeIntervalSinceNow:sleepTime];
|
||||
while (![capture updateImage] && (total += sleepTime)<=timeOut &&
|
||||
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
|
||||
beforeDate:loopUntil])
|
||||
loopUntil = [NSDate dateWithTimeIntervalSinceNow:sleepTime];
|
||||
// If the capture is launched in a separate thread, then
|
||||
// [NSRunLoop currentRunLoop] is not the same as in the main thread, and has no timer.
|
||||
//see https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsrunloop_Class/Reference/Reference.html
|
||||
// "If no input sources or timers are attached to the run loop, this
|
||||
// method exits immediately"
|
||||
// using usleep() is not a good alternative, because it may block the GUI.
|
||||
// Create a dummy timer so that runUntilDate does not exit immediately:
|
||||
[NSTimer scheduledTimerWithTimeInterval:100 target:nil selector:@selector(doFireTimer:) userInfo:nil repeats:YES];
|
||||
while (![capture updateImage] && (total += sleepTime)<=timeOut) {
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:sleepTime]];
|
||||
}
|
||||
|
||||
[localpool drain];
|
||||
|
||||
@@ -336,9 +343,11 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
|
||||
}
|
||||
|
||||
if (cameraNum >= 0) {
|
||||
int nCameras = [devices count];
|
||||
if( cameraNum < 0 || cameraNum >= nCameras )
|
||||
NSUInteger nCameras = [devices count];
|
||||
if( (NSUInteger)cameraNum >= nCameras ) {
|
||||
[localpool drain];
|
||||
return 0;
|
||||
}
|
||||
device = [devices objectAtIndex:cameraNum] ;
|
||||
} else {
|
||||
device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo] ;
|
||||
@@ -402,6 +411,7 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
|
||||
|
||||
grabFrame(60);
|
||||
|
||||
[localpool drain];
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -431,6 +441,7 @@ void CvCaptureCAM::setWidthHeight() {
|
||||
|
||||
|
||||
double CvCaptureCAM::getProperty(int property_id){
|
||||
int retval;
|
||||
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSArray* connections = [mCaptureDeviceInput connections];
|
||||
@@ -440,15 +451,18 @@ double CvCaptureCAM::getProperty(int property_id){
|
||||
int width=s1.width, height=s1.height;
|
||||
switch (property_id) {
|
||||
case CV_CAP_PROP_FRAME_WIDTH:
|
||||
return width;
|
||||
retval = width;
|
||||
break;
|
||||
case CV_CAP_PROP_FRAME_HEIGHT:
|
||||
return height;
|
||||
retval = height;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
[localpool drain];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool CvCaptureCAM::setProperty(int property_id, double value) {
|
||||
@@ -496,13 +510,15 @@ bool CvCaptureCAM::setProperty(int property_id, double value) {
|
||||
@implementation CaptureDelegate
|
||||
|
||||
- (id)init {
|
||||
[super init];
|
||||
newFrame = 0;
|
||||
imagedata = NULL;
|
||||
bgr_imagedata = NULL;
|
||||
currSize = 0;
|
||||
image = NULL;
|
||||
bgr_image = NULL;
|
||||
self = [super init];
|
||||
if (self) {
|
||||
newFrame = 0;
|
||||
imagedata = NULL;
|
||||
bgr_imagedata = NULL;
|
||||
currSize = 0;
|
||||
image = NULL;
|
||||
bgr_image = NULL;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -577,26 +593,26 @@ didDropVideoFrameWithSampleBuffer:(QTSampleBuffer *)sampleBuffer
|
||||
memcpy(imagedata, baseaddress, currSize);
|
||||
|
||||
if (image == NULL) {
|
||||
image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 4);
|
||||
image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 4);
|
||||
}
|
||||
image->width =width;
|
||||
image->height = height;
|
||||
image->width = (int)width;
|
||||
image->height = (int)height;
|
||||
image->nChannels = 4;
|
||||
image->depth = IPL_DEPTH_8U;
|
||||
image->widthStep = rowBytes;
|
||||
image->widthStep = (int)rowBytes;
|
||||
image->imageData = imagedata;
|
||||
image->imageSize = currSize;
|
||||
image->imageSize = (int)currSize;
|
||||
|
||||
if (bgr_image == NULL) {
|
||||
bgr_image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 3);
|
||||
bgr_image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 3);
|
||||
}
|
||||
bgr_image->width =width;
|
||||
bgr_image->height = height;
|
||||
bgr_image->width = (int)width;
|
||||
bgr_image->height = (int)height;
|
||||
bgr_image->nChannels = 3;
|
||||
bgr_image->depth = IPL_DEPTH_8U;
|
||||
bgr_image->widthStep = rowBytes;
|
||||
bgr_image->widthStep = (int)rowBytes;
|
||||
bgr_image->imageData = bgr_imagedata;
|
||||
bgr_image->imageSize = currSize;
|
||||
bgr_image->imageSize = (int)currSize;
|
||||
|
||||
cvCvtColor(image, bgr_image, CV_BGRA2BGR);
|
||||
|
||||
@@ -656,6 +672,8 @@ CvCaptureFile::CvCaptureFile(const char* filename) {
|
||||
return;
|
||||
}
|
||||
|
||||
[mCaptureSession gotoEnd];
|
||||
endOfMovie = [mCaptureSession currentTime];
|
||||
|
||||
[mCaptureSession gotoBeginning];
|
||||
|
||||
@@ -692,6 +710,11 @@ int CvCaptureFile::didStart() {
|
||||
bool CvCaptureFile::grabFrame() {
|
||||
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
||||
double t1 = getProperty(CV_CAP_PROP_POS_MSEC);
|
||||
|
||||
QTTime curTime;
|
||||
curTime = [mCaptureSession currentTime];
|
||||
bool isEnd=(QTTimeCompare(curTime,endOfMovie) == NSOrderedSame);
|
||||
|
||||
[mCaptureSession stepForward];
|
||||
double t2 = getProperty(CV_CAP_PROP_POS_MSEC);
|
||||
if (t2>t1 && !changedPos) {
|
||||
@@ -701,7 +724,7 @@ bool CvCaptureFile::grabFrame() {
|
||||
}
|
||||
changedPos = 0;
|
||||
[localpool drain];
|
||||
return 1;
|
||||
return !isEnd;
|
||||
}
|
||||
|
||||
|
||||
@@ -750,29 +773,29 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() {
|
||||
}
|
||||
|
||||
if (image == NULL) {
|
||||
image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 4);
|
||||
image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 4);
|
||||
}
|
||||
|
||||
image->width =width;
|
||||
image->height = height;
|
||||
image->width = (int)width;
|
||||
image->height = (int)height;
|
||||
image->nChannels = 4;
|
||||
image->depth = IPL_DEPTH_8U;
|
||||
image->widthStep = rowBytes;
|
||||
image->widthStep = (int)rowBytes;
|
||||
image->imageData = imagedata;
|
||||
image->imageSize = currSize;
|
||||
image->imageSize = (int)currSize;
|
||||
|
||||
|
||||
if (bgr_image == NULL) {
|
||||
bgr_image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 3);
|
||||
bgr_image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 3);
|
||||
}
|
||||
|
||||
bgr_image->width =width;
|
||||
bgr_image->height = height;
|
||||
bgr_image->width = (int)width;
|
||||
bgr_image->height = (int)height;
|
||||
bgr_image->nChannels = 3;
|
||||
bgr_image->depth = IPL_DEPTH_8U;
|
||||
bgr_image->widthStep = rowBytes;
|
||||
bgr_image->widthStep = (int)rowBytes;
|
||||
bgr_image->imageData = bgr_imagedata;
|
||||
bgr_image->imageSize = currSize;
|
||||
bgr_image->imageSize = (int)currSize;
|
||||
|
||||
cvCvtColor(image, bgr_image,CV_BGRA2BGR);
|
||||
|
||||
|
||||
@@ -325,7 +325,6 @@ typedef struct CvCaptureCAM_V4L
|
||||
struct v4l2_control control;
|
||||
enum v4l2_buf_type type;
|
||||
struct v4l2_queryctrl queryctrl;
|
||||
struct v4l2_querymenu querymenu;
|
||||
|
||||
struct timeval timestamp;
|
||||
|
||||
@@ -641,24 +640,6 @@ static int autosetup_capture_mode_v4l(CvCaptureCAM_V4L* capture)
|
||||
|
||||
#ifdef HAVE_CAMV4L2
|
||||
|
||||
static void v4l2_scan_controls_enumerate_menu(CvCaptureCAM_V4L* capture)
|
||||
{
|
||||
// printf (" Menu items:\n");
|
||||
CLEAR (capture->querymenu);
|
||||
capture->querymenu.id = capture->queryctrl.id;
|
||||
for (capture->querymenu.index = capture->queryctrl.minimum;
|
||||
(int)capture->querymenu.index <= capture->queryctrl.maximum;
|
||||
capture->querymenu.index++)
|
||||
{
|
||||
if (0 == ioctl (capture->deviceHandle, VIDIOC_QUERYMENU,
|
||||
&capture->querymenu))
|
||||
{
|
||||
// printf (" %s\n", capture->querymenu.name);
|
||||
} else {
|
||||
perror ("VIDIOC_QUERYMENU");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void v4l2_scan_controls(CvCaptureCAM_V4L* capture)
|
||||
{
|
||||
@@ -723,8 +704,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture)
|
||||
capture->v4l2_exposure_max = capture->queryctrl.maximum;
|
||||
}
|
||||
|
||||
if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU)
|
||||
v4l2_scan_controls_enumerate_menu(capture);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -793,9 +772,6 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture)
|
||||
capture->v4l2_exposure_max = capture->queryctrl.maximum;
|
||||
}
|
||||
|
||||
if (capture->queryctrl.type == V4L2_CTRL_TYPE_MENU)
|
||||
v4l2_scan_controls_enumerate_menu(capture);
|
||||
|
||||
} else {
|
||||
|
||||
if (errno == EINVAL)
|
||||
|
||||
@@ -75,34 +75,35 @@ bool CvCaptureCAM_XIMEA::open( int wIndex )
|
||||
return false;
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int isColor = 0;
|
||||
|
||||
// always use auto exposure/gain
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
int width = 0;
|
||||
mvret = xiGetParamInt( hmv, XI_PRM_WIDTH, &width);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
int height = 0;
|
||||
mvret = xiGetParamInt( hmv, XI_PRM_HEIGHT, &height);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
int isColor = 0;
|
||||
mvret = xiGetParamInt(hmv, XI_PRM_IMAGE_IS_COLOR, &isColor);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
if(isColor) // for color cameras
|
||||
if(isColor) // for color cameras
|
||||
{
|
||||
// default image format RGB24
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// always use auto white ballance for color cameras
|
||||
// always use auto white balance for color cameras
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// allocate frame buffer for RGB24 image
|
||||
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 3);
|
||||
frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
|
||||
}
|
||||
else // for mono cameras
|
||||
{
|
||||
@@ -111,7 +112,7 @@ bool CvCaptureCAM_XIMEA::open( int wIndex )
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// allocate frame buffer for MONO8 image
|
||||
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 1);
|
||||
frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
|
||||
}
|
||||
|
||||
//default capture timeout 10s
|
||||
|
||||
@@ -60,14 +60,6 @@ extern "C" {
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef __OPENCV_BUILD
|
||||
# define AVUTIL_COMMON_H
|
||||
# define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
|
||||
# endif
|
||||
# include <libavformat/avformat.h>
|
||||
#else
|
||||
|
||||
// if the header path is not specified explicitly, let's deduce it
|
||||
#if !defined HAVE_FFMPEG_AVCODEC_H && !defined HAVE_LIBAVCODEC_AVCODEC_H
|
||||
|
||||
@@ -81,14 +73,12 @@ extern "C" {
|
||||
#include <ffmpeg/avformat.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBAVFORMAT_AVFORMAT_H)
|
||||
#if defined(HAVE_LIBAVFORMAT_AVFORMAT_H) || defined(WIN32)
|
||||
#include <libavformat/avformat.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -59,11 +59,11 @@ class BaseImageDecoder
|
||||
{
|
||||
public:
|
||||
BaseImageDecoder();
|
||||
virtual ~BaseImageDecoder() {};
|
||||
virtual ~BaseImageDecoder() {}
|
||||
|
||||
int width() const { return m_width; };
|
||||
int height() const { return m_height; };
|
||||
virtual int type() const { return m_type; };
|
||||
int width() const { return m_width; }
|
||||
int height() const { return m_height; }
|
||||
virtual int type() const { return m_type; }
|
||||
|
||||
virtual bool setSource( const String& filename );
|
||||
virtual bool setSource( const Mat& buf );
|
||||
@@ -90,7 +90,7 @@ class BaseImageEncoder
|
||||
{
|
||||
public:
|
||||
BaseImageEncoder();
|
||||
virtual ~BaseImageEncoder() {};
|
||||
virtual ~BaseImageEncoder() {}
|
||||
virtual bool isFormatSupported( int depth ) const;
|
||||
|
||||
virtual bool setDestination( const String& filename );
|
||||
|
||||
164
modules/highgui/src/grfmt_hdr.cpp
Normal file
164
modules/highgui/src/grfmt_hdr.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "grfmt_hdr.hpp"
|
||||
#include "rgbe.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
HdrDecoder::HdrDecoder()
|
||||
{
|
||||
m_signature = "#?RGBE";
|
||||
m_signature_alt = "#?RADIANCE";
|
||||
file = NULL;
|
||||
m_type = CV_32FC3;
|
||||
}
|
||||
|
||||
HdrDecoder::~HdrDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
size_t HdrDecoder::signatureLength() const
|
||||
{
|
||||
return m_signature.size() > m_signature_alt.size() ?
|
||||
m_signature.size() : m_signature_alt.size();
|
||||
}
|
||||
|
||||
bool HdrDecoder::readHeader()
|
||||
{
|
||||
file = fopen(m_filename.c_str(), "rb");
|
||||
if(!file) {
|
||||
return false;
|
||||
}
|
||||
RGBE_ReadHeader(file, &m_width, &m_height, NULL);
|
||||
if(m_width <= 0 || m_height <= 0) {
|
||||
fclose(file);
|
||||
file = NULL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HdrDecoder::readData(Mat& _img)
|
||||
{
|
||||
Mat img(m_height, m_width, CV_32FC3);
|
||||
if(!file) {
|
||||
if(!readHeader()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
|
||||
fclose(file); file = NULL;
|
||||
|
||||
if(_img.depth() == img.depth()) {
|
||||
img.convertTo(_img, _img.type());
|
||||
} else {
|
||||
img.convertTo(_img, _img.type(), 255);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HdrDecoder::checkSignature( const String& signature ) const
|
||||
{
|
||||
if(signature.size() >= m_signature.size() &&
|
||||
(!memcmp(signature.c_str(), m_signature.c_str(), m_signature.size()) ||
|
||||
!memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageDecoder HdrDecoder::newDecoder() const
|
||||
{
|
||||
return makePtr<HdrDecoder>();
|
||||
}
|
||||
|
||||
HdrEncoder::HdrEncoder()
|
||||
{
|
||||
m_description = "Radiance HDR (*.hdr;*.pic)";
|
||||
}
|
||||
|
||||
HdrEncoder::~HdrEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
bool HdrEncoder::write( const Mat& input_img, const std::vector<int>& params )
|
||||
{
|
||||
Mat img;
|
||||
CV_Assert(input_img.channels() == 3 || input_img.channels() == 1);
|
||||
if(input_img.channels() == 1) {
|
||||
std::vector<Mat> splitted(3, input_img);
|
||||
merge(splitted, img);
|
||||
} else {
|
||||
input_img.copyTo(img);
|
||||
}
|
||||
if(img.depth() != CV_32F) {
|
||||
img.convertTo(img, CV_32FC3, 1/255.0f);
|
||||
}
|
||||
CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE);
|
||||
FILE *fout = fopen(m_filename.c_str(), "wb");
|
||||
if(!fout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RGBE_WriteHeader(fout, img.cols, img.rows, NULL);
|
||||
if(params.empty() || params[0] == HDR_RLE) {
|
||||
RGBE_WritePixels_RLE(fout, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
|
||||
} else {
|
||||
RGBE_WritePixels(fout, const_cast<float*>(img.ptr<float>()), img.cols * img.rows);
|
||||
}
|
||||
|
||||
fclose(fout);
|
||||
return true;
|
||||
}
|
||||
|
||||
ImageEncoder HdrEncoder::newEncoder() const
|
||||
{
|
||||
return makePtr<HdrEncoder>();
|
||||
}
|
||||
|
||||
bool HdrEncoder::isFormatSupported( int depth ) const {
|
||||
return depth != CV_64F;
|
||||
}
|
||||
|
||||
}
|
||||
88
modules/highgui/src/grfmt_hdr.hpp
Normal file
88
modules/highgui/src/grfmt_hdr.hpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef _GRFMT_HDR_H_
|
||||
#define _GRFMT_HDR_H_
|
||||
|
||||
#include "grfmt_base.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
enum HdrCompression
|
||||
{
|
||||
HDR_NONE = 0,
|
||||
HDR_RLE = 1
|
||||
};
|
||||
|
||||
// Radiance rgbe (.hdr) reader
|
||||
class HdrDecoder : public BaseImageDecoder
|
||||
{
|
||||
public:
|
||||
HdrDecoder();
|
||||
~HdrDecoder();
|
||||
bool readHeader();
|
||||
bool readData( Mat& img );
|
||||
bool checkSignature( const String& signature ) const;
|
||||
ImageDecoder newDecoder() const;
|
||||
size_t signatureLength() const;
|
||||
protected:
|
||||
String m_signature_alt;
|
||||
FILE *file;
|
||||
};
|
||||
|
||||
// ... writer
|
||||
class HdrEncoder : public BaseImageEncoder
|
||||
{
|
||||
public:
|
||||
HdrEncoder();
|
||||
~HdrEncoder();
|
||||
bool write( const Mat& img, const std::vector<int>& params );
|
||||
ImageEncoder newEncoder() const;
|
||||
bool isFormatSupported( int depth ) const;
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif/*_GRFMT_HDR_H_*/
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "grfmt_tiff.hpp"
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -71,6 +72,7 @@ TiffDecoder::TiffDecoder()
|
||||
TIFFSetErrorHandler( GrFmtSilentTIFFErrorHandler );
|
||||
TIFFSetWarningHandler( GrFmtSilentTIFFErrorHandler );
|
||||
}
|
||||
m_hdr = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,23 +118,34 @@ bool TiffDecoder::readHeader()
|
||||
bool result = false;
|
||||
|
||||
close();
|
||||
TIFF* tif = TIFFOpen( m_filename.c_str(), "rb" );
|
||||
// TIFFOpen() mode flags are different to fopen(). A 'b' in mode "rb" has no effect when reading.
|
||||
// http://www.remotesensing.org/libtiff/man/TIFFOpen.3tiff.html
|
||||
TIFF* tif = TIFFOpen( m_filename.c_str(), "r" );
|
||||
|
||||
if( tif )
|
||||
{
|
||||
int wdth = 0, hght = 0, photometric = 0;
|
||||
uint32 wdth = 0, hght = 0;
|
||||
uint16 photometric = 0;
|
||||
m_tif = tif;
|
||||
|
||||
if( TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &wdth ) &&
|
||||
TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &hght ) &&
|
||||
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric ))
|
||||
{
|
||||
int bpp=8, ncn = photometric > 1 ? 3 : 1;
|
||||
uint16 bpp=8, ncn = photometric > 1 ? 3 : 1;
|
||||
TIFFGetField( tif, TIFFTAG_BITSPERSAMPLE, &bpp );
|
||||
TIFFGetField( tif, TIFFTAG_SAMPLESPERPIXEL, &ncn );
|
||||
|
||||
m_width = wdth;
|
||||
m_height = hght;
|
||||
if((bpp == 32 && ncn == 3) || photometric == PHOTOMETRIC_LOGLUV)
|
||||
{
|
||||
m_type = CV_32FC3;
|
||||
m_hdr = true;
|
||||
return true;
|
||||
}
|
||||
m_hdr = false;
|
||||
|
||||
if( bpp > 8 &&
|
||||
((photometric != 2 && photometric != 1) ||
|
||||
(ncn != 1 && ncn != 3 && ncn != 4)))
|
||||
@@ -171,6 +184,10 @@ bool TiffDecoder::readHeader()
|
||||
|
||||
bool TiffDecoder::readData( Mat& img )
|
||||
{
|
||||
if(m_hdr && img.type() == CV_32FC3)
|
||||
{
|
||||
return readHdrData(img);
|
||||
}
|
||||
bool result = false;
|
||||
bool color = img.channels() > 1;
|
||||
uchar* data = img.data;
|
||||
@@ -181,12 +198,12 @@ bool TiffDecoder::readData( Mat& img )
|
||||
if( m_tif && m_width && m_height )
|
||||
{
|
||||
TIFF* tif = (TIFF*)m_tif;
|
||||
int tile_width0 = m_width, tile_height0 = 0;
|
||||
uint32 tile_width0 = m_width, tile_height0 = 0;
|
||||
int x, y, i;
|
||||
int is_tiled = TIFFIsTiled(tif);
|
||||
int photometric;
|
||||
uint16 photometric;
|
||||
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric );
|
||||
int bpp = 8, ncn = photometric > 1 ? 3 : 1;
|
||||
uint16 bpp = 8, ncn = photometric > 1 ? 3 : 1;
|
||||
TIFFGetField( tif, TIFFTAG_BITSPERSAMPLE, &bpp );
|
||||
TIFFGetField( tif, TIFFTAG_SAMPLESPERPIXEL, &ncn );
|
||||
const int bitsPerByte = 8;
|
||||
@@ -242,11 +259,15 @@ bool TiffDecoder::readData( Mat& img )
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
uchar * bstart = buffer;
|
||||
if( !is_tiled )
|
||||
ok = TIFFReadRGBAStrip( tif, y, (uint32*)buffer );
|
||||
else
|
||||
{
|
||||
ok = TIFFReadRGBATile( tif, x, y, (uint32*)buffer );
|
||||
|
||||
//Tiles fill the buffer from the bottom up
|
||||
bstart += (tile_height0 - tile_height) * tile_width0 * 4;
|
||||
}
|
||||
if( !ok )
|
||||
{
|
||||
close();
|
||||
@@ -258,19 +279,19 @@ bool TiffDecoder::readData( Mat& img )
|
||||
{
|
||||
if (wanted_channels == 4)
|
||||
{
|
||||
icvCvt_BGRA2RGBA_8u_C4R( buffer + i*tile_width*4, 0,
|
||||
icvCvt_BGRA2RGBA_8u_C4R( bstart + i*tile_width0*4, 0,
|
||||
data + x*4 + img.step*(tile_height - i - 1), 0,
|
||||
cvSize(tile_width,1) );
|
||||
}
|
||||
else
|
||||
{
|
||||
icvCvt_BGRA2BGR_8u_C4C3R( buffer + i*tile_width*4, 0,
|
||||
icvCvt_BGRA2BGR_8u_C4C3R( bstart + i*tile_width0*4, 0,
|
||||
data + x*3 + img.step*(tile_height - i - 1), 0,
|
||||
cvSize(tile_width,1), 2 );
|
||||
}
|
||||
}
|
||||
else
|
||||
icvCvt_BGRA2Gray_8u_C4C1R( buffer + i*tile_width*4, 0,
|
||||
icvCvt_BGRA2Gray_8u_C4C1R( bstart + i*tile_width0*4, 0,
|
||||
data + x + img.step*(tile_height - i - 1), 0,
|
||||
cvSize(tile_width,1), 2 );
|
||||
break;
|
||||
@@ -295,19 +316,19 @@ bool TiffDecoder::readData( Mat& img )
|
||||
{
|
||||
if( ncn == 1 )
|
||||
{
|
||||
icvCvt_Gray2BGR_16u_C1C3R(buffer16 + i*tile_width*ncn, 0,
|
||||
icvCvt_Gray2BGR_16u_C1C3R(buffer16 + i*tile_width0*ncn, 0,
|
||||
(ushort*)(data + img.step*i) + x*3, 0,
|
||||
cvSize(tile_width,1) );
|
||||
}
|
||||
else if( ncn == 3 )
|
||||
{
|
||||
icvCvt_RGB2BGR_16u_C3R(buffer16 + i*tile_width*ncn, 0,
|
||||
icvCvt_RGB2BGR_16u_C3R(buffer16 + i*tile_width0*ncn, 0,
|
||||
(ushort*)(data + img.step*i) + x*3, 0,
|
||||
cvSize(tile_width,1) );
|
||||
}
|
||||
else
|
||||
{
|
||||
icvCvt_BGRA2BGR_16u_C4C3R(buffer16 + i*tile_width*ncn, 0,
|
||||
icvCvt_BGRA2BGR_16u_C4C3R(buffer16 + i*tile_width0*ncn, 0,
|
||||
(ushort*)(data + img.step*i) + x*3, 0,
|
||||
cvSize(tile_width,1), 2 );
|
||||
}
|
||||
@@ -317,12 +338,12 @@ bool TiffDecoder::readData( Mat& img )
|
||||
if( ncn == 1 )
|
||||
{
|
||||
memcpy((ushort*)(data + img.step*i)+x,
|
||||
buffer16 + i*tile_width*ncn,
|
||||
buffer16 + i*tile_width0*ncn,
|
||||
tile_width*sizeof(buffer16[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
icvCvt_BGRA2Gray_16u_CnC1R(buffer16 + i*tile_width*ncn, 0,
|
||||
icvCvt_BGRA2Gray_16u_CnC1R(buffer16 + i*tile_width0*ncn, 0,
|
||||
(ushort*)(data + img.step*i) + x, 0,
|
||||
cvSize(tile_width,1), ncn, 2 );
|
||||
}
|
||||
@@ -350,13 +371,13 @@ bool TiffDecoder::readData( Mat& img )
|
||||
if(dst_bpp == 32)
|
||||
{
|
||||
memcpy((float*)(data + img.step*i)+x,
|
||||
buffer32 + i*tile_width*ncn,
|
||||
buffer32 + i*tile_width0*ncn,
|
||||
tile_width*sizeof(buffer32[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((double*)(data + img.step*i)+x,
|
||||
buffer64 + i*tile_width*ncn,
|
||||
buffer64 + i*tile_width0*ncn,
|
||||
tile_width*sizeof(buffer64[0]));
|
||||
}
|
||||
}
|
||||
@@ -380,6 +401,37 @@ bool TiffDecoder::readData( Mat& img )
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TiffDecoder::readHdrData(Mat& img)
|
||||
{
|
||||
int rows_per_strip = 0, photometric = 0;
|
||||
if(!m_tif)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TIFF *tif = static_cast<TIFF*>(m_tif);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip);
|
||||
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric );
|
||||
TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT);
|
||||
int size = 3 * m_width * m_height * sizeof (float);
|
||||
tstrip_t strip_size = 3 * m_width * rows_per_strip;
|
||||
float *ptr = img.ptr<float>();
|
||||
for (tstrip_t i = 0; i < TIFFNumberOfStrips(tif); i++, ptr += strip_size)
|
||||
{
|
||||
TIFFReadEncodedStrip(tif, i, ptr, size);
|
||||
size -= strip_size * sizeof(float);
|
||||
}
|
||||
close();
|
||||
if(photometric == PHOTOMETRIC_LOGLUV)
|
||||
{
|
||||
cvtColor(img, img, COLOR_XYZ2BGR);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvtColor(img, img, COLOR_RGB2BGR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -405,7 +457,11 @@ ImageEncoder TiffEncoder::newEncoder() const
|
||||
|
||||
bool TiffEncoder::isFormatSupported( int depth ) const
|
||||
{
|
||||
#ifdef HAVE_TIFF
|
||||
return depth == CV_8U || depth == CV_16U || depth == CV_32F;
|
||||
#else
|
||||
return depth == CV_8U || depth == CV_16U;
|
||||
#endif
|
||||
}
|
||||
|
||||
void TiffEncoder::writeTag( WLByteStream& strm, TiffTag tag,
|
||||
@@ -557,6 +613,33 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector<int>& params)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TiffEncoder::writeHdr(const Mat& _img)
|
||||
{
|
||||
Mat img;
|
||||
cvtColor(_img, img, COLOR_BGR2XYZ);
|
||||
TIFF* tif = TIFFOpen(m_filename.c_str(), "w");
|
||||
if (!tif)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, img.cols);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, img.rows);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_SGILOG);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_LOGLUV);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
int strip_size = 3 * img.cols;
|
||||
float *ptr = const_cast<float*>(img.ptr<float>());
|
||||
for (int i = 0; i < img.rows; i++, ptr += strip_size)
|
||||
{
|
||||
TIFFWriteEncodedStrip(tif, i, ptr, strip_size * sizeof(float));
|
||||
}
|
||||
TIFFClose(tif);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIFF
|
||||
@@ -568,6 +651,12 @@ bool TiffEncoder::write( const Mat& img, const std::vector<int>& /*params*/)
|
||||
int channels = img.channels();
|
||||
int width = img.cols, height = img.rows;
|
||||
int depth = img.depth();
|
||||
#ifdef HAVE_TIFF
|
||||
if(img.type() == CV_32FC3)
|
||||
{
|
||||
return writeHdr(img);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (depth != CV_8U && depth != CV_16U)
|
||||
return false;
|
||||
|
||||
@@ -108,6 +108,8 @@ public:
|
||||
protected:
|
||||
void* m_tif;
|
||||
int normalizeChannelsNumber(int channels) const;
|
||||
bool readHdrData(Mat& img);
|
||||
bool m_hdr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -130,6 +132,7 @@ protected:
|
||||
int count, int value );
|
||||
|
||||
bool writeLibTiff( const Mat& img, const std::vector<int>& params );
|
||||
bool writeHdr( const Mat& img );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -174,12 +174,12 @@ bool WebPDecoder::readData(Mat &img)
|
||||
if (channels == 3)
|
||||
{
|
||||
res_ptr = WebPDecodeBGRInto(data.data, data.total(), out_data,
|
||||
out_data_size, img.step);
|
||||
(int)out_data_size, (int)img.step);
|
||||
}
|
||||
else if (channels == 4)
|
||||
{
|
||||
res_ptr = WebPDecodeBGRAInto(data.data, data.total(), out_data,
|
||||
out_data_size, img.step);
|
||||
(int)out_data_size, (int)img.step);
|
||||
}
|
||||
|
||||
if(res_ptr == out_data)
|
||||
@@ -255,22 +255,22 @@ bool WebPEncoder::write(const Mat& img, const std::vector<int>& params)
|
||||
{
|
||||
if(channels == 3)
|
||||
{
|
||||
size = WebPEncodeLosslessBGR(image->data, width, height, image->step, &out);
|
||||
size = WebPEncodeLosslessBGR(image->data, width, height, (int)image->step, &out);
|
||||
}
|
||||
else if(channels == 4)
|
||||
{
|
||||
size = WebPEncodeLosslessBGRA(image->data, width, height, image->step, &out);
|
||||
size = WebPEncodeLosslessBGRA(image->data, width, height, (int)image->step, &out);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(channels == 3)
|
||||
{
|
||||
size = WebPEncodeBGR(image->data, width, height, image->step, quality, &out);
|
||||
size = WebPEncodeBGR(image->data, width, height, (int)image->step, quality, &out);
|
||||
}
|
||||
else if(channels == 4)
|
||||
{
|
||||
size = WebPEncodeBGRA(image->data, width, height, image->step, quality, &out);
|
||||
size = WebPEncodeBGRA(image->data, width, height, (int)image->step, quality, &out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,5 +52,6 @@
|
||||
#include "grfmt_jpeg2000.hpp"
|
||||
#include "grfmt_exr.hpp"
|
||||
#include "grfmt_webp.hpp"
|
||||
#include "grfmt_hdr.hpp"
|
||||
|
||||
#endif/*_GRFMTS_H_*/
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "grfmts.hpp"
|
||||
#undef min
|
||||
#undef max
|
||||
#include <iostream>
|
||||
|
||||
/****************************************************************************************\
|
||||
* Image Codecs *
|
||||
@@ -60,6 +61,8 @@ struct ImageCodecInitializer
|
||||
{
|
||||
decoders.push_back( makePtr<BmpDecoder>() );
|
||||
encoders.push_back( makePtr<BmpEncoder>() );
|
||||
decoders.push_back( makePtr<HdrDecoder>() );
|
||||
encoders.push_back( makePtr<HdrEncoder>() );
|
||||
#ifdef HAVE_JPEG
|
||||
decoders.push_back( makePtr<JpegDecoder>() );
|
||||
encoders.push_back( makePtr<JpegEncoder>() );
|
||||
@@ -203,7 +206,6 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
|
||||
decoder->setSource(filename);
|
||||
if( !decoder->readHeader() )
|
||||
return 0;
|
||||
|
||||
CvSize size;
|
||||
size.width = decoder->width();
|
||||
size.height = decoder->height();
|
||||
@@ -271,7 +273,6 @@ static bool imwrite_( const String& filename, const Mat& image,
|
||||
ImageEncoder encoder = findEncoder( filename );
|
||||
if( !encoder )
|
||||
CV_Error( CV_StsError, "could not find a writer for the specified extension" );
|
||||
|
||||
if( !encoder->isFormatSupported(image.depth()) )
|
||||
{
|
||||
CV_Assert( encoder->isFormatSupported(CV_8U) );
|
||||
|
||||
6326
modules/highgui/src/ppltasks_winrt.h
Normal file
6326
modules/highgui/src/ppltasks_winrt.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,14 @@
|
||||
#include <assert.h>
|
||||
|
||||
#if defined WIN32 || defined WINCE
|
||||
#if !defined _WIN32_WINNT
|
||||
#ifdef HAVE_MSMF
|
||||
#define _WIN32_WINNT 0x0600 // Windows Vista
|
||||
#else
|
||||
#define _WIN32_WINNT 0x0500 // Windows 2000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#undef small
|
||||
#undef min
|
||||
@@ -129,7 +137,6 @@ CvCapture* cvCreateCameraCapture_Android( int index );
|
||||
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
||||
|
||||
|
||||
CVAPI(int) cvHaveImageReader(const char* filename);
|
||||
CVAPI(int) cvHaveImageWriter(const char* filename);
|
||||
|
||||
@@ -189,6 +196,20 @@ double cvGetRatioWindow_GTK(const char* name);
|
||||
double cvGetOpenGlProp_W32(const char* name);
|
||||
double cvGetOpenGlProp_GTK(const char* name);
|
||||
|
||||
namespace cv
|
||||
{
|
||||
class IVideoCapture
|
||||
{
|
||||
public:
|
||||
virtual ~IVideoCapture() {}
|
||||
virtual double getProperty(int) { return 0; }
|
||||
virtual bool setProperty(int, double) { return 0; }
|
||||
virtual bool grabFrame() = 0;
|
||||
virtual bool retrieveFrame(int, cv::OutputArray) = 0;
|
||||
virtual int getCaptureDomain() { return CAP_ANY; } // Return the type of the capture object: CAP_VFW, etc...
|
||||
};
|
||||
};
|
||||
|
||||
//for QT
|
||||
#if defined (HAVE_QT)
|
||||
double cvGetModeWindow_QT(const char* name);
|
||||
|
||||
450
modules/highgui/src/rgbe.cpp
Normal file
450
modules/highgui/src/rgbe.cpp
Normal file
@@ -0,0 +1,450 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "rgbe.hpp"
|
||||
#include <math.h>
|
||||
#if !defined(__APPLE__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
// This file contains code to read and write four byte rgbe file format
|
||||
// developed by Greg Ward. It handles the conversions between rgbe and
|
||||
// pixels consisting of floats. The data is assumed to be an array of floats.
|
||||
// By default there are three floats per pixel in the order red, green, blue.
|
||||
// (RGBE_DATA_??? values control this.) Only the mimimal header reading and
|
||||
// writing is implemented. Each routine does error checking and will return
|
||||
// a status value as defined below. This code is intended as a skeleton so
|
||||
// feel free to modify it to suit your needs.
|
||||
|
||||
// Some opencv specific changes have been added:
|
||||
// inline define specified, error handler uses CV_Error,
|
||||
// defines changed to work in bgr color space.
|
||||
//
|
||||
// posted to http://www.graphics.cornell.edu/~bjw/
|
||||
// written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95
|
||||
// based on code written by Greg Ward
|
||||
|
||||
#define INLINE inline
|
||||
|
||||
/* offsets to red, green, and blue components in a data (float) pixel */
|
||||
#define RGBE_DATA_RED 2
|
||||
#define RGBE_DATA_GREEN 1
|
||||
#define RGBE_DATA_BLUE 0
|
||||
/* number of floats per pixel */
|
||||
#define RGBE_DATA_SIZE 3
|
||||
|
||||
enum rgbe_error_codes {
|
||||
rgbe_read_error,
|
||||
rgbe_write_error,
|
||||
rgbe_format_error,
|
||||
rgbe_memory_error
|
||||
};
|
||||
|
||||
/* default error routine. change this to change error handling */
|
||||
static int rgbe_error(int rgbe_error_code, const char *msg)
|
||||
{
|
||||
switch (rgbe_error_code) {
|
||||
case rgbe_read_error:
|
||||
CV_Error(cv::Error::StsError, "RGBE read error");
|
||||
break;
|
||||
case rgbe_write_error:
|
||||
CV_Error(cv::Error::StsError, "RGBE write error");
|
||||
break;
|
||||
case rgbe_format_error:
|
||||
CV_Error(cv::Error::StsError, cv::String("RGBE bad file format: ") +
|
||||
cv::String(msg));
|
||||
break;
|
||||
default:
|
||||
case rgbe_memory_error:
|
||||
CV_Error(cv::Error::StsError, cv::String("RGBE error: \n") +
|
||||
cv::String(msg));
|
||||
}
|
||||
return RGBE_RETURN_FAILURE;
|
||||
}
|
||||
|
||||
/* standard conversion from float pixels to rgbe pixels */
|
||||
/* note: you can remove the "inline"s if your compiler complains about it */
|
||||
static INLINE void
|
||||
float2rgbe(unsigned char rgbe[4], float red, float green, float blue)
|
||||
{
|
||||
float v;
|
||||
int e;
|
||||
|
||||
v = red;
|
||||
if (green > v) v = green;
|
||||
if (blue > v) v = blue;
|
||||
if (v < 1e-32) {
|
||||
rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
|
||||
}
|
||||
else {
|
||||
v = static_cast<float>(frexp(v,&e) * 256.0/v);
|
||||
rgbe[0] = (unsigned char) (red * v);
|
||||
rgbe[1] = (unsigned char) (green * v);
|
||||
rgbe[2] = (unsigned char) (blue * v);
|
||||
rgbe[3] = (unsigned char) (e + 128);
|
||||
}
|
||||
}
|
||||
|
||||
/* standard conversion from rgbe to float pixels */
|
||||
/* note: Ward uses ldexp(col+0.5,exp-(128+8)). However we wanted pixels */
|
||||
/* in the range [0,1] to map back into the range [0,1]. */
|
||||
static INLINE void
|
||||
rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4])
|
||||
{
|
||||
float f;
|
||||
|
||||
if (rgbe[3]) { /*nonzero pixel*/
|
||||
f = static_cast<float>(ldexp(1.0,rgbe[3]-(int)(128+8)));
|
||||
*red = rgbe[0] * f;
|
||||
*green = rgbe[1] * f;
|
||||
*blue = rgbe[2] * f;
|
||||
}
|
||||
else
|
||||
*red = *green = *blue = 0.0;
|
||||
}
|
||||
|
||||
/* default minimal header. modify if you want more information in header */
|
||||
int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info)
|
||||
{
|
||||
const char *programtype = "RGBE";
|
||||
|
||||
if (info && (info->valid & RGBE_VALID_PROGRAMTYPE))
|
||||
programtype = info->programtype;
|
||||
if (fprintf(fp,"#?%s\n",programtype) < 0)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
/* The #? is to identify file type, the programtype is optional. */
|
||||
if (info && (info->valid & RGBE_VALID_GAMMA)) {
|
||||
if (fprintf(fp,"GAMMA=%g\n",info->gamma) < 0)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
}
|
||||
if (info && (info->valid & RGBE_VALID_EXPOSURE)) {
|
||||
if (fprintf(fp,"EXPOSURE=%g\n",info->exposure) < 0)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
}
|
||||
if (fprintf(fp,"FORMAT=32-bit_rle_rgbe\n\n") < 0)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
if (fprintf(fp, "-Y %d +X %d\n", height, width) < 0)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/* minimal header reading. modify if you want to parse more information */
|
||||
int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info)
|
||||
{
|
||||
char buf[128];
|
||||
float tempf;
|
||||
int i;
|
||||
|
||||
if (info) {
|
||||
info->valid = 0;
|
||||
info->programtype[0] = 0;
|
||||
info->gamma = info->exposure = 1.0;
|
||||
}
|
||||
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == NULL)
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
if ((buf[0] != '#')||(buf[1] != '?')) {
|
||||
/* if you want to require the magic token then uncomment the next line */
|
||||
/*return rgbe_error(rgbe_format_error,"bad initial token"); */
|
||||
}
|
||||
else if (info) {
|
||||
info->valid |= RGBE_VALID_PROGRAMTYPE;
|
||||
for(i=0;i<static_cast<int>(sizeof(info->programtype)-1);i++) {
|
||||
if ((buf[i+2] == 0) || isspace(buf[i+2]))
|
||||
break;
|
||||
info->programtype[i] = buf[i+2];
|
||||
}
|
||||
info->programtype[i] = 0;
|
||||
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == 0)
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
}
|
||||
for(;;) {
|
||||
if ((buf[0] == 0)||(buf[0] == '\n'))
|
||||
return rgbe_error(rgbe_format_error,"no FORMAT specifier found");
|
||||
else if (strcmp(buf,"FORMAT=32-bit_rle_rgbe\n") == 0)
|
||||
break; /* format found so break out of loop */
|
||||
else if (info && (sscanf(buf,"GAMMA=%g",&tempf) == 1)) {
|
||||
info->gamma = tempf;
|
||||
info->valid |= RGBE_VALID_GAMMA;
|
||||
}
|
||||
else if (info && (sscanf(buf,"EXPOSURE=%g",&tempf) == 1)) {
|
||||
info->exposure = tempf;
|
||||
info->valid |= RGBE_VALID_EXPOSURE;
|
||||
}
|
||||
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == 0)
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
}
|
||||
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == 0)
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
if (strcmp(buf,"\n") != 0)
|
||||
return rgbe_error(rgbe_format_error,
|
||||
"missing blank line after FORMAT specifier");
|
||||
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == 0)
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
if (sscanf(buf,"-Y %d +X %d",height,width) < 2)
|
||||
return rgbe_error(rgbe_format_error,"missing image size specifier");
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/* simple write routine that does not use run length encoding */
|
||||
/* These routines can be made faster by allocating a larger buffer and
|
||||
fread-ing and fwrite-ing the data in larger chunks */
|
||||
int RGBE_WritePixels(FILE *fp, float *data, int numpixels)
|
||||
{
|
||||
unsigned char rgbe[4];
|
||||
|
||||
while (numpixels-- > 0) {
|
||||
float2rgbe(rgbe,data[RGBE_DATA_RED],
|
||||
data[RGBE_DATA_GREEN],data[RGBE_DATA_BLUE]);
|
||||
data += RGBE_DATA_SIZE;
|
||||
if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
}
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/* simple read routine. will not correctly handle run length encoding */
|
||||
int RGBE_ReadPixels(FILE *fp, float *data, int numpixels)
|
||||
{
|
||||
unsigned char rgbe[4];
|
||||
|
||||
while(numpixels-- > 0) {
|
||||
if (fread(rgbe, sizeof(rgbe), 1, fp) < 1)
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],
|
||||
&data[RGBE_DATA_BLUE],rgbe);
|
||||
data += RGBE_DATA_SIZE;
|
||||
}
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/* The code below is only needed for the run-length encoded files. */
|
||||
/* Run length encoding adds considerable complexity but does */
|
||||
/* save some space. For each scanline, each channel (r,g,b,e) is */
|
||||
/* encoded separately for better compression. */
|
||||
|
||||
static int RGBE_WriteBytes_RLE(FILE *fp, unsigned char *data, int numbytes)
|
||||
{
|
||||
#define MINRUNLENGTH 4
|
||||
int cur, beg_run, run_count, old_run_count, nonrun_count;
|
||||
unsigned char buf[2];
|
||||
|
||||
cur = 0;
|
||||
while(cur < numbytes) {
|
||||
beg_run = cur;
|
||||
/* find next run of length at least 4 if one exists */
|
||||
run_count = old_run_count = 0;
|
||||
while((run_count < MINRUNLENGTH) && (beg_run < numbytes)) {
|
||||
beg_run += run_count;
|
||||
old_run_count = run_count;
|
||||
run_count = 1;
|
||||
while( (beg_run + run_count < numbytes) && (run_count < 127)
|
||||
&& (data[beg_run] == data[beg_run + run_count]))
|
||||
run_count++;
|
||||
}
|
||||
/* if data before next big run is a short run then write it as such */
|
||||
if ((old_run_count > 1)&&(old_run_count == beg_run - cur)) {
|
||||
buf[0] = static_cast<unsigned char>(128 + old_run_count); /*write short run*/
|
||||
buf[1] = data[cur];
|
||||
if (fwrite(buf,sizeof(buf[0])*2,1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
cur = beg_run;
|
||||
}
|
||||
/* write out bytes until we reach the start of the next run */
|
||||
while(cur < beg_run) {
|
||||
nonrun_count = beg_run - cur;
|
||||
if (nonrun_count > 128)
|
||||
nonrun_count = 128;
|
||||
buf[0] = static_cast<unsigned char>(nonrun_count);
|
||||
if (fwrite(buf,sizeof(buf[0]),1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
if (fwrite(&data[cur],sizeof(data[0])*nonrun_count,1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
cur += nonrun_count;
|
||||
}
|
||||
/* write out next run if one was found */
|
||||
if (run_count >= MINRUNLENGTH) {
|
||||
buf[0] = static_cast<unsigned char>(128 + run_count);
|
||||
buf[1] = data[beg_run];
|
||||
if (fwrite(buf,sizeof(buf[0])*2,1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
cur += run_count;
|
||||
}
|
||||
}
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
#undef MINRUNLENGTH
|
||||
}
|
||||
|
||||
int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
int num_scanlines)
|
||||
{
|
||||
unsigned char rgbe[4];
|
||||
unsigned char *buffer;
|
||||
int i, err;
|
||||
|
||||
if ((scanline_width < 8)||(scanline_width > 0x7fff))
|
||||
/* run length encoding is not allowed so write flat*/
|
||||
return RGBE_WritePixels(fp,data,scanline_width*num_scanlines);
|
||||
buffer = (unsigned char *)malloc(sizeof(unsigned char)*4*scanline_width);
|
||||
if (buffer == NULL)
|
||||
/* no buffer space so write flat */
|
||||
return RGBE_WritePixels(fp,data,scanline_width*num_scanlines);
|
||||
while(num_scanlines-- > 0) {
|
||||
rgbe[0] = 2;
|
||||
rgbe[1] = 2;
|
||||
rgbe[2] = static_cast<unsigned char>(scanline_width >> 8);
|
||||
rgbe[3] = scanline_width & 0xFF;
|
||||
if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1) {
|
||||
free(buffer);
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
}
|
||||
for(i=0;i<scanline_width;i++) {
|
||||
float2rgbe(rgbe,data[RGBE_DATA_RED],
|
||||
data[RGBE_DATA_GREEN],data[RGBE_DATA_BLUE]);
|
||||
buffer[i] = rgbe[0];
|
||||
buffer[i+scanline_width] = rgbe[1];
|
||||
buffer[i+2*scanline_width] = rgbe[2];
|
||||
buffer[i+3*scanline_width] = rgbe[3];
|
||||
data += RGBE_DATA_SIZE;
|
||||
}
|
||||
/* write out each of the four channels separately run length encoded */
|
||||
/* first red, then green, then blue, then exponent */
|
||||
for(i=0;i<4;i++) {
|
||||
if ((err = RGBE_WriteBytes_RLE(fp,&buffer[i*scanline_width],
|
||||
scanline_width)) != RGBE_RETURN_SUCCESS) {
|
||||
free(buffer);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
int num_scanlines)
|
||||
{
|
||||
unsigned char rgbe[4], *scanline_buffer, *ptr, *ptr_end;
|
||||
int i, count;
|
||||
unsigned char buf[2];
|
||||
|
||||
if ((scanline_width < 8)||(scanline_width > 0x7fff))
|
||||
/* run length encoding is not allowed so read flat*/
|
||||
return RGBE_ReadPixels(fp,data,scanline_width*num_scanlines);
|
||||
scanline_buffer = NULL;
|
||||
/* read in each successive scanline */
|
||||
while(num_scanlines > 0) {
|
||||
if (fread(rgbe,sizeof(rgbe),1,fp) < 1) {
|
||||
free(scanline_buffer);
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
}
|
||||
if ((rgbe[0] != 2)||(rgbe[1] != 2)||(rgbe[2] & 0x80)) {
|
||||
/* this file is not run length encoded */
|
||||
rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],&data[RGBE_DATA_BLUE],rgbe);
|
||||
data += RGBE_DATA_SIZE;
|
||||
free(scanline_buffer);
|
||||
return RGBE_ReadPixels(fp,data,scanline_width*num_scanlines-1);
|
||||
}
|
||||
if ((((int)rgbe[2])<<8 | rgbe[3]) != scanline_width) {
|
||||
free(scanline_buffer);
|
||||
return rgbe_error(rgbe_format_error,"wrong scanline width");
|
||||
}
|
||||
if (scanline_buffer == NULL)
|
||||
scanline_buffer = (unsigned char *)
|
||||
malloc(sizeof(unsigned char)*4*scanline_width);
|
||||
if (scanline_buffer == NULL)
|
||||
return rgbe_error(rgbe_memory_error,"unable to allocate buffer space");
|
||||
|
||||
ptr = &scanline_buffer[0];
|
||||
/* read each of the four channels for the scanline into the buffer */
|
||||
for(i=0;i<4;i++) {
|
||||
ptr_end = &scanline_buffer[(i+1)*scanline_width];
|
||||
while(ptr < ptr_end) {
|
||||
if (fread(buf,sizeof(buf[0])*2,1,fp) < 1) {
|
||||
free(scanline_buffer);
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
}
|
||||
if (buf[0] > 128) {
|
||||
/* a run of the same value */
|
||||
count = buf[0]-128;
|
||||
if ((count == 0)||(count > ptr_end - ptr)) {
|
||||
free(scanline_buffer);
|
||||
return rgbe_error(rgbe_format_error,"bad scanline data");
|
||||
}
|
||||
while(count-- > 0)
|
||||
*ptr++ = buf[1];
|
||||
}
|
||||
else {
|
||||
/* a non-run */
|
||||
count = buf[0];
|
||||
if ((count == 0)||(count > ptr_end - ptr)) {
|
||||
free(scanline_buffer);
|
||||
return rgbe_error(rgbe_format_error,"bad scanline data");
|
||||
}
|
||||
*ptr++ = buf[1];
|
||||
if (--count > 0) {
|
||||
if (fread(ptr,sizeof(*ptr)*count,1,fp) < 1) {
|
||||
free(scanline_buffer);
|
||||
return rgbe_error(rgbe_read_error,NULL);
|
||||
}
|
||||
ptr += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* now convert data from buffer into floats */
|
||||
for(i=0;i<scanline_width;i++) {
|
||||
rgbe[0] = scanline_buffer[i];
|
||||
rgbe[1] = scanline_buffer[i+scanline_width];
|
||||
rgbe[2] = scanline_buffer[i+2*scanline_width];
|
||||
rgbe[3] = scanline_buffer[i+3*scanline_width];
|
||||
rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],
|
||||
&data[RGBE_DATA_BLUE],rgbe);
|
||||
data += RGBE_DATA_SIZE;
|
||||
}
|
||||
num_scanlines--;
|
||||
}
|
||||
free(scanline_buffer);
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
89
modules/highgui/src/rgbe.hpp
Normal file
89
modules/highgui/src/rgbe.hpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef _RGBE_HDR_H_
|
||||
#define _RGBE_HDR_H_
|
||||
|
||||
// posted to http://www.graphics.cornell.edu/~bjw/
|
||||
// written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95
|
||||
// based on code written by Greg Ward
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
int valid; /* indicate which fields are valid */
|
||||
char programtype[16]; /* listed at beginning of file to identify it
|
||||
* after "#?". defaults to "RGBE" */
|
||||
float gamma; /* image has already been gamma corrected with
|
||||
* given gamma. defaults to 1.0 (no correction) */
|
||||
float exposure; /* a value of 1.0 in an image corresponds to
|
||||
* <exposure> watts/steradian/m^2.
|
||||
* defaults to 1.0 */
|
||||
} rgbe_header_info;
|
||||
|
||||
/* flags indicating which fields in an rgbe_header_info are valid */
|
||||
#define RGBE_VALID_PROGRAMTYPE 0x01
|
||||
#define RGBE_VALID_GAMMA 0x02
|
||||
#define RGBE_VALID_EXPOSURE 0x04
|
||||
|
||||
/* return codes for rgbe routines */
|
||||
#define RGBE_RETURN_SUCCESS 0
|
||||
#define RGBE_RETURN_FAILURE -1
|
||||
|
||||
/* read or write headers */
|
||||
/* you may set rgbe_header_info to null if you want to */
|
||||
int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info);
|
||||
int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info);
|
||||
|
||||
/* read or write pixels */
|
||||
/* can read or write pixels in chunks of any size including single pixels*/
|
||||
int RGBE_WritePixels(FILE *fp, float *data, int numpixels);
|
||||
int RGBE_ReadPixels(FILE *fp, float *data, int numpixels);
|
||||
|
||||
/* read or write run length encoded files */
|
||||
/* must be called to read or write whole scanlines */
|
||||
int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
int num_scanlines);
|
||||
int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
int num_scanlines);
|
||||
|
||||
#endif/*_RGBE_HDR_H_*/
|
||||
@@ -216,6 +216,11 @@ void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void
|
||||
cvSetMouseCallback(windowName.c_str(), onMouse, param);
|
||||
}
|
||||
|
||||
int cv::getMouseWheelDelta( int flags )
|
||||
{
|
||||
return CV_GET_WHEEL_DELTA(flags);
|
||||
}
|
||||
|
||||
int cv::startWindowThread()
|
||||
{
|
||||
return cvStartWindowThread();
|
||||
|
||||
@@ -1536,7 +1536,7 @@ CvWindow::CvWindow(QString name, int arg2)
|
||||
setWindowTitle(name);
|
||||
setObjectName(name);
|
||||
|
||||
setFocus( Qt::PopupFocusReason ); //#1695 arrow keys are not recieved without the explicit focus
|
||||
setFocus( Qt::PopupFocusReason ); //#1695 arrow keys are not received without the explicit focus
|
||||
|
||||
resize(400, 300);
|
||||
setMinimumSize(1, 1);
|
||||
@@ -1736,7 +1736,8 @@ void CvWindow::displayStatusBar(QString text, int delayms)
|
||||
|
||||
void CvWindow::enablePropertiesButton()
|
||||
{
|
||||
vect_QActions[9]->setDisabled(false);
|
||||
if (!vect_QActions.empty())
|
||||
vect_QActions[9]->setDisabled(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -569,7 +569,7 @@ static int icvCreateTrackbar (const char* trackbar_name,
|
||||
|
||||
//pad size maxvalue in pixel
|
||||
Point qdSize;
|
||||
char valueinchar[strlen(trackbar_name)+1 +1 +1+nbDigit+1];//lenght+\n +space +(+nbDigit+)
|
||||
char valueinchar[strlen(trackbar_name)+1 +1 +1+nbDigit+1];//length+\n +space +(+nbDigit+)
|
||||
sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->maxval);
|
||||
SInt16 baseline;
|
||||
CFStringRef text = CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
#if defined (HAVE_GTK) || defined (HAVE_GTK3)
|
||||
#ifdef HAVE_GTK
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
@@ -150,77 +150,32 @@ cvImageWidget_realize (GtkWidget *widget)
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
|
||||
#if defined(HAVE_GTK3)
|
||||
GtkAllocation allocation;
|
||||
gtk_widget_get_allocation(widget, &allocation);
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
//printf("cvImageWidget_realize\n");
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (CV_IS_IMAGE_WIDGET (widget));
|
||||
|
||||
gtk_widget_set_realized(widget, TRUE);
|
||||
|
||||
#if defined(HAVE_GTK3)
|
||||
attributes.x = allocation.x;
|
||||
attributes.y = allocation.y;
|
||||
attributes.width = allocation.width;
|
||||
attributes.height = allocation.height;
|
||||
#else
|
||||
attributes.x = widget->allocation.x;
|
||||
attributes.y = widget->allocation.y;
|
||||
attributes.width = widget->allocation.width;
|
||||
attributes.height = widget->allocation.height;
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
attributes.event_mask = gtk_widget_get_events (widget) |
|
||||
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;
|
||||
attributes.visual = gtk_widget_get_visual (widget);
|
||||
|
||||
#if defined(HAVE_GTK3)
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
||||
gtk_widget_set_window(
|
||||
widget,
|
||||
gdk_window_new(
|
||||
gtk_widget_get_parent_window(widget),
|
||||
&attributes,
|
||||
attributes_mask
|
||||
)
|
||||
);
|
||||
|
||||
gtk_widget_set_style(
|
||||
widget,
|
||||
gtk_style_attach(
|
||||
gtk_widget_get_style(widget),
|
||||
gtk_widget_get_window(widget)
|
||||
)
|
||||
);
|
||||
|
||||
gdk_window_set_user_data (
|
||||
gtk_widget_get_window(widget),
|
||||
widget
|
||||
);
|
||||
|
||||
gtk_style_set_background (
|
||||
gtk_widget_get_style(widget),
|
||||
gtk_widget_get_window(widget),
|
||||
GTK_STATE_ACTIVE
|
||||
);
|
||||
#else
|
||||
// The following lines are included to prevent breaking
|
||||
// compatibility with older Gtk2 (<gtk+-2.18) libraries.
|
||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||
widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
gdk_window_set_user_data (widget->window, widget);
|
||||
|
||||
gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
|
||||
#endif // HAVE_GTK3
|
||||
}
|
||||
|
||||
static CvSize cvImageWidget_calc_size( int im_width, int im_height, int max_width, int max_height ){
|
||||
@@ -232,56 +187,6 @@ static CvSize cvImageWidget_calc_size( int im_width, int im_height, int max_widt
|
||||
return cvSize( cvRound(max_height*aspect), max_height );
|
||||
}
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
static void
|
||||
cvImageWidget_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width)
|
||||
{
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (CV_IS_IMAGE_WIDGET (widget));
|
||||
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
|
||||
|
||||
if(image_widget->original_image != NULL) {
|
||||
*minimal_width = image_widget->flags & CV_WINDOW_AUTOSIZE ?
|
||||
gdk_window_get_width(gtk_widget_get_window(widget)) : image_widget->original_image->cols;
|
||||
}
|
||||
else {
|
||||
*minimal_width = 320;
|
||||
}
|
||||
|
||||
if(image_widget->scaled_image != NULL) {
|
||||
*natural_width = *minimal_width < image_widget->scaled_image->cols ?
|
||||
image_widget->scaled_image->cols : *minimal_width;
|
||||
}
|
||||
else {
|
||||
*natural_width = *minimal_width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cvImageWidget_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height)
|
||||
{
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (CV_IS_IMAGE_WIDGET (widget));
|
||||
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
|
||||
|
||||
if(image_widget->original_image != NULL) {
|
||||
*minimal_height = image_widget->flags & CV_WINDOW_AUTOSIZE ?
|
||||
gdk_window_get_height(gtk_widget_get_window(widget)) : image_widget->original_image->rows;
|
||||
}
|
||||
else {
|
||||
*minimal_height = 240;
|
||||
}
|
||||
|
||||
if(image_widget->scaled_image != NULL) {
|
||||
*natural_height = *minimal_height < image_widget->scaled_image->rows ?
|
||||
image_widget->scaled_image->cols : *minimal_height;
|
||||
}
|
||||
else {
|
||||
*natural_height = *minimal_height;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
static void
|
||||
cvImageWidget_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
@@ -312,7 +217,6 @@ cvImageWidget_size_request (GtkWidget *widget,
|
||||
}
|
||||
//printf("%d %d\n",requisition->width, requisition->height);
|
||||
}
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
static void cvImageWidget_set_size(GtkWidget * widget, int max_width, int max_height){
|
||||
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
|
||||
@@ -333,7 +237,7 @@ static void cvImageWidget_set_size(GtkWidget * widget, int max_width, int max_he
|
||||
cvReleaseMat( &image_widget->scaled_image );
|
||||
}
|
||||
if( !image_widget->scaled_image ){
|
||||
image_widget->scaled_image = cvCreateMat( scaled_image_size.height, scaled_image_size.width, CV_8UC3 );
|
||||
image_widget->scaled_image = cvCreateMat( scaled_image_size.height, scaled_image_size.width, CV_8UC3 );
|
||||
|
||||
|
||||
}
|
||||
@@ -351,11 +255,7 @@ cvImageWidget_size_allocate (GtkWidget *widget,
|
||||
g_return_if_fail (CV_IS_IMAGE_WIDGET (widget));
|
||||
g_return_if_fail (allocation != NULL);
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
#else
|
||||
widget->allocation = *allocation;
|
||||
#endif //HAVE_GTK3
|
||||
image_widget = CV_IMAGE_WIDGET (widget);
|
||||
|
||||
|
||||
@@ -379,37 +279,26 @@ cvImageWidget_size_allocate (GtkWidget *widget,
|
||||
((image_widget->flags & CV_WINDOW_AUTOSIZE) ||
|
||||
(image_widget->flags & CV_WINDOW_NO_IMAGE)) )
|
||||
{
|
||||
#if defined (HAVE_GTK3)
|
||||
allocation->width = image_widget->original_image->cols;
|
||||
allocation->height = image_widget->original_image->rows;
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
#else
|
||||
widget->allocation.width = image_widget->original_image->cols;
|
||||
widget->allocation.height = image_widget->original_image->rows;
|
||||
#endif //HAVE_GTK3
|
||||
gdk_window_move_resize( gtk_widget_get_window(widget),
|
||||
allocation->x, allocation->y,
|
||||
image_widget->original_image->cols, image_widget->original_image->rows );
|
||||
gdk_window_move_resize( widget->window, allocation->x, allocation->y,
|
||||
image_widget->original_image->cols, image_widget->original_image->rows );
|
||||
if(image_widget->flags & CV_WINDOW_NO_IMAGE){
|
||||
image_widget->flags &= ~CV_WINDOW_NO_IMAGE;
|
||||
gtk_widget_queue_resize( GTK_WIDGET(widget) );
|
||||
}
|
||||
}
|
||||
else{
|
||||
gdk_window_move_resize (gtk_widget_get_window(widget),
|
||||
gdk_window_move_resize (widget->window,
|
||||
allocation->x, allocation->y,
|
||||
allocation->width, allocation->height );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
static void
|
||||
cvImageWidget_destroy (GtkWidget *object)
|
||||
#else
|
||||
static void
|
||||
cvImageWidget_destroy (GtkObject *object)
|
||||
#endif //HAVE_GTK3
|
||||
{
|
||||
CvImageWidget *image_widget;
|
||||
|
||||
@@ -421,39 +310,24 @@ cvImageWidget_destroy (GtkObject *object)
|
||||
cvReleaseMat( &image_widget->scaled_image );
|
||||
cvReleaseMat( &image_widget->original_image );
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
if (GTK_WIDGET_CLASS (parent_class)->destroy)
|
||||
(* GTK_WIDGET_CLASS (parent_class)->destroy) (object);
|
||||
#else
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
#endif //HAVE_GTK3
|
||||
}
|
||||
|
||||
static void cvImageWidget_class_init (CvImageWidgetClass * klass)
|
||||
{
|
||||
#if defined (HAVE_GTK3)
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
#else
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
widget_class = (GtkWidgetClass*) klass;
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
parent_class = GTK_WIDGET_CLASS( g_type_class_peek (gtk_widget_get_type ()) );
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
widget_class->destroy = cvImageWidget_destroy;
|
||||
widget_class->get_preferred_width = cvImageWidget_get_preferred_width;
|
||||
widget_class->get_preferred_height = cvImageWidget_get_preferred_height;
|
||||
#else
|
||||
object_class->destroy = cvImageWidget_destroy;
|
||||
widget_class->size_request = cvImageWidget_size_request;
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
widget_class->realize = cvImageWidget_realize;
|
||||
widget_class->size_request = cvImageWidget_size_request;
|
||||
widget_class->size_allocate = cvImageWidget_size_allocate;
|
||||
widget_class->button_press_event = NULL;
|
||||
widget_class->button_release_event = NULL;
|
||||
@@ -473,15 +347,13 @@ GType cvImageWidget_get_type (void){
|
||||
|
||||
if (!image_type)
|
||||
{
|
||||
image_type = g_type_register_static_simple(
|
||||
GTK_TYPE_WIDGET,
|
||||
(gchar*) "CvImageWidget",
|
||||
sizeof(CvImageWidgetClass),
|
||||
(GClassInitFunc) cvImageWidget_class_init,
|
||||
sizeof(CvImageWidget),
|
||||
(GInstanceInitFunc) cvImageWidget_init,
|
||||
(GTypeFlags)NULL
|
||||
);
|
||||
image_type = g_type_register_static_simple( GTK_TYPE_WIDGET,
|
||||
(gchar*) "CvImageWidget",
|
||||
sizeof(CvImageWidgetClass),
|
||||
(GClassInitFunc) cvImageWidget_class_init,
|
||||
sizeof(CvImageWidget),
|
||||
(GInstanceInitFunc) cvImageWidget_init,
|
||||
(GTypeFlags)NULL);
|
||||
}
|
||||
|
||||
return image_type;
|
||||
@@ -770,12 +642,8 @@ double cvGetRatioWindow_GTK(const char* name)
|
||||
if (!window)
|
||||
EXIT; // keep silence here
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
result = static_cast<double>(
|
||||
gtk_widget_get_allocated_width(window->widget)) / gtk_widget_get_allocated_height(window->widget);
|
||||
#else
|
||||
result = static_cast<double>(window->widget->allocation.width) / window->widget->allocation.height;
|
||||
#endif // HAVE_GTK3
|
||||
|
||||
__END__;
|
||||
|
||||
return result;
|
||||
@@ -870,55 +738,7 @@ namespace
|
||||
|
||||
#endif // HAVE_OPENGL
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
static gboolean cvImageWidget_draw(GtkWidget* widget, cairo_t *cr, gpointer data)
|
||||
{
|
||||
#ifdef HAVE_OPENGL
|
||||
CvWindow* window = (CvWindow*)data;
|
||||
|
||||
if (window->useGl)
|
||||
{
|
||||
drawGl(window);
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
(void)data;
|
||||
#endif
|
||||
|
||||
CvImageWidget *image_widget = NULL;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
g_return_val_if_fail (widget != NULL, FALSE);
|
||||
g_return_val_if_fail (CV_IS_IMAGE_WIDGET (widget), FALSE);
|
||||
|
||||
image_widget = CV_IMAGE_WIDGET (widget);
|
||||
|
||||
if( image_widget->scaled_image ){
|
||||
// center image in available region
|
||||
int x0 = (gtk_widget_get_allocated_width(widget) - image_widget->scaled_image->cols)/2;
|
||||
int y0 = (gtk_widget_get_allocated_height(widget) - image_widget->scaled_image->rows)/2;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_data(image_widget->scaled_image->data.ptr, GDK_COLORSPACE_RGB, false,
|
||||
8, MIN(image_widget->scaled_image->cols, gtk_widget_get_allocated_width(widget)),
|
||||
MIN(image_widget->scaled_image->rows, gtk_widget_get_allocated_height(widget)),
|
||||
image_widget->scaled_image->step, NULL, NULL);
|
||||
|
||||
gdk_cairo_set_source_pixbuf(cr, pixbuf, x0, y0);
|
||||
}
|
||||
else if( image_widget->original_image ){
|
||||
pixbuf = gdk_pixbuf_new_from_data(image_widget->original_image->data.ptr, GDK_COLORSPACE_RGB, false,
|
||||
8, MIN(image_widget->original_image->cols, gtk_widget_get_allocated_width(widget)),
|
||||
MIN(image_widget->original_image->rows, gtk_widget_get_allocated_height(widget)),
|
||||
image_widget->original_image->step, NULL, NULL);
|
||||
gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
|
||||
}
|
||||
|
||||
cairo_paint(cr);
|
||||
g_object_unref(pixbuf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else
|
||||
static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
|
||||
{
|
||||
#ifdef HAVE_OPENGL
|
||||
@@ -956,7 +776,6 @@ static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, g
|
||||
8, MIN(image_widget->scaled_image->cols, widget->allocation.width),
|
||||
MIN(image_widget->scaled_image->rows, widget->allocation.height),
|
||||
image_widget->scaled_image->step, NULL, NULL);
|
||||
|
||||
gdk_cairo_set_source_pixbuf(cr, pixbuf, x0, y0);
|
||||
}
|
||||
else if( image_widget->original_image ){
|
||||
@@ -968,11 +787,9 @@ static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, g
|
||||
}
|
||||
|
||||
cairo_paint(cr);
|
||||
g_object_unref(pixbuf);
|
||||
cairo_destroy(cr);
|
||||
return TRUE;
|
||||
}
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
CV_IMPL int cvNamedWindow( const char* name, int flags )
|
||||
{
|
||||
@@ -1045,13 +862,8 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
|
||||
G_CALLBACK(icvOnMouse), window );
|
||||
g_signal_connect( window->frame, "delete-event",
|
||||
G_CALLBACK(icvOnClose), window );
|
||||
#if defined(HAVE_GTK3)
|
||||
g_signal_connect( window->widget, "draw",
|
||||
G_CALLBACK(cvImageWidget_draw), window );
|
||||
#else
|
||||
g_signal_connect( window->widget, "expose-event",
|
||||
G_CALLBACK(cvImageWidget_expose), window );
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
gtk_widget_add_events (window->widget, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK) ;
|
||||
|
||||
@@ -1608,13 +1420,6 @@ CV_IMPL const char* cvGetWindowName( void* window_handle )
|
||||
return window_name;
|
||||
}
|
||||
|
||||
#if defined (HAVE_GTK3)
|
||||
#define GDK_Escape GDK_KEY_Escape
|
||||
#define GDK_Return GDK_KEY_Return
|
||||
#define GDK_Linefeed GDK_KEY_Linefeed
|
||||
#define GDK_Tab GDK_KEY_Tab
|
||||
#endif //HAVE_GTK3
|
||||
|
||||
static gboolean icvOnKeyPress( GtkWidget * /*widget*/,
|
||||
GdkEventKey* event, gpointer /*user_data*/ )
|
||||
{
|
||||
@@ -1745,16 +1550,11 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
|
||||
image_widget->original_image &&
|
||||
image_widget->scaled_image ){
|
||||
// image origin is not necessarily at (0,0)
|
||||
#if defined (HAVE_GTK3)
|
||||
int x0 = (gtk_widget_get_allocated_width(widget) - image_widget->scaled_image->cols)/2;
|
||||
int y0 = (gtk_widget_get_allocated_height(widget) - image_widget->scaled_image->rows)/2;
|
||||
#else
|
||||
int x0 = (widget->allocation.width - image_widget->scaled_image->cols)/2;
|
||||
int y0 = (widget->allocation.height - image_widget->scaled_image->rows)/2;
|
||||
#endif //HAVE_GTK3
|
||||
pt.x = cvRound( ((pt32f.x-x0)*image_widget->original_image->cols)/
|
||||
pt.x = cvFloor( ((pt32f.x-x0)*image_widget->original_image->cols)/
|
||||
image_widget->scaled_image->cols );
|
||||
pt.y = cvRound( ((pt32f.y-y0)*image_widget->original_image->rows)/
|
||||
pt.y = cvFloor( ((pt32f.y-y0)*image_widget->original_image->rows)/
|
||||
image_widget->scaled_image->rows );
|
||||
}
|
||||
else{
|
||||
@@ -1829,7 +1629,7 @@ CV_IMPL int cvWaitKey( int delay )
|
||||
}
|
||||
|
||||
|
||||
#endif // HAVE_GTK || HAVE_GTK3
|
||||
#endif // HAVE_GTK
|
||||
#endif // WIN32
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -40,31 +40,15 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <windowsx.h> // required for GET_X_LPARAM() and GET_Y_LPARAM() macros
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
|
||||
#define COMPILE_MULTIMON_STUBS // Required for multi-monitor support
|
||||
#ifndef _MULTIMON_USE_SECURE_CRT
|
||||
# define _MULTIMON_USE_SECURE_CRT 0 // some MinGW platforms have no strncpy_s
|
||||
#endif
|
||||
|
||||
#if defined SM_CMONITORS && !defined MONITOR_DEFAULTTONEAREST
|
||||
# define MONITOR_DEFAULTTONULL 0x00000000
|
||||
# define MONITOR_DEFAULTTOPRIMARY 0x00000001
|
||||
# define MONITOR_DEFAULTTONEAREST 0x00000002
|
||||
# define MONITORINFOF_PRIMARY 0x00000001
|
||||
#endif
|
||||
#ifndef __inout
|
||||
# define __inout
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
#endif
|
||||
#include <MultiMon.h>
|
||||
|
||||
#include <commctrl.h>
|
||||
#include <winuser.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -106,6 +90,10 @@ static const char* trackbar_text =
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x020E
|
||||
#endif
|
||||
|
||||
static void FillBitmapInfo( BITMAPINFO* bmi, int width, int height, int bpp, int origin )
|
||||
{
|
||||
assert( bmi && width >= 0 && height >= 0 && (bpp == 8 || bpp == 24 || bpp == 32));
|
||||
@@ -1087,12 +1075,7 @@ cvShowImage( const char* name, const CvArr* arr )
|
||||
window = icvFindWindowByName(name);
|
||||
if(!window)
|
||||
{
|
||||
#ifndef HAVE_OPENGL
|
||||
cvNamedWindow(name, CV_WINDOW_AUTOSIZE);
|
||||
#else
|
||||
cvNamedWindow(name, CV_WINDOW_AUTOSIZE | CV_WINDOW_OPENGL);
|
||||
#endif
|
||||
|
||||
cvNamedWindow(name, CV_WINDOW_AUTOSIZE);
|
||||
window = icvFindWindowByName(name);
|
||||
}
|
||||
|
||||
@@ -1383,6 +1366,39 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
SetFocus(window->hwnd);
|
||||
break;
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
if( window->on_mouse )
|
||||
{
|
||||
int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
|
||||
(wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
|
||||
(wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
|
||||
(wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
|
||||
(wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
|
||||
(GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
|
||||
int event = (uMsg == WM_MOUSEWHEEL ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
|
||||
|
||||
// Set the wheel delta of mouse wheel to be in the upper word of 'event'
|
||||
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
|
||||
flags |= (delta << 16);
|
||||
|
||||
POINT pt;
|
||||
pt.x = GET_X_LPARAM( lParam );
|
||||
pt.y = GET_Y_LPARAM( lParam );
|
||||
::ScreenToClient(hwnd, &pt); // Convert screen coordinates to client coordinates.
|
||||
|
||||
RECT rect;
|
||||
GetClientRect( window->hwnd, &rect );
|
||||
|
||||
SIZE size = {0,0};
|
||||
icvGetBitmapData( window, &size, 0, 0 );
|
||||
|
||||
window->on_mouse( event, pt.x*size.cx/MAX(rect.right - rect.left,1),
|
||||
pt.y*size.cy/MAX(rect.bottom - rect.top,1), flags,
|
||||
window->on_mouse_param );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
RECT cr, tr, wrc;
|
||||
@@ -1480,8 +1496,8 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||
if( uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP )
|
||||
ReleaseCapture();
|
||||
|
||||
pt.x = LOWORD( lParam );
|
||||
pt.y = HIWORD( lParam );
|
||||
pt.x = GET_X_LPARAM( lParam );
|
||||
pt.y = GET_Y_LPARAM( lParam );
|
||||
|
||||
GetClientRect( window->hwnd, &rect );
|
||||
icvGetBitmapData( window, &size, 0, 0 );
|
||||
|
||||
Reference in New Issue
Block a user