我一直在使用NSDataDetector
解析字符串的地址,并且大部分它做得很好.然而,在地址'类似于这个地方它没有检测到它.
6200 North Evan Blvd Suit 487 Highland UT 84043
目前我正在使用此代码:
NSError *error = nil;
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeAddress error:&error];
NSArray *matches = [detector matchesInString:output options:0 range:NSMakeRange(0, [output length])];
for (NSTextCheckingResult *match in matches) {
if ([match resultType] == NSTextCheckingTypeAddress) {
_address = [_tesseractData substringWithRange:[match range]];
NSDictionary *data = [match addressComponents];
_zip = [data objectForKey:@"ZIP"];
if (_zip) {
NSRange zipRange = [_tesseractData rangeOfString:_zip];
if (zipRange.location != NSNotFound) {
[_tesseractData deleteCharactersInRange:zipRange];
}
}
_city = [data objectForKey:@"City"];
if …
Run Code Online (Sandbox Code Playgroud) 我目前有一种方法可以检测图像中的卡片,并且大多数情况下,当光线相当一致并且背景非常平静时,它可以工作.
这是我用来执行此操作的代码:
Mat img = inImg.clone();
outImg = Mat(inImg.size(), CV_8UC1);
inImg.copyTo(outImg);
Mat img_fullRes = img.clone();
pyrDown(img, img);
Mat imgGray;
cvtColor(img, imgGray, CV_RGB2GRAY);
outImg_gray = imgGray.clone();
// Find Edges //
Mat detectedEdges = imgGray.clone();
bilateralFilter(imgGray, detectedEdges, 0, 185, 3, 0);
Canny( detectedEdges, detectedEdges, 20, 65, 3 );
dilate(detectedEdges, detectedEdges, Mat::ones(3,3,CV_8UC1));
Mat cdst = img.clone();
vector<Vec4i> lines;
HoughLinesP(detectedEdges, lines, 1, CV_PI/180, 60, 50, 3 );
for( size_t i = 0; i < lines.size(); i++ )
{
Vec4i l = lines[i];
// For …
Run Code Online (Sandbox Code Playgroud) 我试图计算图像中文本的偏斜,以便我可以纠正它以获得最佳的OCR结果.
目前这是我正在使用的功能:
double compute_skew(Mat &img)
{
// Binarize
cv::threshold(img, img, 225, 255, cv::THRESH_BINARY);
// Invert colors
cv::bitwise_not(img, img);
cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 3));
cv::erode(img, img, element);
std::vector<cv::Point> points;
cv::Mat_<uchar>::iterator it = img.begin<uchar>();
cv::Mat_<uchar>::iterator end = img.end<uchar>();
for (; it != end; ++it)
if (*it)
points.push_back(it.pos());
cv::RotatedRect box = cv::minAreaRect(cv::Mat(points));
double angle = box.angle;
if (angle < -45.)
angle += 90.;
cv::Point2f vertices[4];
box.points(vertices);
for(int i = 0; i < 4; ++i)
cv::line(img, vertices[i], vertices[(i + 1) % 4], cv::Scalar(255, …
Run Code Online (Sandbox Code Playgroud) 下面的代码给我画了一个圆圈,如何修改现有代码来绘制三角形呢?
_colorDotLayer = [CALayer layer];
CGFloat width = self.bounds.size.width-6;
_colorDotLayer.bounds = CGRectMake(0, 0, width, width);
_colorDotLayer.allowsGroupOpacity = YES;
_colorDotLayer.backgroundColor = self.annotationColor.CGColor;
_colorDotLayer.cornerRadius = width/2;
_colorDotLayer.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
Run Code Online (Sandbox Code Playgroud) 我需要存储用户可以添加的数据,他们可以添加无限量.他们可以是NSStrings
或者UIImage
是.我查看了NSUserDefaults,但它似乎用于少量数据,如设置或首选项.
什么是存储用户信息的最佳/最安全的方式,以便当他们关闭应用程序时,它仍然在应用程序中.数据填充a UITableView
和a NSMutableArray
.
什么是最好的方法呢?
我正在尝试使用自定义图像,MKAnnotationView
当我使用以下代码时,我的注释上没有图像.我已经检查了调试,以确保图像正确加载到UIImage
.
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"String"];
if(!annotationView) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"String"];
UIButton *directionButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *directionIcon = [UIImage imageNamed:@"IconDirections"];
[directionButton setImage:directionIcon forState:UIControlStateNormal];
annotationView.rightCalloutAccessoryView = directionButton;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
return annotationView;
}
Run Code Online (Sandbox Code Playgroud) 我正在呈现一个加载屏幕,我不希望显示导航栏.所以我用
self.navigationController.navigationBar.hidden = true
这诀窍和隐藏导航栏.但是当我想要显示导航栏时,我想要将其设置为动画.
我尝试过使用此代码,但条形图没有出现.
self.navigationController.setNavigationBarHidden(false, animated: true)
运行上面的代码后,条形图仍然隐藏,如何显示/动画条形图?
我有这个代码,我正在质疑我是否需要使用捕获列表来引用self
弱.
现在我正在考虑getTextFileData
并且.main.async
是静态方法,因此,这不会导致保留周期.但是,我确实访问了该games
物业,有点不确定.
NPWebService.getTextFileData { (games, success) in
if success {
self.games = games
DispatchQueue.main.async {
self.updateUI()
}
}
}
Run Code Online (Sandbox Code Playgroud) 我试图放下一些代表公共汽车站的图钉,当我对图像进行广告时,它会改变图钉的位置.当我没有设置图像时,引脚会掉落在正确的位置.
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if annotation is StopAnnotation {
let identifier = "stopAnnotation"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
if pinView == nil {
//println("Pinview was nil")
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
pinView!.canShowCallout = true
pinView.image = UIImage(named: "stopIcon")
}
return pinView
}
return nil
}
Run Code Online (Sandbox Code Playgroud)
例子
我试图使用的图像:
谁能告诉我为什么这样做呢?我在这个应用程序的Obj-C版本中使用完全相同的图像,一切正常.
我在应用程序商店中发现了几个应用程序可以很好地复制长时间曝光,但我在文档中找不到任何引起我注意的内容。我注意到的一件事是,当您打开应用程序时,它会停止播放音乐,这让我认为这些应用程序正在拍摄视频并以某种方式组合这些图像并叠加它们。
有谁知道我如何使用它来做到这一点AVFoundation
?
ios ×7
objective-c ×5
swift ×3
c++ ×2
opencv ×2
avfoundation ×1
closures ×1
mkannotation ×1
skew ×1
uibutton ×1
uitableview ×1