Skip to content

Instantly share code, notes, and snippets.

View codeOfRobin's full-sized avatar

Robin codeOfRobin

View GitHub Profile
import mechanize
import cookielib
from bs4 import BeautifulSoup
import re
import io
import sys
import csv
reload(sys)
sys.setdefaultencoding("utf8")
UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 330)];
[img setContentMode:UIViewContentModeScaleAspectFill];
[img setTag:2];
[img setImage:[UIImage imageNamed:@"sda"]];
UITableView *table=[[UITableView alloc]initWithFrame:CGRectMake(0, 80, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame))];
[self.view addSubview:table];
[table setDataSource:self];
[table setDelegate:self];
[table registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section==0) {
return 1;
}
else
{
return [self.data count];
}
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
UIImageView *img=(UIImageView *)[self.view viewWithTag:2];
CGFloat y=-scrollView.contentOffset.y;
if (y>0)
{
[img setFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame)+y*CGRectGetWidth(self.view.frame)/330,y+330 )];
[img setCenter:CGPointMake(self.view.center.x, img.center.y)];
}
- (cv::Mat)cvMatFromUIImage:(UIImage *)image
{
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);
CGFloat cols = image.size.width;
CGFloat rows = image.size.height;
cv::Mat cvMat(rows, cols, CV_8UC4); // 8 bits per component, 4 channels (color channels + alpha)
CGContextRef contextRef = CGBitmapContextCreate(cvMat.data, // Pointer to data
cols, // Width of bitmap
int threshold_value = 0;
int const max_BINARY_value = 2147483647;
cv::Mat src_gray=[self cvMatFromUIImage:img.image];
cv::Mat dst;
dst=src_gray;
cv::cvtColor(src_gray, dst, cv::COLOR_RGB2GRAY);
cv::Mat canny_output;
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
int const max_BINARY_value = 2147483647;
cv::Mat src_gray=[self cvMatFromUIImage:img.image];
cv::Mat dst;
dst=src_gray;
cv::cvtColor(src_gray, dst, cv::COLOR_RGB2GRAY);
int const max_BINARY_value = 2147483647;
cv::Mat src_gray=[self cvMatFromUIImage:img.image];
cv::Mat dst;
dst=src_gray;
cv::cvtColor(src_gray, dst, cv::COLOR_RGB2GRAY);
cv::Mat canny_output;
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
cv::RNG rng(12345);
brew install opencv3 --with-python3
echo /usr/local/opt/opencv3/lib/python3.4/site-packages >> /usr/local/lib/python3.4/site-packages/opencv3.pth
mkdir -p /Users/<insert your username here>/Library/Python/3.4/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python3.4/site-packages")' >> /Users/<insert your username here>/Library/Python/3.4/lib/python/site-packages/homebrew.pth
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
let img = getImageWithColor(colorToSet, CGSizeMake(100, 100))
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.navigationController?.navigationBar.setBackgroundImage(img,forBarMetrics: .Default)
self.pageIndicatorContainer.backgroundColor = colorToSet
})
})