我试图从静止图像中获取角点GPUImageHarrisCornerDetectionFilter.
我查看了项目中的示例代码,我查看了文档,我看过这篇文章大致相同的事情: 现有UIImage上的GPUImage Harris Corner Detection提供黑屏输出
但我无法让它发挥作用 - 我很难理解这应该如何与静止图像一起使用.
我现在所拥有的是:
func harrisCorners() -> [CGPoint] {
var points = [CGPoint]()
let stillImageSource: GPUImagePicture = GPUImagePicture(image: self.image)
let filter = GPUImageHarrisCornerDetectionFilter()
filter.cornersDetectedBlock = { (cornerArray:UnsafeMutablePointer<GLfloat>, cornersDetected:UInt, frameTime:CMTime) in
for index in 0..<Int(cornersDetected) {
points.append(CGPoint(x:CGFloat(cornerArray[index * 2]), y:CGFloat(cornerArray[(index * 2) + 1])))
}
}
filter.forceProcessingAtSize(self.image.size)
stillImageSource.addTarget(filter)
stillImageSource.processImage()
return points
}
Run Code Online (Sandbox Code Playgroud)
此函数总是返回,[]因此它显然不起作用.
一个有趣的细节 - 我从GPUImage示例中编译了FilterShowcaseSwift项目,并且过滤器无法找到非常清晰的角落,就像在黑色背景上的一张纸上一样.
我正在尝试创建一个正则表达式来匹配一个持有MySQL时间戳格式的日期的字符串,例如"2012-07-16 02:04:33".
它并不像听起来那么容易,例如你不应该在2月30日结束.
我知道有更简单的方法可以做到这一点,但我依赖于能够传递字符串和正则表达式来评估该字符串.
我很乐意提出任何建议.
djangoproject.com上的Django教程给出了这样的模型:
import datetime
from django.utils import timezone
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length = 200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_recently(self):
now = timezone.now()
return now - datetime.timedelta(days = 1) <= self.pub_date < now
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length = 200)
votes = models.IntegerField(default = 0)
def __unicode__(self):
return self.choice_text
Run Code Online (Sandbox Code Playgroud)
Choice使用ForeignKey,这是一种多对一的关系,所以我应该能够使用一个选择进行多个轮询.如果我尝试从夹具中加载它,如下所示:
[
{
"model": "polls.Poll",
"pk": 3,
"fields": { …Run Code Online (Sandbox Code Playgroud) 我正在使用Blueimp fileupload()将图像文件发布到django-tastypie API.
在上传文件时,以下代码可正常工作:
$("#image").fileupload({
dataType: 'json',
start: function() {
console.log("start fileupload");
},
progress: function(e, data) {
console.log(data.loaded + " " + data.total);
},
beforeSend: function(xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken'));
},
done: function(e, data) {
console.log("done uploading file.");
}
});
$("#image").bind('fileuploadfinished', function (e, data) {
console.log("fileuploadfinished");
});
Run Code Online (Sandbox Code Playgroud)
但是,done永远不会调用回调.我尝试绑定fileuploadfinished,也从未调用过.
start并且progress都按预期调用.
beforeSend没有文档,但django-tastypie需要SessionAuthentication- 删除它不会改变它done,fileuploadfinished也永远不会被调用.
当多个 Markdown 文件中的任何一个发生更改时,我正在尝试使用 Makefile 来编译 PDF:
# Compile report
source := draft
output := dist
sources := $(wildcard $(source)/*.md)
objects := $(patsubst %.md,%.pdf,$(subst$(source),$(output),$(sources)))
all: $(objects)
report-print.md: $(source)/%.md
cat draft/*.md | pandoc \
--variable geometry:a4paper \
--number-sections \
--toc \
--f markdown \
-s \
-o dist/report-print.pdf \
.PHONY : clean
clean:
rm -f $(output)/*.pdf
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
make: *** No rule to make target `dist/01-title.pdf', needed by `all'. Stop.
Run Code Online (Sandbox Code Playgroud)
该文件draft/01-title.md是源文件之一。
我试图在UIView中显示相机的输入.后来我需要能够分析视频帧,所以我需要使用AVFoundation这样做,据我所知.
到目前为止我所拥有的:
import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var camView: UIView!
var captureSession:AVCaptureSession?
var videoPreviewLayer:AVCaptureVideoPreviewLayer?
var videoCaptureDevice: AVCaptureDevice?
var input: AnyObject?
override func viewDidLoad() {
super.viewDidLoad()
videoCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
do {
input = try AVCaptureDeviceInput(device: videoCaptureDevice)
} catch {
print("video device error")
}
captureSession = AVCaptureSession()
captureSession?.addInput(input as! AVCaptureInput)
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
videoPreviewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
videoPreviewLayer?.frame = camView.layer.bounds
captureSession?.startRunning()
}
}
Run Code Online (Sandbox Code Playgroud)
这camView是可见的,但它没有显示任何内容.
该应用程序要求获得首次使用相机的许可,并已获得该许可.
设置断点和检查captureSession,videoPreviewLayer,videoCaptureDevice并input证实他们都被设定.