本文整理汇总了C++中cv::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: isDir
static bool isDir(const cv::String& path, DIR* dir)
{
#if defined _WIN32 || defined WINCE
DWORD attributes;
BOOL status = TRUE;
if (dir)
attributes = dir->data.dwFileAttributes;
else
{
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
#ifdef WINRT
wchar_t wpath[MAX_PATH];
size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH);
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
status = ::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs);
#else
status = ::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs);
#endif
attributes = all_attrs.dwFileAttributes;
}
return status && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
#else
(void)dir;
struct stat stat_buf;
if (0 != stat( path.c_str(), &stat_buf))
return false;
int is_dir = S_ISDIR( stat_buf.st_mode);
return is_dir != 0;
#endif
}
开发者ID:cyberCBM,项目名称:DetectO,代码行数:31,代码来源:glob.cpp
示例2: print_info
void print_info(ID3D10Texture2D* pSurface, int mode, float fps, cv::String oclDevName)
{
HRESULT r;
UINT subResource = ::D3D10CalcSubresource(0, 0, 1);
D3D10_MAPPED_TEXTURE2D mappedTex;
r = pSurface->Map(subResource, D3D10_MAP_WRITE_DISCARD, 0, &mappedTex);
if (FAILED(r))
{
return;
}
cv::Mat m(m_height, m_width, CV_8UC4, mappedTex.pData, (int)mappedTex.RowPitch);
cv::String strMode = cv::format("%s", m_modeStr[mode].c_str());
cv::String strProcessing = m_demo_processing ? "blur frame" : "copy frame";
cv::String strFPS = cv::format("%2.1f", fps);
cv::String strDevName = cv::format("%s", oclDevName.c_str());
cv::putText(m, strMode, cv::Point(0, 16), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strProcessing, cv::Point(0, 32), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strFPS, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
m_pSurface->Unmap(subResource);
return;
} // print_info()
开发者ID:liuyq,项目名称:opencv,代码行数:29,代码来源:d3d10_interop.cpp
示例3: print_info
void print_info(ID3D11Texture2D* pSurface, int mode, float fps, cv::String oclDevName)
{
HRESULT r;
UINT subResource = ::D3D11CalcSubresource(0, 0, 1);
D3D11_MAPPED_SUBRESOURCE mappedTex;
r = m_pD3D11Ctx->Map(pSurface, subResource, D3D11_MAP_WRITE_DISCARD, 0, &mappedTex);
if (FAILED(r))
{
return;
}
cv::Mat m(m_height, m_width, CV_8UC4, mappedTex.pData, (int)mappedTex.RowPitch);
cv::String strMode = cv::format("%s", m_modeStr[mode].c_str());
cv::String strFPS = cv::format("%2.1f", fps);
cv::String strDevName = cv::format("%s", oclDevName.c_str());
cv::putText(m, strMode, cv::Point(0, 16), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strFPS, cv::Point(0, 32), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strDevName, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
m_pD3D11Ctx->Unmap(pSurface, subResource);
return;
} // printf_info()
开发者ID:4ker,项目名称:opencv,代码行数:27,代码来源:d3d11_interop.cpp
示例4: loadParameters
int loadParameters(cv::String filepath) override
{
cv::FileStorage fs;
//if user specified a pathfile, try to use it.
if (!filepath.empty())
{
fs.open(filepath, cv::FileStorage::READ);
}
// If the file opened, read the parameters.
if (fs.isOpened())
{
fs["borderX"] >> Param.borderX;
fs["borderY"] >> Param.borderY;
fs["corrWinSizeX"] >> Param.corrWinSizeX;
fs["corrWinSizeY"] >> Param.corrWinSizeY;
fs["correlationThreshold"] >> Param.correlationThreshold;
fs["textrureThreshold"] >> Param.textrureThreshold;
fs["neighborhoodSize"] >> Param.neighborhoodSize;
fs["disparityGradient"] >> Param.disparityGradient;
fs["lkTemplateSize"] >> Param.lkTemplateSize;
fs["lkPyrLvl"] >> Param.lkPyrLvl;
fs["lkTermParam1"] >> Param.lkTermParam1;
fs["lkTermParam2"] >> Param.lkTermParam2;
fs["gftQualityThres"] >> Param.gftQualityThres;
fs["gftMinSeperationDist"] >> Param.gftMinSeperationDist;
fs["gftMaxNumFeatures"] >> Param.gftMaxNumFeatures;
fs.release();
return 1;
}
开发者ID:Bleach665,项目名称:opencv_contrib,代码行数:32,代码来源:quasi_dense_stereo.cpp
示例5: save
void save(cv::String filename)
{
FILE* fout = fopen(filename.c_str(), "wb");
/*if (fout == NULL) {
throw FLANNException("Cannot open file");
}*/
save_header(fout, *nnIndex_);
saveIndex(fout);
fclose(fout);
}
开发者ID:ryuxin,项目名称:cbuf-composite,代码行数:10,代码来源:flann_base.hpp
示例6: isDir
static bool isDir(const cv::String& path, DIR* dir)
{
#if defined WIN32 || defined _WIN32 || defined WINCE
DWORD attributes;
if (dir)
attributes = dir->data.dwFileAttributes;
else
attributes = ::GetFileAttributes(path.c_str());
return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
#else
(void)dir;
struct stat stat_buf;
if (0 != stat( path.c_str(), &stat_buf))
return false;
int is_dir = S_ISDIR( stat_buf.st_mode);
return is_dir != 0;
#endif
}
开发者ID:HVisionSening,项目名称:opencv2-framework-for-mac,代码行数:19,代码来源:glob.cpp
示例7: glob_rec
static void glob_rec(const cv::String& directory, const cv::String& wildchart, std::vector<cv::String>& result, bool recursive)
{
DIR *dir;
struct dirent *ent;
if ((dir = opendir (directory.c_str())) != 0)
{
/* find all the files and directories within directory */
try
{
while ((ent = readdir (dir)) != 0)
{
const char* name = ent->d_name;
if((name[0] == 0) || (name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0))
continue;
cv::String path = directory + native_separator + name;
if (isDir(path, dir))
{
if (recursive)
glob_rec(path, wildchart, result, recursive);
}
else
{
if (wildchart.empty() || wildcmp(name, wildchart.c_str()))
result.push_back(path);
}
}
}
catch (...)
{
closedir(dir);
throw;
}
closedir(dir);
}
else CV_Error(CV_StsObjectNotFound, cv::format("could not open directory: %s", directory.c_str()));
}
开发者ID:410pfeliciano,项目名称:opencv,代码行数:39,代码来源:glob.cpp
示例8: remove_all
CV_EXPORTS void remove_all(const cv::String& path)
{
if (!exists(path))
return;
if (isDirectory(path))
{
std::vector<String> entries;
utils::fs::glob(path, cv::String(), entries, false, true);
for (size_t i = 0; i < entries.size(); i++)
{
const String& e = entries[i];
remove_all(e);
}
#ifdef _MSC_VER
bool result = _rmdir(path.c_str()) == 0;
#else
bool result = rmdir(path.c_str()) == 0;
#endif
if (!result)
{
CV_LOG_ERROR(NULL, "Can't remove directory: " << path);
}
}
else
{
#ifdef _MSC_VER
bool result = _unlink(path.c_str()) == 0;
#else
bool result = unlink(path.c_str()) == 0;
#endif
if (!result)
{
CV_LOG_ERROR(NULL, "Can't remove file: " << path);
}
}
}
开发者ID:JoeHowse,项目名称:opencv,代码行数:36,代码来源:filesystem.cpp
示例9: createDirectory
bool createDirectory(const cv::String& path)
{
CV_INSTRUMENT_REGION();
#if defined WIN32 || defined _WIN32 || defined WINCE
#ifdef WINRT
wchar_t wpath[MAX_PATH];
size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH);
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
int result = CreateDirectoryA(wpath, NULL) ? 0 : -1;
#else
int result = _mkdir(path.c_str());
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__
int result = mkdir(path.c_str(), 0777);
#else
int result = -1;
#endif
if (result == -1)
{
return isDirectory(path);
}
return true;
}
开发者ID:JoeHowse,项目名称:opencv,代码行数:24,代码来源:filesystem.cpp
示例10: print_info
void print_info(LPDIRECT3DSURFACE9 pSurface, int mode, float time, cv::String oclDevName)
{
HDC hDC;
HRESULT r = pSurface->GetDC(&hDC);
if (FAILED(r))
{
return;
}
HFONT hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont);
if (hOldFont)
{
TEXTMETRIC tm;
::GetTextMetrics(hDC, &tm);
char buf[256];
int y = 0;
buf[0] = 0;
sprintf(buf, "mode: %s", m_modeStr[mode].c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf(buf, m_demo_processing ? "blur frame" : "copy frame");
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf(buf, "time: %4.1f msec", time);
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf(buf, "OpenCL device: %s", oclDevName.c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
::SelectObject(hDC, hOldFont);
}
r = pSurface->ReleaseDC(hDC);
return;
} // print_info()
开发者ID:Jendker,项目名称:opencv,代码行数:48,代码来源:d3d9_interop.cpp
示例11: fillListWrapperLibs
void CameraWrapperConnector::fillListWrapperLibs(const cv::String& folderPath, std::vector<cv::String>& listLibs)
{
DIR *dp;
struct dirent *ep;
dp = opendir (folderPath.c_str());
if (dp != NULL)
{
while ((ep = readdir (dp))) {
const char* cur_name=ep->d_name;
if (strstr(cur_name, PREFIX_CAMERA_WRAPPER_LIB)) {
listLibs.push_back(cur_name);
LOGE("||%s", cur_name);
}
}
(void) closedir (dp);
}
}
开发者ID:0kazuya,项目名称:opencv,代码行数:18,代码来源:camera_activity.cpp
示例12: print_info
void print_info(MODE mode, float time, cv::String& oclDevName)
{
#if defined(_WIN32)
HDC hDC = m_hDC;
HFONT hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont);
if (hOldFont)
{
TEXTMETRIC tm;
::GetTextMetrics(hDC, &tm);
char buf[256+1];
int y = 0;
buf[0] = 0;
sprintf_s(buf, sizeof(buf)-1, "Mode: %s OpenGL %s", m_modeStr[mode].c_str(), use_buffer() ? "buffer" : "texture");
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf_s(buf, sizeof(buf)-1, "Time, msec: %2.1f", time);
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf_s(buf, sizeof(buf)-1, "OpenCL device: %s", oclDevName.c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
::SelectObject(hDC, hOldFont);
}
#elif defined(__linux__)
char buf[256+1];
snprintf(buf, sizeof(buf)-1, "Time, msec: %2.1f, Mode: %s OpenGL %s, Device: %s", time, m_modeStr[mode].c_str(), use_buffer() ? "buffer" : "texture", oclDevName.c_str());
XStoreName(m_display, m_window, buf);
#endif
}
开发者ID:ArkaJU,项目名称:opencv,代码行数:40,代码来源:opengl_interop.cpp
示例13: print_info
void print_info(int mode, float fps, cv::String oclDevName)
{
#if defined(WIN32) || defined(_WIN32)
HDC hDC = m_hDC;
HFONT hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont);
if (hOldFont)
{
TEXTMETRIC tm;
::GetTextMetrics(hDC, &tm);
char buf[256+1];
int y = 0;
buf[0] = 0;
sprintf_s(buf, sizeof(buf)-1, "Mode: %s", m_modeStr[mode].c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf_s(buf, sizeof(buf)-1, "FPS: %2.1f", fps);
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
buf[0] = 0;
sprintf_s(buf, sizeof(buf)-1, "OpenCL device: %s", oclDevName.c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
::SelectObject(hDC, hOldFont);
}
#elif defined(__linux__)
char buf[256+1];
snprintf(buf, sizeof(buf)-1, "FPS: %2.1f Mode: %s Device: %s", fps, m_modeStr[mode].c_str(), oclDevName.c_str());
XStoreName(m_display, m_window, buf);
#endif
}
开发者ID:liuyq,项目名称:opencv,代码行数:40,代码来源:opengl_interop.cpp
示例14: save
static inline void save(OutputArchive& ar, const cv::String& val)
{
ar = Nan::New<v8::String>(val.c_str());
}
开发者ID:BrainsoftLtd,项目名称:cloudcv-bootstrap,代码行数:4,代码来源:opencv.hpp
示例15: imshow
void imshow(cv::String name, cv::Mat im)
{
GuiReceiver::getInstance()->showImage(QString(name.c_str()), im);
}
开发者ID:Petititi,项目名称:imGraph,代码行数:4,代码来源:GuiReceiver.cpp
示例16: detectFaces
// Detect faces in a photo
std::vector<FaceRect> detectFaces(cv::String inputName, cv::String cascadeName, double scale, bool infer = false) {
cv::CascadeClassifier cascade;
if (!cascade.load(cascadeName)) {
std::cout << "error;Could not load classifier cascade. Filename: \"" << cascadeName << "\"" << std::endl;
}
if (inputName.empty()) {
std::cout << "error;You must specify the file to process." << std::endl;
}
cv::Mat img = cv::imread(inputName, 1);
if (img.empty()) {
std::cout << "error;Could not load the file to process. Filename: \"" << inputName << "\"" << std::endl;
}
std::vector<cv::Rect> faces;
cv::Size smallImgSize;
static bool disableDnn;
#ifdef HAS_OPENCV_DNN
disableDnn = faceDetectNet.empty();
#else
disableDnn = true;
#endif
if (disableDnn) {
// Classical face detection
cv::Mat gray;
cvtColor(img, gray, CV_BGR2GRAY);
cv::Mat smallImg(cvRound(img.rows / scale), cvRound(img.cols / scale), CV_8UC1);
smallImgSize = smallImg.size();
cv::resize(gray, smallImg, smallImgSize, 0, 0, cv::INTER_LINEAR);
cv::equalizeHist(smallImg, smallImg);
cascade.detectMultiScale(smallImg, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));
} else {
#ifdef HAS_OPENCV_DNN
// DNN based face detection
faces = detectFacesMat(img);
smallImgSize = img.size(); // Not using the small image here
#endif
}
std::vector<FaceRect> scaled;
for (std::vector<cv::Rect>::const_iterator r = faces.begin(); r != faces.end(); r++) {
FaceRect i;
i.x = (float) r->x / smallImgSize.width;
i.y = (float) r->y / smallImgSize.height;
i.width = (float) r->width / smallImgSize.width;
i.height = (float) r->height / smallImgSize.height;
#ifdef HAS_OPENCV_DNN
if (infer && !faceRecogNet.empty()) {
// Get colour image for vector generation
cv::Mat colourImg;
cv::resize(img, colourImg, smallImgSize, 0, 0, cv::INTER_LINEAR);
i.vec = faceToVecMat(colourImg(*r)); // Run vector conversion on the face
} else {
i.vec.assign(128, 0);
}
#else
i.vec.assign(128, 0);
#endif
scaled.push_back(i);
}
return scaled;
}
开发者ID:GNOME,项目名称:shotwell,代码行数:69,代码来源:facedetect-opencv.cpp
示例17: VideoCapture_create
void VideoCapture_create(CvCapture*& capture, Ptr<IVideoCapture>& icap, VideoCaptureAPIs api, const cv::String& filename)
{
switch (api)
{
default:
CV_LOG_WARNING(NULL, "VideoCapture(filename=" << filename << ") was built without support of requested backendID=" << (int)api);
break;
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
case CAP_V4L:
TRY_OPEN_LEGACY(cvCreateCameraCapture_V4L(filename.c_str()))
break;
#endif
#ifdef HAVE_VFW
case CAP_VFW:
TRY_OPEN_LEGACY(cvCreateFileCapture_VFW(filename.c_str()))
break;
#endif
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
case CAP_QT:
TRY_OPEN_LEGACY(cvCreateFileCapture_QT(filename.c_str()))
break;
#endif
#ifdef HAVE_AVFOUNDATION
case CAP_AVFOUNDATION:
TRY_OPEN_LEGACY(cvCreateFileCapture_AVFoundation(filename.c_str()))
break;
#endif
#ifdef HAVE_OPENNI
case CAP_OPENNI:
TRY_OPEN_LEGACY(cvCreateFileCapture_OpenNI(filename.c_str()))
break;
#endif
#ifdef HAVE_OPENNI2
case CAP_OPENNI2:
TRY_OPEN_LEGACY(cvCreateFileCapture_OpenNI2(filename.c_str()))
break;
#endif
#ifdef HAVE_XIMEA
case CAP_XIAPI:
TRY_OPEN_LEGACY(cvCreateCameraCapture_XIMEA(filename.c_str()))
break;
#endif
case CAP_IMAGES:
TRY_OPEN_LEGACY(cvCreateFileCapture_Images(filename.c_str()))
break;
#ifdef HAVE_FFMPEG
case CAP_FFMPEG:
TRY_OPEN(cvCreateFileCapture_FFMPEG_proxy(filename))
break;
#endif
#ifdef HAVE_GSTREAMER
case CAP_GSTREAMER:
TRY_OPEN(createGStreamerCapture(filename))
break;
#endif
#ifdef HAVE_XINE
case CAP_XINE:
TRY_OPEN(createXINECapture(filename.c_str()))
break;
#endif
#ifdef HAVE_MSMF
case CAP_MSMF:
TRY_OPEN(cvCreateCapture_MSMF(filename))
break;
#endif
#ifdef HAVE_GPHOTO2
case CAP_GPHOTO2:
TRY_OPEN(createGPhoto2Capture(filename))
break;
#endif
#ifdef HAVE_MFX
case CAP_INTEL_MFX:
TRY_OPEN(makePtr<VideoCapture_IntelMFX>(filename))
break;
#endif
case CAP_OPENCV_MJPEG:
TRY_OPEN(createMotionJpegCapture(filename))
break;
} // switch
}
开发者ID:ArkaJU,项目名称:opencv,代码行数:85,代码来源:videoio_registry.cpp
示例18: LOGD
cv::String CameraWrapperConnector::getPathLibFolder()
{
if (!pathLibFolder.empty())
return pathLibFolder;
Dl_info dl_info;
if(0 != dladdr((void *)nextFrame, &dl_info))
{
LOGD("Library name: %s", dl_info.dli_fname);
LOGD("Library base address: %p", dl_info.dli_fbase);
const char* libName=dl_info.dli_fname;
while( ((*libName)=='/') || ((*libName)=='.') )
libName++;
char lineBuf[2048];
FILE* file = fopen("/proc/self/smaps", "rt");
if(file)
{
while (fgets(lineBuf, sizeof lineBuf, file) != NULL)
{
//verify that line ends with library name
int lineLength = strlen(lineBuf);
int libNameLength = strlen(libName);
//trim end
for(int i = lineLength - 1; i >= 0 && isspace(lineBuf[i]); --i)
{
lineBuf[i] = 0;
--lineLength;
}
if (0 != strncmp(lineBuf + lineLength - libNameLength, libName, libNameLength))
{
//the line does not contain the library name
continue;
}
//extract path from smaps line
char* pathBegin = strchr(lineBuf, '/');
if (0 == pathBegin)
{
LOGE("Strange error: could not find path beginning in lin \"%s\"", lineBuf);
continue;
}
char* pathEnd = strrchr(pathBegin, '/');
pathEnd[1] = 0;
LOGD("Libraries folder found: %s", pathBegin);
fclose(file);
return pathBegin;
}
fclose(file);
LOGE("Could not find library path");
}
else
{
LOGE("Could not read /proc/self/smaps");
}
}
else
{
LOGE("Could not get library name and base address");
}
return cv::String();
}
开发者ID:0kazuya,项目名称:opencv,代码行数:70,代码来源:camera_activity.cpp
注:本文中的cv::String类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论