最近很多小伙伴都在问自学Swift-三十天三十个Swift小项目和更新中...这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展10个开源PythonOpenCV小项目,YouTub
最近很多小伙伴都在问自学 Swift - 三十天三十个 Swift 小项目和更新中...这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展10 个开源 Python OpenCV 小项目,YouTube热门、android 小项目、android 小项目 demo2、bin巨专题一 简单搜索(更新中等相关知识,下面开始了哦!
本文目录一览:- 自学 Swift - 三十天三十个 Swift 小项目(更新中...)(swift简单小项目)
- 10 个开源 Python OpenCV 小项目,YouTube热门
- android 小项目
- android 小项目 demo2
- bin巨专题一 简单搜索(更新中
自学 Swift - 三十天三十个 Swift 小项目(更新中...)(swift简单小项目)
个人拖延症太严重,一直没好好学习Swift。受@Allen_朝辉启发,决定每天写个小项目来学习Swift。
项目代码同步更新到github:项目地址
Project 01 - SimpleStopWatch
1)简单的计时器
2)使用 Timer.scheduledTimer
3)开始,暂停,重置功能
Project 02 - CustomFont
1)自定义字体
2)项目中导入字体文件(注意:直接拖到项目中,Build Phases - copy Bundle Resources 肯没有自动包含,需要手动添加)
3)在info.plist中添加Fonts provided by application属性,添加字体
4)使用以下代码打印出字体名字
for family in UIFont.familyNames { print("font-family:",family) for font in UIFont.fontNames(forFamilyName: family) { print("font-name:",font) } }
Project 03 - PlayLocalVideo
1)播放本地视频
2)使用UITableView做个个视频列表
3)import AVKit 使用AVPlayerViewController播放视频
Project 04 - SnapChatMenu
1)模仿SnapChat样式
2)左右两个视图是UIImageView
3)相机使用AVFoundation框架
Project 05 - CarouselEffect
1)UICollectionView实现的卡片选择2)使用UIBlurEffect UIVisualEffectView 添加了模糊效果
10 个开源 Python OpenCV 小项目,YouTube热门
点击上方“小白学视觉”,选择加"星标"或“置顶”
重磅干货,第一时间送达
本文转自 | 新机器视觉
1. Drowsiness Detector 睡意检测
https://github.com/misbah4064/drowsinessDetector
2. Object Tracking 目标跟踪
https://github.com/misbah4064/object_tracking
3. Lane Detection 车道线检测
https://github.com/misbah4064/lane_detection
4. Face Landmark Detection 人脸特征点检测
https://github.com/misbah4064/faceLandmarks
模型文件:
https://github.com/davisking/dlib-models/blob/master/shape_predictor_68_face_landmarks.dat.bz2
5. Hand Pose Detection 手部姿态检测
https://github.com/misbah4064/hand_pose_detection
6. Yolo Object Detection and Tracking CPU端YOLO目标检测与跟踪
https://github.com/misbah4064/yolo_objectDetection_imagesCPU
7. License Plate Detection and Recognition 车牌检测与识别
https://github.com/misbah4064/licensePlateReader
8. Text Detection and Recognition 文本检测与识别
https://github.com/misbah4064/textDetection-Recognition
9. Background Removal and replace with video 视频背景去除与替换
https://github.com/misbah4064/backgroundRemoval
10. Car Detection 车辆检测
https://github.com/misbah4064/car_detector_haarcascades
交流群
欢迎加入公众号读者群一起和同行交流,目前有SLAM、三维视觉、传感器、自动驾驶、计算摄影、检测、分割、识别、医学影像、GAN、算法竞赛等微信群(以后会逐渐细分),请扫描下面微信号加群,备注:”昵称+学校/公司+研究方向“,例如:”张三 + 上海交大 + 视觉SLAM“。请按照格式备注,否则不予通过。添加成功后会根据研究方向邀请进入相关微信群。请勿在群内发送广告,否则会请出群,谢谢理解~
本文分享自微信公众号 - 小白学视觉(NoobCV)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。
android 小项目
LoginActivity:
package cn.thewee.gourmetmeal.staff;
import java.util.HashMap;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import cn.thewee.gourmetmeal.staff.logic.ImgDownloadLogic;
import cn.thewee.gourmetmeal.staff.logic.LoginLogic;
import cn.thewee.gourmetmeal.staff.util.Tools;
public class LoginActivity extends BaseActivity {
private static final String TAG = "LoginActivity";
EditText edt_username;
EditText edt_password;
Button btn_login;
// 登陆结果处理,用来接收登陆线程消息,进行 UI 操作
Handler login_handler = new Handler(){
@Override
public void handleMessage(Message msg) {
// 关闭进度条 Dialog
if(p_dialog.isShowing()){
p_dialog.dismiss();
}
// 如果登陆成功则进入 MainActivity,否则 toast 提示错误
switch(msg.what){
case WHAT_SUBMIT_COMPLETE:
if(msg.getData().getInt("code") == 200){
Intent i_loginSuccess = null;
if(edt_password.getText().toString().equals("888888")){
i_loginSuccess = new Intent(LoginActivity.this, AlterPasswordActivity.class);
}else{
i_loginSuccess = new Intent(LoginActivity.this, MainActivity.class);
}
i_loginSuccess.putExtra("username", edt_username.getText().toString());
startActivity(i_loginSuccess);
LoginActivity.this.finish();
}else{
Toast.makeText(LoginActivity.this, msg.getData().getString("msg"), Toast.LENGTH_SHORT).show();
}
break;
case WHAT_SUBMIT_FAILED:
Toast.makeText(LoginActivity.this, getString(R.string.net_timeout), Toast.LENGTH_SHORT).show();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 配置 Listener
setListener();
}
/**
* 控件变量初始化
*/
@Override
protected void initViews() {
this.setContentView(R.layout.login);
edt_username = (EditText) this.findViewById(R.id.edt_username);
edt_password = (EditText) this.findViewById(R.id.edt_password);
btn_login = (Button) this.findViewById(R.id.btn_login);
// 登陆进度条
p_dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
p_dialog.setMessage(getString(R.string.is_logining));
}
/**
* 配置 Listener
*/
private void setListener() {
// 登陆按钮监听器
btn_login.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// 检测文本框是否为空
if(edt_username.getText().length() == 0 || edt_password.getText().length() == 0){
Toast.makeText(LoginActivity.this,
getString(R.string.text_is_null), Toast.LENGTH_SHORT).show();
return;
}
// 检测网络是否可用,若不可用 Toast 提示
if(!Tools.netIsAvailable(getApplicationContext())){
Toast.makeText(LoginActivity.this,
getString(R.string.net_disable), Toast.LENGTH_SHORT).show();
return;
}
// 显示进度条
p_dialog.show();
// 开启登陆线程
LoginThread loginThread = new LoginThread();
loginThread.setDaemon(true);
loginThread.start();
}
});
}
// 登陆线程
class LoginThread extends Thread{
@Override
public void run() {
Message msg = login_handler.obtainMessage();
Bundle data = new Bundle();
// 获取登陆结果
LoginLogic loginLogic = new LoginLogic();
HashMap<String, Object> result = loginLogic.login(edt_username.getText().toString(),
edt_password.getText().toString());
// HashMap<String, Object> result = new HashMap<String, Object>();
// result.put("rt", "200");
// result.put ("rtmsg", "登陆成功");
if(result!=null){
msg.what = WHAT_SUBMIT_COMPLETE;
data.putInt("code", Integer.valueOf((String)result.get("rt")));
data.putString("msg", (String)result.get("rtmsg"));
msg.setData(data);
// 发送消息
login_handler.sendMessage(msg);
}else{
login_handler.sendEmptyMessage(WHAT_SUBMIT_FAILED);
}
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
new AlertDialog.Builder(LoginActivity.this)
.setIcon(R.drawable.ic_launcher)
.setTitle ("提示")
.setMessage ("确认退出?")
.setPositiveButton ("确定",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialoginterface, int i){
System.exit(1);
}
})
.setNeutralButton ("返回",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialoginterface, int i){
}
})
.show();
return super.onKeyDown(keyCode, event);
}
@Override
protected void getExtras() {
// TODO Auto-generated method stub
}
}
login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@drawable/menu_background" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="70dp"
android:layout_marginRight="70dp"
android:layout_marginTop="50dp"
android:paddingTop="30dp"
android:background="@drawable/login_bg" >
<TextView
android:id="@+id/loginnametextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:layout_marginLeft="65dp"
android:layout_toLeftOf="@+id/edtxt_login_pwd"
android:text="@string/username"
android:textColor="#000000"
android:textSize="20sp" >
</TextView>
<EditText
android:id="@+id/edt_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/loginnametextview"
android:layout_toRightOf="@+id/loginnametextview"
android:background="@drawable/input_bg"
android:hint="@string/username_hint"
android:singleLine="true"
android:text="login01" >
</EditText>
<TextView
android:id="@+id/loginpasswordtextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/edt_username"
android:layout_marginLeft="65dp"
android:layout_marginTop="15dp"
android:text="@string/password"
android:textColor="#000000"
android:textSize="20sp" >
</TextView>
<EditText
android:id="@+id/edt_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_marginLeft="10dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/loginpasswordtextview"
android:layout_toRightOf="@+id/loginpasswordtextview"
android:background="@drawable/input_bg"
android:inputType="textPassword"
android:hint="@string/password_hint"
android:text="999999" >
</EditText>
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/edt_password"
android:layout_marginTop="15dp"
android:layout_alignRight="@+id/edt_password"
android:background="@drawable/btn_login" >
</Button>
</RelativeLayout>
</RelativeLayout>
android 小项目 demo2
MainActivity:
package cn.thewee.gourmetmeal.staff;
import java.util.Timer;
import java.util.TimerTask;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
public class MainActivity extends BaseActivity {
Button btn_order;
Button btn_settleAccount;
Button btn_orderRate;
Button btn_increaseOrder;
Button btn_more;
String username;
/**
* 画廊
*/
/**=================Gallery===============*/
private Gallery pictureGallery = null ;
private int[] picture = {
R.drawable.gallery1,
R.drawable.gallery2,
R.drawable.gallery3,
R.drawable.gallery4,
R.drawable.gallery5,
R.drawable.gallery6,
};
private int index = 0 ;
/**=======================================*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
username = getIntent().getStringExtra("username");
// 初始化各按钮 Listener
setListener();
}
/**
* 初始化 View 变量
*/
@Override
protected void initViews() {
setContentView(R.layout.main);
pictureGallery = (Gallery)findViewById(R.id.gallery_main);
ImageAdapter adapter = new ImageAdapter(this);
this.pictureGallery.setAdapter(adapter);
Timer timer = new Timer();
timer.schedule(task, 2000, 2000);
btn_order = (Button) this.findViewById(R.id.btn_order);
btn_settleAccount = (Button) this.findViewById(R.id.btn_checkout);
btn_orderRate = (Button) this.findViewById(R.id.btn_orderSchedule);
btn_increaseOrder = (Button) this.findViewById(R.id.btn_increaseOrder);
btn_more = (Button) this.findViewById(R.id.btn_more);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
new AlertDialog.Builder(MainActivity.this)
.setIcon(R.drawable.ic_launcher)
.setTitle ("提示")
.setMessage ("确认退出?")
.setPositiveButton ("确定",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialoginterface, int i){
System.exit(1);
}
})
.setNeutralButton ("返回",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialoginterface, int i){
}
})
.show();
return super.onKeyDown(KeyEvent.KEYCODE_BACK, event);
}
/**
* 定时器
*/
private TimerTask task = new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what = 2 ;
index = pictureGallery.getSelectedItemPosition();
index ++ ;
handler.sendMessage(message);
}
};
/**
* Handler
*/
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 2:
pictureGallery.setSelection(index);
break;
default:
break;
}
}
};
/**
* 初始化各按钮 Listener
*/
private void setListener() {
OnBtnClickListener btn_listener = new OnBtnClickListener();
btn_order.setOnClickListener(btn_listener);
btn_settleAccount.setOnClickListener(btn_listener);
btn_orderRate.setOnClickListener(btn_listener);
btn_increaseOrder.setOnClickListener(btn_listener);
btn_more.setOnClickListener(btn_listener);
}
class OnBtnClickListener implements OnClickListener{
@Override
public void onClick(View v) {
Intent i_openAct = null;
switch(v.getId()){
case R.id.btn_order:// 点菜
i_openAct = new Intent(MainActivity.this, DishesMenuActivity.class);
i_openAct.putExtra("mode", MODE_SUBMIT_ORDER);
break;
case R.id.btn_checkout:// 结台
i_openAct = new Intent(MainActivity.this, OrderListActivity.class);
i_openAct.putExtra("mode", MODE_CHECKOUT);
break;
case R.id.btn_orderSchedule:// 订单进度
i_openAct = new Intent(MainActivity.this, OrderListActivity.class);
i_openAct.putExtra("mode", MODE_ORDER_SCHEDULE);
break;
case R.id.btn_increaseOrder:// 加单,先到 OrderList 中选择流水号,后转入 “点菜” 界面
i_openAct = new Intent(MainActivity.this, OrderListActivity.class);
i_openAct.putExtra("mode", MODE_ORDER_ADD);
break;
case R.id.btn_more:// 更多
i_openAct = new Intent(MainActivity.this, MoreActivity.class);
break;
}
if(i_openAct != null){
i_openAct.putExtra("username", username);
startActivity(i_openAct);
}
}
}
/**
* Gallery 适配器
* @author Administrator
*
*/
class ImageAdapter extends BaseAdapter{
private int GalleryItemBackground;
private Context context ;
public ImageAdapter(Context context ){
this.context = context ;
TypedArray typedArray = context.obtainStyledAttributes(R.styleable.Gallery);
GalleryItemBackground = typedArray.getResourceId(R.styleable.Gallery_android_galleryItemBackground, 0);
}
public int getCount() {
return Integer.MAX_VALUE;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(context);
imageView.setImageResource(picture[position % picture.length]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT, Gallery.LayoutParams.FILL_PARENT));
imageView.setBackgroundResource(GalleryItemBackground);
return imageView;
}
}
@Override
protected void getExtras() {
// TODO Auto-generated method stub
}
}
main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/menu_background"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp" >
<Gallery
android:id="@+id/gallery_main"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:gravity="center" >
<Button
android:id="@+id/btn_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/btn_choosedish" />
<Button
android:id="@+id/btn_checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/btn_checkout" />
<Button
android:id="@+id/btn_orderSchedule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/btn_order_schedule" />
<Button
android:id="@+id/btn_increaseOrder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/btn_add_order" />
<Button
android:id="@+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/btn_more" />
</LinearLayout>
<!--
<Button
android:id="@+id/btn_browseOrder"
android:text="查 单"
android:layout_margin="5dp"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_changeTable"
android:text="换 台"
android:layout_margin="5dp"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_mergeTable"
android:text="并 台"
android:layout_margin="5dp"
android:layout_weight="1"/>
-->
</LinearLayout>
bin巨专题一 简单搜索(更新中
A--棋盘问题
POJ-1321
链接: https://vjudge.net/problem/15202/origin
类似n皇后问题,需要注意的是dfs的边界问题(t在此处
思路:当前走到i/u行j列,判断该点是否可以放棋子,不可以就j++,可以就dfs(i + 1),对放的棋子数进行计数,若等于k则return,记得状态还原。
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 using namespace std; 6 const int N = 20; 7 8 int n,k,flag; 9 char g[N][N]; 10 bool row[N]; 11 12 void dfs(int u,int x){ 13 if(x == k) { 14 flag ++; 15 return; 16 } 17 18 for(int i = u; i < n ; i ++ ){ 19 for(int j = 0; j < n; j ++ ){ 20 if(g[i][j] != ‘.‘ && !row[j]){ 21 row[j] = true; 22 dfs(i + 1,x + 1); 23 row[j] = false; 24 } 25 } 26 } 27 return; 28 } 29 30 int main() 31 { 32 while(scanf("%d %d",&n,&k) != EOF){ 33 if(n ==-1 && k == -1) break; 34 flag = 0; 35 for(int y = 0; y < n; y ++ ) 36 for(int z = 0; z < n; z ++ ) 37 cin>>g[y][z]; 38 dfs(0,0); 39 printf("%d\n",flag); 40 } 41 return 0; 42 }