我正在为我的移动应用程序制作一些Restful API.
APP和Web服务器之间的通信必须在REST中进行.这些apis应该是私有的,只有我的应用程序才能调用它们以获得成功的结果.
困难的部分是,我的应用程序中不需要用户ID和密码,因此我不知道如何在没有基本用户身份验证的情况下使用移动应用程序限制rest API.
我认为一种解决方案是嵌入某种硬编码字符串,因此当移动应用程序使用restful url时,他们将通过ssl以加密格式传递.但我知道这似乎是非常糟糕的解决方案..
请在这种情况下建议什么应该是最好的解决方案.
我试图在matlab中绘制速度向量,我们使用"箭头"功能http://www.mathworks.com/help/techdoc/ref/quiver.html
我需要使用OpenCV库在C++中移植相同的方法.
我听说有一些光流方法,即Lucas和Kanade(cvCalOpticalFlowLK)或Horn和Schunck(cvCalOpticalFlowHS)或块匹配方法(cvCalOpticalFlowBM)
但所有这些功能都需要两个图像,而我需要使用一个图像,因为我正在处理指纹.
请帮助我......
[编辑]找到解决方案
void cvQuiver(IplImage*Image,int x,int y,int u,int v,CvScalar Color,
int Size,int Thickness){
cv::Point pt1,pt2;
double Theta;
double PI = 3.1416;
if(u==0)
Theta=PI/2;
else
Theta=atan2(double(v),(double)(u));
pt1.x=x;
pt1.y=y;
pt2.x=x+u;
pt2.y=y+v;
cv::line(Image,pt1,pt2,Color,Thickness,8); //Draw Line
Size=(int)(Size*0.707);
if(Theta==PI/2 && pt1.y > pt2.y)
{
pt1.x=(int)(Size*cos(Theta)-Size*sin(Theta)+pt2.x);
pt1.y=(int)(Size*sin(Theta)+Size*cos(Theta)+pt2.y);
cv::line(Image,pt1,pt2,Color,Thickness,8); //Draw Line
pt1.x=(int)(Size*cos(Theta)+Size*sin(Theta)+pt2.x);
pt1.y=(int)(Size*sin(Theta)-Size*cos(Theta)+pt2.y);
cv::line(Image,pt1,pt2,Color,Thickness,8); //Draw Line
}
else{
pt1.x=(int)(-Size*cos(Theta)-Size*sin(Theta)+pt2.x);
pt1.y=(int)(-Size*sin(Theta)+Size*cos(Theta)+pt2.y);
cv::line(Image,pt1,pt2,Color,Thickness,8); //Draw Line
pt1.x=(int)(-Size*cos(Theta)+Size*sin(Theta)+pt2.x);
pt1.y=(int)(-Size*sin(Theta)-Size*cos(Theta)+pt2.y);
cv::line(Image,pt1,pt2,Color,Thickness,8); //Draw Line
}
}
Run Code Online (Sandbox Code Playgroud) 我想显示404错误页面,因为我在protected/view/system文件夹中创建了error404.php文件.
默认情况下,我有Sitecontroller,它包含错误动作功能,如下所示
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
Run Code Online (Sandbox Code Playgroud)
在主配置文件中,它被定义为
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
Run Code Online (Sandbox Code Playgroud)
我的问题是我只需要自定义404页面,其余的错误我需要处理它由sitecontroller的错误函数处理的方式.但我找不到办法做到这一点.如果我想删除'errorAction'=>'site/error',那么它会通过调用显示404错误
throw new CHttpException(404, 'Page not found');
Run Code Online (Sandbox Code Playgroud)
但这样做我只能看到没有布局的页面,其他自定义错误被视为404,而不是.我多次阅读手册,但我仍然无法解决它.
我已经为dft做了一些预处理,我试图通过imwrite保存这个图像.
我的裁剪图像有此信息
output.type() 5
output.channels() 1
output.depth() 5
Run Code Online (Sandbox Code Playgroud)
但每当我保存它时会产生黑色输出.我已经检查了堆栈流的旧现有线程,但似乎都不适合我.例如 OpenCV2.3 imwrite保存黑色图像
我也尝试了很多颜色转换和深度转换,但我不知道为什么它不起作用.
std::vector<int> qualityType;
qualityType.push_back(CV_IMWRITE_JPEG_QUALITY);
qualityType.push_back(90);
Mat out1,out2;
cv::cvtColor(output, out1, CV_GRAY2BGR);
//out1.convertTo(out2,CV_8U,1./256); // i tried this too
cv::imwrite("dft1.jpg",out1,qualityType); // tried even using quality type
Run Code Online (Sandbox Code Playgroud)
imshow显示这个图像很好只有问题来我保存它.
请帮忙
[编辑]也许我制作的dft类有问题,因为每当我使用dft函数时输出只能用于inshow但是为了保存它不起作用.
CDftRidgeAnalyses::CDftRidgeAnalyses(void)
{
}
CDftRidgeAnalyses::~CDftRidgeAnalyses(void)
{
}
Mat CDftRidgeAnalyses::GetRidgeAnalyses(Mat inpGray)
{
Mat img = inpGray;
int WidthPadded=0,HeightPadded=0;
WidthPadded=img.cols*2;
HeightPadded=img.rows*2;
int M = getOptimalDFTSize( img.rows );
//Create a Gaussian Highpass filter 5% the height of the Fourier transform
double db = 0.05 * HeightPadded;
Mat …
Run Code Online (Sandbox Code Playgroud) 我已经看过许多教程和信息,但是我找不到如何在任何其他自定义相机应用程序中使用现有相机应用程序的默认设置的地方。我已经看到图像的清晰度,并且在内置相机应用程序中其焦点非常好。现在,我正在使用自己的自定义功能创建自己的应用程序,但是我仍然无法使其清晰而又不模糊...我不想使用相机的Intent技术,因为之后必须要做一些图像处理。
我曾经使用过缩放功能,但是奇怪的是,缩放功能无法正常使用...就像在内置相机应用程序中一样
这是我的表面变化代码
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h)
{
Log.e(TAG, "surfaceChanged");
// XXX stopPreview() will crash if preview is not running
if (mPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters params = mCamera.getParameters();
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
mFrameWidth = w;
mFrameHeight = h;
// selecting optimal camera preview size
{
double minDiff = Double.MAX_VALUE;
for (Camera.Size size : sizes)
{
if (Math.abs(size.height - h) < minDiff)
{
mFrameWidth = size.width;
mFrameHeight = size.height;
minDiff = Math.abs(size.height - h); …
Run Code Online (Sandbox Code Playgroud) 我刚从Windows商店购买了我的开发者帐户,我想在上传之前签署我的应用程序.当我进入包装然后点击选择证书按钮时,我看到以下选项:
我使用第三个选项测试了所有内容,但第一个选项,从证书库中选择,给出了如下错误:
没有可用的证书
没有证书符合申请标准.
这是错误的屏幕截图:
我怎么能拿到证书?我认为像Apple iTunes我可以从商店创建证书然后我将使用它或像Android自签名证书.
我正在使用Visual Studio 2013 ..
请帮助
我正在通过位图 api 从图库加载图像,但图像的方向与我保存的方向不同。在stackoverflow的某个地方,我读到我需要获取原始值,然后旋转矩阵。我试过这个,但我的方向来自 exif 界面的 0。
int desiredImageWidth = 310; // pixels
int desiredImageHeight = 518; // pixels
Log.i("FA", "Image Loading "+strFileName);
BitmapFactory.Options o = new BitmapFactory.Options();
Bitmap newImage = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(strFileName, o),
desiredImageWidth,
desiredImageHeight,
false);
Bitmap finalBmp = getCorrectOrientedBitmap(strFileName,newImage);
Bitmap myBitmap32 = finalBmp.copy(Bitmap.Config.ARGB_8888, true);
Mat matImg = Utils.bitmapToMat(myBitmap32);
Run Code Online (Sandbox Code Playgroud)
我的主要定位功能是
private Bitmap getCorrectOrientedBitmap(String filename,Bitmap Source) throws IOException{
Bitmap rotatedBitmap = null;
ExifInterface exif = new ExifInterface(filename);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Matrix matrix = new Matrix();
Log.i("FA", "orientation "+orientation);
switch(orientation)
{ …
Run Code Online (Sandbox Code Playgroud) 我想为主模板布局放置默认的元数据描述标签.
在许多情况下,我需要使用视图中的自定义数据替换描述和关键字等默认元标记.
我试过了:
$this->registerMetaTag
Run Code Online (Sandbox Code Playgroud)
在我需要自定义元标记的视图中,我也在主布局中使用了它.
我想如果我将使用带有id或名称的元标记,它将被替换,但结果显示重复的元标记,例如
<meta id="main_index" name="Description" content="my default content added by layout.">
<meta id="main_index" name="Description" content="my customized content added by the view"></head>
Run Code Online (Sandbox Code Playgroud)
提供默认描述标记的最佳方法是什么,但每次调用时都可以通过视图进行自定义 $this->registerMetaTag
这可能是一个简单的问题,但我有点困惑,所以希望有人指导我.
我正在使用openCV libfacerec的人脸识别库,它给出了很好的结果,但我需要估计相似性的百分比.如果我使用未知图像作为输入,那么它仍然根据最后距离值预测好像该人存在于系统中
if(dist < minDist) {
minDist = dist;
minClass = _labels[sampleIdx];
}
Run Code Online (Sandbox Code Playgroud)
我需要定义一些阈值,然后根据该阈值对某个百分比或距离值验证/无效用户图片,是否有人知道如何使用libfacerec库执行此操作,因为在此库中没有公共变量来查看距离或百分比值?否则我需要在库内为它编码,因为据我所知,它不包含此功能???
我正在使用Get方法进行表单发布但我不感兴趣,如果有人能看到我是否正在使用yii框架.所以我不需要使用YII_CSRF_TOKEN,而是需要创建自己定义的id名称,例如只有TOKEN.
我不想透露我正在使用的框架,任何类型的提示或帮助???
我想在确定正确的填充尺寸后创建高斯高通滤波器(例如,如果图像宽度和高度是10X10,那么应该是20X20).
我有Matlab代码,我试图在OpenCV中移植,但我很难正确移植它.我的Matlab代码如下所示:
f1_seg = imread('thumb1-small-test.jpg');
Iori = f1_seg;
% Iori = imresize(Iori, 0.2);
%Convert to grayscale
I = Iori;
if length(size(I)) == 3
I = rgb2gray(Iori);
end
%
%Determine good padding for Fourier transform
PQ = paddedsize(size(I));
I = double(I);
%Create a Gaussian Highpass filter 5% the width of the Fourier transform
D0 = 0.05*PQ(1);
H = hpfilter('gaussian', PQ(1), PQ(2), D0);
% Calculate the discrete Fourier transform of the image.
F=fft2(double(I),size(H,1),size(H,2));
% Apply the highpass filter to the Fourier spectrum …
Run Code Online (Sandbox Code Playgroud) 我使用Itext库进行PDF签名,适用于50MB以下的小文件.但是如果文件大小为150MB那么大小的文件就会崩溃
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at com.itextpdf.text.pdf.ByteBuffer.append(ByteBuffer.java:210)
at com.itextpdf.text.pdf.ByteBuffer.write(ByteBuffer.java:622)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
at java.io.FilterOutputStream.write(FilterOutputStream.java:80)
at com.itextpdf.text.pdf.OutputStreamCounter.write(OutputStreamCounter.java:104)
at com.itextpdf.text.pdf.PRStream.toPdf(PRStream.java:230)
at com.itextpdf.text.pdf.PdfIndirectObject.writeTo(PdfIndirectObject.java:157)
at com.itextpdf.text.pdf.PdfWriter$PdfBody.write(PdfWriter.java:397)
at com.itextpdf.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:386)
at com.itextpdf.text.pdf.PdfWriter.addToBody(PdfWriter.java:848)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:353)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:327)
at com.itextpdf.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:1244)
at com.itextpdf.text.pdf.security.MakeSignature.signDetached(MakeSignature.java:134)
Run Code Online (Sandbox Code Playgroud)
这是我的签名代码,适用于少于50 MB的pdf文件
private void PdfSigningProcess(String src, String dest,
Certificate[] chain,
PrivateKey pk, String digestAlgorithm, String provider,
MakeSignature.CryptoStandard subfilter, String reason, String location)
throws
GeneralSecurityException, IOException, DocumentException
{
// Creating the reader and the stamper
PdfReader reader =
new PdfReader(src);
FileOutputStream os =
new …
Run Code Online (Sandbox Code Playgroud) 我是json的新手,我有一个问题,为什么json_decode在<和>的标签之间返回空字符串...这里是我的json字符串
{
"clipboard":
{
"title": " Mozilla Firefox ",
"event": "<MOUSE+Copy/Paste>"
}
}
Run Code Online (Sandbox Code Playgroud)
json_decode到var_dump的输出显示
object(stdClass)#44 (1) { ["clipboard"]=> object(stdClass)#45 (2) { ["title"]=> string(17) " Mozilla Firefox " ["event"]=> string(18) "" } }
Run Code Online (Sandbox Code Playgroud)
为什么它一直在"<"和">"之间删除数据,我在一个在线json编辑器上检查它成功验证了我的json字符串,它确实显示了它的值.但是当我使用deocde_json时,"event"数组元素变为空.
opencv ×5
php ×5
android ×3
c++ ×3
java ×3
yii ×3
image ×2
api ×1
camera ×1
certificate ×1
csrf ×1
default ×1
depth ×1
dft ×1
exception ×1
fft ×1
gaussian ×1
html ×1
html5 ×1
itext ×1
json ×1
matrix ×1
orientation ×1
percentage ×1
rest ×1
save ×1
settings ×1
sign ×1
string ×1
vector ×1
yii2 ×1