我正在尝试在即将推出的应用中实现裁剪和透视校正功能.在做研究的同时,我遇到了:
在一组cv :: Point上执行cv :: warpPerspective以进行伪偏移
http://sudokugrab.blogspot.ch/2009/07/how-does-it-all-work.html
所以我决定尝试用OpenCV实现这个功能 - 框架就在那里,所以安装很快.但是,我没有得到我希望的结果:(第二张图片是结果)


我已经翻译了所有代码以使用Xcode并三次检查坐标.你能告诉我我的代码有什么问题吗?为了完整起见,我还包括了UIImage - > Mat转换+反转:
- (void)confirmedImage
{
if ([_adjustRect frameEdited]) {
cv::Mat src = [self cvMatFromUIImage:_sourceImage];
// My original Coordinates
// 4-------3
// | |
// | |
// | |
// 1-------2
CGFloat scaleFactor = [_sourceImageView contentScale];
CGPoint p1 = [_adjustRect coordinatesForPoint:4 withScaleFactor:scaleFactor];
CGPoint p2 = [_adjustRect coordinatesForPoint:3 withScaleFactor:scaleFactor];
CGPoint p3 = [_adjustRect coordinatesForPoint:1 withScaleFactor:scaleFactor];
CGPoint p4 = [_adjustRect coordinatesForPoint:2 withScaleFactor:scaleFactor];
std::vector<cv::Point2f> c1;
c1.push_back(cv::Point2f(p1.x, p1.y));
c1.push_back(cv::Point2f(p2.x, p2.y));
c1.push_back(cv::Point2f(p3.x, p3.y)); …Run Code Online (Sandbox Code Playgroud) 我已经进行了全面研究,以便找到在iOS上执行自适应阈值处理的内核.不幸的是,我不了解内核语言或其背后的逻辑.下面,我找到了一个执行阈值处理的例程(https://gist.github.com/xhruso00/a3f8a9c8ae7e33b8b23d)
static NSString * const kKernelSource = @"kernel vec4 thresholdKernel(sampler image)\n"
"{\n"
" float inputThreshold = 0.05;\n"
" float pass = 1.0;\n"
" float fail = 0.0;\n"
" const vec4 vec_Y = vec4( 0.299, 0.587, 0.114, 0.0 );\n"
" vec4 src = unpremultiply( sample(image, samplerCoord(image)) );\n"
" float Y = dot( src, vec_Y );\n"
" src.rgb = vec3( compare( Y - inputThreshold, fail, pass));\n"
" return premultiply(src);\n"
"}";
Run Code Online (Sandbox Code Playgroud)
是否有可能将其重写为自适应阈值内核?我提供给它的图像已经变成B&W并且已经模糊了.你能指点我的资源吗?我想坚持使用CoreImage,因为我的整个堆栈是围绕它构建的.
编辑:我想要实现的最佳示例/参考已在GPUImage的GPUImageAdaptiveThresholdFilter中实现 - https://github.com/BradLarson/GPUImage/blob/c5f0914152419437869c35e29858773b1a06083c/framework/Source/GPUImageAdaptiveThresholdFilter.m
我正在使用以下代码将新页面添加到现有PDF文档并保存.
require('addons/fpdf.php');
require('addons/fpdi.php');
$pdf = new FPDI();
$pagecount = $pdf->setSourceFile($orgpdfpath);
for($i = 1; $i <= $pagecount; $i++){
$pdf->addPage();
$tplidx = $pdf->importPage($i);
$pdf->useTemplate($tplidx);
}
$pdf->addPage($pdforientation);
$pdf->Image($imgpath,$pdfxaxis,$pdfyaxis,$pdfwith,$pdfheight);
$pdf->Output($orgpdfpath,'F');
Run Code Online (Sandbox Code Playgroud)
如果我有一个A4,第1页:肖像,第2页:肖像,第3页:肖像等文档,它可以正常工作.
如果我添加横向A4页面也可以.但是,在我添加了横向页面并尝试添加纵向后,横向将移回到纵向,并且文档的整个格式会中断.
我怀疑这必须在循环中使用addPage().为什么在应用 - > useTemplate时它不能正确旋转?
我正在GitHub上README.mediawiki为我的项目编写一个名为plainBlog的文件,但我想在其上添加一些内联代码.这是什么语法?另外,XML代码的语法是什么(多行)?
内联代码的一个例子位于github/markup,我们有这样的行:gem install wikicloth
我只想在我的UINavigationController堆栈中的一个View上支持不同的Orientations.我怎样才能做到这一点?
它也必须在iOS5中工作.
objective-c orientation uiviewcontroller uinavigationcontroller ios6
我需要在iOS 7的UIAlertView上添加Multiple UITextField吗?
myAlertView = [[UIAlertView alloc] initWithTitle:@"Enter Your Detail" message:@"\n\n\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Register",nil];
txtEmail = [[UITextField alloc] initWithFrame:CGRectMake(30, 40, 220, 25)];
txtEmail.placeholder = @"email address";
txtFirstName = [[UITextField alloc] initWithFrame:CGRectMake(30, 70, 220, 25)];
txtFirstName.placeholder = @"first Name";
txtSurname = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 220, 25)];
txtSurname.placeholder = @"surname";
[myAlertView addSubview:txtEmail];
[myAlertView addSubview:txtFirstName];
[myAlertView addSubview:txtSurname];
[myAlertView show];
Run Code Online (Sandbox Code Playgroud)
在IOS 6中没问题,但在IOS 7中它没有显示UITextField
我有一个NSWindowController包含几个NSViewControllers.我想普遍接受使用NSWindowController类的拖放事件,而不是被其他视图拦截NSTextView(包含在a中NSViewController)
如何判断NSTextView忽略拖放事件?
drag-and-drop nstextview nsviewcontroller nswindowcontroller
ios ×3
objective-c ×2
orientation ×2
cifilter ×1
cikernel ×1
core-image ×1
fpdf ×1
fpdi ×1
github ×1
ios6 ×1
iphone ×1
markup ×1
mediawiki ×1
nstextview ×1
opencv ×1
pdf ×1
perspective ×1
php ×1