From Beginner to Server: A Programmer's Record of Vipassana in China

I used to think I had pretty good concentration—until I realized I couldn’t even focus on observing my own breath for a full minute.

A Seed Planted 13 Years Ago

Vipassana is a meditation technique with a history of over 2,500 years. Its core is simple: observe the sensations in your body as they truly are, without judgment or reaction—just watch them arise and pass away.

There are many types of meditation—some focus on the breath, some visualize images, some repeat a word silently. I’ve only studied Vipassana, so I can only speak from my own experience. Vipassana belongs to the “observation” category—it’s not just about calming the mind, but using that stillness to see how your mind actually works.

I first learned about Vipassana 13 years ago from a book called Pragmatic Thinking and Learning: Refactor Your Wetware. It mentioned meditation as a way to improve concentration, and I realized this might be the ultimate way to achieve focus and happiness. But back then, I felt I was still young—fresh out of school, with so much to do. “I’ll try it in a few years,” I told myself, planting a seed in my heart.

Over the years, I came across biographies and other materials, discovering that many people in Silicon Valley practice Vipassana or meditation—Steve Jobs, for example. I also dabbled in some meditation practices, but they never felt systematic enough, and I never had any breakthroughs.

Before I knew it, it was 2025. More and more things were competing for our attention, and I found it increasingly hard to focus. Life was getting busier—career development, children’s education, loans… There were always a few things hanging in my mind, making it hard to find peace, and I’d often feel inexplicably irritable. But now, I finally had large blocks of time to myself, so I wanted to find a place to learn more systematically. It wasn’t just about improving concentration; I also hoped to understand myself better through practice. I even wondered if I could achieve some kind of “great enlightenment,” like the characters in the Hong Kong and Taiwanese TV shows and movies I watched as a child, after a period of secluded practice.

I found the website https://ng.shandao8.com/ online and discovered that 10-day Vipassana courses are held in many places across the country. By entering a course code, such as “qd2026” for the Qingdao Vipassana Center’s 2026 courses, you can look up the full year’s schedule. Incredibly, the entire course is completely free—no commercial elements at all, including accommodations and meals. The construction of all Vipassana centers and the ongoing operation of the courses rely entirely on donations from old students. In this day and age, it’s amazing that such a group of people is doing this kind of public service—kudos to them. I gritted my teeth and signed up for a course at the Zhengzhou Xuanzhong Center. Why grit my teeth? I was still worried I wouldn’t be able to last the 10 days. Why Zhengzhou instead of a place closer to me, like Wuyishan? Because these courses are hard to get into, and Zhengzhou was the only place with availability at a suitable time. After registering, the Vipassana Center even contacted my immediate family to confirm they were aware of and agreed to my participation—only then was the registration complete.

I arrived in Zhengzhou the day before the course started, gave myself a pep talk, rested, and reported to the Vipassana Center the next day.

The Difficulty of the First Three Days

Here, we woke up at 4 a.m. and went to bed at 10 p.m. During practice, except for designated times to ask the assistant teacher for guidance, we had to observe noble silence—no discussions allowed.

The first three days of the course focused on observing the breath, concentrating all attention on the small area below the nostrils and above the upper lip to feel the breath. Teacher Goenka taught us: “Don’t control the breath, and don’t try to breathe in any special way. Just observe the present reality, whatever it is. When you inhale, simply be aware that the breath is coming in; when you exhale, simply be aware that the breath is going out. And when your mind wanders into memories or fantasies, just be aware: ‘My mind is not on the breath right now,’ and gently bring your attention back.” During practice, I realized that I thought I was the master of myself, but in the end, I couldn’t even focus on observing the breath going in and out of my nostrils for a full minute. I wasn’t the master of myself at all—my mind was far harder to control than I’d imagined, which was truly disheartening.

Besides the difficulty of concentration, in the early days, there was also the unbearable numbness in my legs. During each hour of sitting, I had to change my posture two or three times. On one of these days, one of the participants couldn’t take it anymore and quietly packed his bags and left. While I wasn’t about to leave, I did wonder if I could make it through.

Day Four: Seeing My Automatic Reactions

On the fourth day, the teacher began instructing us to observe sensations throughout the body, from head to toes and back again. What stands between us and the world is our body—we aren’t truly reacting to the outside world, but to the sensations in our own bodies. When a sensation is unpleasant, our reaction is “aversion”; when a sensation is pleasant, our reaction is “craving more.” I finally understood something: I used to think that whatever happened outside would naturally lead to my feelings. Just like a programmer writing code—it’s normal to feel frustrated when there’s a bug, or angry when requirements change again, right? But when I carefully observed my body, I realized there was an intermediate layer: my reaction to the sensations. Leg numbness was a signal, but “I can’t take it, I need to change my posture” was my body’s program. The teacher told us not to react immediately—just observe. I tried to endure it, just watching the leg numbness happening. One minute, two minutes… It didn’t get worse; it even began to fade.

At that moment, I suddenly realized: the suffering wasn’t the leg numbness itself—the suffering was my desperate reaction to make it go away.

We never realize that our minds have been running an automatic program for decades: avoid discomfort, cling to pleasure. I don’t even remember when these reactions formed, but they’ve been running in the background, consuming my energy, and I’d never stopped to look at them.

Vipassana was the first time I saw these automatic programs.

I didn’t experience any “great enlightenment” or out-of-body experiences. I simply saw, for the first time from an observer’s perspective, how my own mind works. And that was enough.


At a little past four in the morning, on the path leading to the Dhamma Hall, the sky was still not fully lit. In the distance stood the dragon-shaped peak of Xinzheng’s Ancestral Mountain, while the whole world seemed hushed, save for the sound of my own footsteps.

Master Goenka taught us that, in truth, there is no such thing as a “soul.” When we attentively perceive the present moment and regard all sensations in the body—whether pleasant or unpleasant—with equanimity, we realize that these sensations arise for a time, then fade away, and new sensations arise in turn. They come and go like this—this is impermanence. Through Vipassana, as we diligently observe these sensations, we gradually become “observers” of them, witnessing their rise and fall. We are no longer completely controlled by our feelings, becoming more rational and wise.

After the fourth day, I felt that I was making progress each day, and the time no longer seemed as difficult to endure as before. Throughout the rest of the course, no more fellow practitioners left—everyone remained steadfast and completed the entire journey.

Additionally, it was here that I discovered for the first time that vegetarian food could be so delicious—it even suited my palate better than meat. I didn’t feel any discomfort due to the vegetarian diet, perhaps because the kitchen servers (volunteers, who are often past students) worked entirely out of their own willingness, which allowed them to prepare more flavorful meals. On the last day, after the noble silence ended, I spoke with a past student, and it confirmed my thoughts: sometimes, when there aren’t enough servers and external hires are brought in to cook, the food doesn’t taste as good. He could even tell whether the food had been prepared by servers or not.

After completing the 10-day course, I found myself waking up naturally at 4 a.m. every day at home. I practiced one hour of Vipassana daily, and over six months, this practice brought greater inner peace, made it easier to concentrate, and enhanced the insight that comes from heightened awareness.

Six Months Later: Washing Dishes Is Also Practice

Six months later, I participated as a server in a Vipassana course held at the Hong Kong Vipassana Centre on Lantau Island, Hong Kong (https://www.dhamma.org/). Each day, I worked in the kitchen during the morning, noon, and evening shifts, and servers also had 5–6 hours of group meditation practice. The center had documented the tasks for each server role in detail. For example, which meals to prepare each day, the workflow for each dish, and even details like how to position a spice jar lid were illustrated with example pictures. As a result, servers could get started with almost no difficulty. Everyone in the kitchen helped one another—whenever someone needed assistance, others stepped in right away. After finishing their own tasks, servers proactively checked whether others had completed their work. The quality of the meals prepared by our server team was no less impressive than what I had experienced as a student at the Zhengzhou Xuanzhong Centre.

One day while washing dishes, I found myself entering a peculiar state.

First, I rinsed and scrubbed the bowls with water to remove any residue. Then, I applied a small amount of dish soap—just enough to coat the thin layer of grease. Finally, as I rinsed them again, I watched the suds slide away, leaving the bowls clean and sparkling. Throughout the entire process, my attention was entirely on the flow of water, the bubbles, and the tactile sensation of my fingers against the bowls. My mind didn’t wander.

At that moment, I was reminded of the ancient story of the butcher, Pao Ding—not because washing dishes is particularly profound, but because the state of focused attention was the same. What my hands were doing, my mind was fully immersed in—no distraction, no scattered thoughts. When I finished washing a stack of bowls, they were clean, and I felt a deep sense of fulfillment.


Vegetarian Lunch at the Hong Kong Vipassana Centre

Postscript

Thirteen years ago, while reading a programmer’s book, I planted a seed, thinking Vipassana was about improving focus. Thirteen years later, I’ve discovered that focus is merely a byproduct—the true reward is learning to coexist with one’s own mind: no longer being held hostage by automatic reactions that have been running for decades, no longer being pushed around by every unpleasant sensation.

If you, too, often struggle to concentrate and feel restless or unhappy, consider carving out 12 days (arrival on the first afternoon + 10 days of practice + departure on the morning of the 12th day) to observe that part of yourself you’ve never truly examined.

Compared to spending a great deal of time planning a trip in the external world—staying in hotels, enjoying buffets, checking off a few scenic spots, and then editing photos—this inward journey is far more valuable, and certainly more exhilarating, because the destination is your own mind.

从新生到法工:一个程序员的内观记录

我以为自己是个专注力还不错的人,直到发现连观察自己的呼吸都撑不过一分钟。

一颗种子埋了13年

内观(Vipassana),是一种有2500多年历史的禅修方法。它的核心很简单:如实观察自己身体的感受,不评判、不反应,只是看着它们升起又消失。

冥想的种类有很多,有的专注于呼吸,有的观想画面,有的重复默念一个词。我只是了解过内观,只有资格讲讲自己内观的经历,内观属于其中的”观”——不是让心静下来就完了,而是用这份安静去看清自己的心是怎么运作的。

13年前第一次知道内观,来自一本书:《程序员的思维修炼:开发认知潜能的九堂课》,里面提到了一种提升专注力的方式:冥想,通过这本书我认识到这可能是带来专注和快乐的终极方式。但那时觉得自己还年轻,作为从学校毕业不久的新人,还有好多事情要做,过几年再尝试吧,我在心中埋下了一颗种子。

后来陆续看过一些名人传记等书籍资料,发现硅谷也有很多人练习内观或者冥想,比如乔布斯。中间也零星尝试过一些冥想练习,但总觉得不够系统,没什么突破。

一晃到了2025年,越来越多东西在抢夺我们的注意力,我感觉自己越来越难以专注;生活中的事情也越来越多,职业发展、孩子教育、贷款……脑子里总有几件事悬着,静不下来,时不时就会莫名烦躁。而我也有了大块属于自己的时间,于是想找一个更系统学习的地方,不仅仅是为了提升自己的专注力,还希望通过练习,更好的认识自己,甚至想看看自己能不能像小时候看的港台电视或者电影中的人物一样,在闭关修炼一段时间后能有什么”大彻大悟”。

在网上找到了 https://ng.shandao8.com/ 这个网站,发现国内很多地方都有10日内观课程,输入课程代码,比如2026年青岛内观中心的课程,输入”qd2026”即可查到2026年全年的课程。而且整个课程不可思议的完全免费,不存在任何商业性质,包括食宿也不收取任何费用。所有内观中心的建设和课程的持续运营,全都是依靠旧生们的捐赠,在这个时代居然有这么一批人干着这种公益,为他们点赞。我咬咬牙报名了郑州悬钟中心的课程,为什么要咬牙呢,还是有些担心这10天的课程坚持不下去。为什么报名郑州而不是离我更近的武夷山等地方,是因为这个课程并不好抢,合适的时间只有郑州有名额。报名登记后内观中心还要和直系亲属联系,确认直系亲属知晓并同意才算是报名成功。

我在课程报到前一天到了郑州,再给自己做了做心理建设,休整后第二天去内观中心报到了。

前三天的难受

在这里每天4点钟起床,晚上10点睡觉,练习过程中除每日在指定时间能和助理老师请教修习,其他时间需要止语,不能讨论。

课程前3天练习观呼吸,把所有注意力集中在鼻孔下方上嘴唇一小块区域,感受呼吸。葛印卡老师教导我们:”别去控制呼吸,也不要想用什么特殊的方式呼吸。只要观察现在的状况,不管状况如何。吸气的时候,你只是意识到,这股气进来了;呼气的时候,你只是意识到,这股气出去了。而当你不再专注,思绪开始在回忆和幻想中游荡的时候,你只是意识到:现在我的思绪不在呼吸上了,把注意力转移回来即可。”练习中我发现,我自以为是自己的主人,最后却发现专心观察气息如何进出鼻孔都很难持续1分钟,自己根本算不上自己的主人,自己的心远比想象中更难掌控,这着实让我有点沮丧。

除了注意力难以集中外,前期还有脚麻无法忍受,每一小时的静坐大概要换2-3次姿势。在这一天也有一个大哥坚持不下去,收拾行李悄悄离开了,我虽然不至于离开,但也有些怀疑自己还能不能熬得过去。

第四天:看见自己的自动反应

到了第四天,老师开始教授观察全身的感觉,从头到脚,再从脚到头。我们和世界之间隔着的是我们的身体,我们真正反应的对象不是外界,而是自己身体的感觉。某种感觉不愉快,我们的反应就是”厌恶”;某种感觉愉快,我们的反应就是”想要更多”。我终于悟出点什么了,以前我以为,外界发生了什么,我就会有什么感受,这是天经地义的。就像程序员写代码,代码出bug就会感到烦躁,需求又改我就生气,这不是很正常吗?但当我认真观察身体时,发现中间还有一层:我对感受的反应。腿麻是一个信号,但”受不了、要换姿势”是我身体的程序。老师让我们不要立刻反应,就只是观察。我试着忍住,只是看着腿麻这件事正在发生。一分钟、两分钟……它居然没有变得更糟,甚至开始消退。

那一刻我突然意识到:痛苦不是腿麻本身,痛苦是我拼命想让它消失的那个反应。

我们从没意识到自己内心有一套运行了几十年的自动程序:不舒服就逃避,舒服就想抓住。这些反应什么时候形成的我都不记得了,但它们一直在后台跑,消耗着我的精力,而我从没停下来看一眼。

内观就是第一次让我看见了这些自动程序。

我没有”大彻大悟”,没有灵魂出窍,只是第一次以旁观者的视角,看见了自己的心是怎么运作的,这就够了。


图一:清晨四点多,走去法堂的路上,天还没亮透,远处是新郑始祖山上的龙头,整个世界安静得只剩下自己的脚步声。

葛印卡老师告诉我们,其实灵魂这东西也不存在。我们认真感知当下,平等地看待身体各种感受,愉悦的还是不愉悦的。这些感受来了一阵,然后消失,新的感受又升起,感受就这样来来去去,这就是无常。通过内观,当我们认真观察这些感受,就慢慢变成这些感受的”旁观者”,观察这些感受生起又灭去,我们不再被感受完全控制,变得更加理性和睿智。

过了第4天,感觉自己每天都有进步,日子也没前几天这么难熬,过程中再没有小伙伴离去,大家坚定地修完了全程。

另外在这里我第一次发现素食能这么好吃,居然比吃肉更合胃口,没有因为是素食而有任何不适应,可能是厨房的法工(即义工,旧生可报名)完全出于自愿的缘故,反而能做出更可口的饭菜。到最后一天结束止语后,我和一个旧生交流,印证了我的想法:有时法工不够雇佣外面的人做饭,反而饭菜不好吃,他甚至能吃出饭菜是否由法工做的。

10日课程修完之后,在家中每天4点钟居然就醒了,每天练习一小时内观,半年的内观使得我的内心更加平静,更容易集中注意力,也增强了觉知带来的洞察力。

半年后:洗碗也是修行

半年后,我作为法工参加了位于香港大屿山的香港内观中心(https://www.dhamma.org/) 举行的内观课程,每天早中晚在厨房工作,另外法工有5-6小时共修。中心已经把每个岗位法工要做的工作做成了文档,比如每一天哪一顿要做的饭菜、每道饭菜工作流程、细到怎么摆放一个调味瓶的杯盖都提供了示例图片,所以法工们上手几乎没什么成本。大家在厨房互帮互助,任何人需要协助马上就有人出来帮忙,干完自己工作后,还会主动去看别人任务是否完成,我们法工团队做出来的饭菜水准一点也不逊色于在郑州悬钟中心当新生时吃到的。

有一天洗碗的时候,我发现自己进入了一种奇特的状态。

先用水把碗冲洗和刷一遍,去掉残渣;再抹上洗洁精,因为只剩下薄薄一层油脂,用量很少就够了;最后冲水,看着泡沫滑落,碗面变得干净透亮。整个过程,我的注意力就在水流、泡沫、手指和碗的触感上,没有想别的。

那一刻我想起了庖丁解牛的故事——不是因为洗碗有多高深,而是那种专注的状态是一样的。手上在做什么,心就在什么上面,没有分神,没有杂念。洗完一摞碗,碗很干净,我也很满足。


图二:香港内观中心的素食午餐

晚上九点学员休息后,法工会和老师开个短会。在郑州做学生时要求课程全程止语,我和老师交流较少,但这几天近距离相处下来,我发现他们身上有一种很难形容的东西。女老师脸上常常带着孩子般的笑容,不是那种客套的微笑,是真的开心;男老师的笑容更沉静一些,充满了智慧。

他们修行了很多年,比大多数人都松弛、快乐。我想,这大概就是”真正的快乐”长什么样子吧。

10天的课程只是开了一个头,让你学会一种观察自己的方法。但这个方法不是只能盘腿坐着用的——洗碗时可以用,给老人孩子沟通时可以用,工作的时候也可以用,正所谓行走坐卧皆是禅。

佛陀对此有一个很简洁的说法:”当你看时,就只是看;当你听时,就只是听;当你嗅、尝、触时,就只是嗅、尝、触;当你认知时,就只是认知。”

听起来很简单,但大多数时候我们做一件事,脑子里还同时想着几件别的事。内观教会我的,不是什么玄妙的道理,就是怎么让那些杂念安静下来,把注意力真正放在手上这一件事。

做一个真正快乐专注的人,其实没有那么复杂。认真过好每一个当下,你就能过好这一生——因为这一生,本来就是由一个个当下组成的。

写在最后

13年前,我在一本程序员的书里埋下了一颗种子,以为内观是为了提升专注力。13年后我发现,专注力只是副产品,真正的收获是学会和自己心相处——不再被那些运行了几十年的自动反应绑架,不再被每一个不愉快的感受推着走。

如果你也常常注意力难以集中,感到焦躁不快乐,可以考虑找12天时间(第一天下午报到+10天练习+第12天早上离开),去观察一下那个你从未认真审视过的自己。比起花大量时间去规划外部世界的旅行,住酒店、吃自助、打卡几个景点然后修修图。

这趟内心的旅行更有价值,当然也更刺激——因为目的地是你自己的心。


AI开放平台集成API

说明

方法说明:

1.select():选择识别的方法,参数为url的路由
2.where():过滤条件,参数为请求的参数,同官方文档一致
3.get():触发API请求,返回结果

百度

代码示例:

  1. 人脸识别(image参数无需base64):
    1
    Entry::Baidu($config)->face->select('detect')->where(['image' => file_get_contents(__DIR__ . '/file/face_detect.jpeg'), 'id_card_side' => 'front'])->get();
  2. 通用文字识别(image参数无需base64):
    1
    Entry::Baidu($this->config)->ocr->select('general_basic')->where(['url' => 'http://aip.bdstatic.com/portal/dist/1513863228374/ai_images/technology/ocr-general/general/demo-card-2.jpg'])->get();
  3. 人体关键点识别(image参数无需base64):
    1
    Entry::Baidu($config)->body->select('analysis')->where(['image' => file_get_contents(__DIR__ . '/../../file/body1.jpg')])->get();
  4. 商品检索(image参数无需base64):
    1
    Entry::Baidu($this->config)->imageSearch->select('v1/realtime_search/product/search')->where(['image' => file_get_contents(__DIR__ . '/../../file/cup.jpg')])->get();

    官方文档:

百度AI开放平台

方法:

1.人脸识别(face
* detect:人脸检测
* match:人脸比对
* verify:人脸认证
* identify:人脸识别
* multi-identify:M:N 识别
* add:人脸库添加
* update:人脸库更新
* delete:人脸删除
* get:用户信息查询
* getlist:组列表查询
* getusers:组内用户列表查询
* adduser:组间复制用户
* deleteuser:组内删除用户

2.文字识别(ocr)
* idcard:身份证
* bankcard:银行卡
* general:通用文字识别(含位置信息版)
* general_basic:通用文字识别
* webimage:网络图片文字识别
* general_enhanced:通用文字识别
* driving_license:驾驶证识别
* vehicle_license:行驶证识别
* license_plate:车牌识别
* accurate:通用文字识别(含位置高精度版)
* accurate_basic:通用文字识别(高精度版)
* receipt:通用票据识别
* business_license:营业执照识别
3.人体识别(body)
* analysis:人体关键点识别
* attr:人体属性识别
* num:人流量统计
4.图片搜索(imageSearch)
* realtime_search/same_hq/add:相同图检索—入库
* realtime_search/same_hq/search:相同图检索—检索
* realtime_search/same_hq/delete:相同图检索—删除
* realtime_search/same_hq/update:相同图检索—更新
* v1/realtime_search/similar/add:相似图检索—入库
* v1/realtime_search/similar/search:相似图检索—检索
* v1/realtime_search/similar/delete:相似图检索—删除
* v1/realtime_search/similar/update:相似图检索—更新
* v1/realtime_search/product/add:商品—入库
* v1/realtime_search/product/search:商品—检索
* v1/realtime_search/product/delete:商品—删除
* v1/realtime_search/product/update:商品—更新

腾讯优图

代码示例:

  1. 人脸检测(where()方法可以传入url或者image)
    1
    Entry::Youtu($config)->face->select('detectface')->where(['image' => __DIR__ . '/../../file/face_01.jpg', 'mode' => 1])->get();
  2. 通用文字检测(where()方法可以传入url或者image)
    1
    Entry::Youtu($this->config)->ocr->select('generalocr')->where(['url' => 'http://open.youtu.qq.com/app/img/experience/char_general/ocr_common07.jpg'])->get();
  3. 图像处理(默认调用人脸融合API)
    1
    2
    3
    4
    $opData = [['cmd' => 'doFaceMerge', 'params' => ['model_id' => 'cf_wzry_zhugeImage']]];
    //$request = ['img_data' => __DIR__ . '/../../file/face_01.jpg', 'rsp_img_type' => "url", 'opdata' => $opdata];
    $params = ['img_data' => 'http://open.youtu.qq.com/app/img/experience/face_img/face_04.jpg', 'rsp_img_type' => "url", 'opdata' => $opData];
    $result = Entry::Youtu($config)->imageProcess->select()->where($params)->get();//人脸融合

    官方文档:

腾讯AI开放平台

方法:

1.人脸识别(face
* detectface:人脸检测
* faceshape:五官定位
* identify:人脸识别

2.文字识别(ocr)
* generalocr:通用
* idcardocr:身份证
* bcocr:名片
* bizlicenseocr:营业执照
* creditcardocr:银行卡
* plateocr:车牌识别
* driverlicenseocr:驾驶证(1)行驶证(0)识别
3.图像处理(imageProcess)
* pitu_open_access_for_youtu.fcg:人脸融合,默认参数,可以不填

FACE++

代码示例:

  1. 人脸识别(where()方法可以传入image_url,image_file,image_base64):
    1
    Entry::FacePlus($this->config)->face->select('detect')->where(['image_file' => __DIR__ . '/../../file/face_01.jpg', 'return_attributes' => 'skinstatus'])->get();
  2. 手势识别(where()方法可以传入image_url,image_file,image_base64):
    1
    Entry::FacePlus($config)->body->select('gesture')->where(['image_url' => 'http://open.youtu.qq.com/app/img/experience/face_img/face_06.jpg', 'return_attributes' => 'skinstatus'])->get();
  3. 驾驶证识别(where()方法可以传入image_url,image_file,image_base64):
    1
    Entry::FacePlus($this->config)->ocr->select('ocrdriverlicense')->where(['image_url' => 'http://open.youtu.qq.com/app/img/experience/char_general/ocr_jsz_01.jpg'])->get();
  4. 识别图片场景和图片主体(where()方法可以传入image_url,image_file,image_base64):
    1
    Entry::FacePlus($this->config)->image->select('detectsceneandobject')->where(['image_base64' => base64_encode(file_get_contents(__DIR__ . '/../../file/cup.jpg'))])->get();

官方文档:

FACE++AI开放平台

方法:

1.人脸识别(face
* detect:人脸检测和人脸分析
* compare:两个人脸进行比对
* search:在一个已有的 FaceSet 中找出与目标人脸最相似的一张或多张人脸
* create:创建一个人脸的集合 FaceSet
* addface:为一个已经创建的 FaceSet 添加人脸标识 face_token
* removeface:移除一个FaceSet中的某些或者全部face_token
* update:更新一个人脸集合的属性
* getdetail:获取一个 FaceSet 的所有信息
* delete:删除一个人脸集合
* getfacesets:获取某一 API Key 下的 FaceSet 列表及其 faceset_token、outer_id、display_name 和 tags 等信息
2.人体识别(body
* detect:人体检测和人体属性分析
* segment:识别传入图片中人体的完整轮廓,进行人形抠像
* gesture:手势识别
3.证件识别(ocr)
* ocridcard:身份证
* ocrdriverlicense:驾驶证
* ocrvehiclelicense:行驶证
* ocrbankcard:银行卡
4.图像识别(image)
* detectsceneandobject:图片分析,识别图片场景和图片主体
* recognizetext:图片分析,找出图片中出现的文字信息
* general:通用文字识别(含位置信息版)
* mergeface:人脸融合

JUST DO IT

随感:如果你有些想法,有没有去做比最后的结果更重要,也就是去实践这种想法比成功与否更重要,那这种想法就是值得去做的,你是幸福的。

这也让我想起了我大学时候的一个想法,让我一个行政管理的学生花费了2年多的时间,现在只剩下一个网址和截图了:http://app.weibo.com/detail/5a5etW?ref=appsearch

爱情信鸽

虽然没有成功,但是让我踏上了程序员之路,心里只有暗自庆幸。

从设计模式到代码架构

设计模式,这是我听过最糟糕的翻译,这个名字对于程序员来说有点高高在上,难以理解,尤其是php,python,nodejs这些脚本语言的开发人员可能因为这个名字就忽视了设计模式的重要性。当然,除了名字以外,从更深层次,更具体来说,我觉得有三个原因:

  1. 不用设计模式也可以完成工作,很多时候反而更简单快速;
  2. 软件的世界快速迭代,很多设计模式有些过时了;
  3. 如果没有理解透彻一些设计模式,可能还存在过度设计的问题,拿着把锤子,看到哪里都是钉子。

但是用所谓‘简单’的方法去写的代码,业务一复杂之后,你就会发现改动之痛苦,改一个功能要看完所有流程,最后不得不重构,相信很多人都会有这个经历,这些就是设计模式解决的问题,但是精通了设计模式并不能解决所有问题,常常也要重构,设计模式绝对不是银弹。

设计模式的本质是什么

设计模式其实就是架构,实现一个模块或者功能有几种方法,前面的人总结了他觉得最优的方法,然后抽象出来成为一种模式,这就是设计模式。本质上这和架构没有什么区别。

设计模式和架构的区别

那架构和设计模式有没有什么区别呢,其实是有区别的,某种程度上可以这样理解:架构是从整个系统,更宏观的层面来总结的,而现在大家理解的设计模式,更多是从代码层面出发,或者框架的层面来总结的。但是这种区别并不是软件架构大师们主观的结果,这两个概念最开始是一个东西,但是随着软件复杂度的不断增加,演化成了两个概念。

更好的理解设计模式

我觉得对于设计模式的理解是把设计模式归并到架构的一部分,是架构的子集,重命名为代码架构,这样好理解很多。

MVC从多层模型开始

如果你的控制层比模型层更大,产品同学找你改个功能很费劲,一改就来bug的时候,你可以考虑用多层模型解耦你的业务。

MVC功能定位

  1. 模型(Model)应当负责管理几乎所有涉及数据的事情,包含数据、业务逻辑,以及数据校验规则。
  2. 控制器(Controller)用来解释请求数据,使用相应的模型,并渲染相应的响应或视图,可以被看作是模型和视图之间的中间人处理动作和请求。
  3. Views包含用户界面元素,如文本、图片和表单,当然,现在流行前后端分离的架构中,这一层可能从后端同学那里剥离出去了。

数据和业务逻辑放在模型层,控制器只是个中间人的角色,这样就保持了瘦控制器和胖模型。但是实际开发中,很多同学会将数据的校验和业务逻辑放在控制器层,变成了胖控制器,瘦模型,控制层的代码没有复用性可言,产品需求一改,重构又要开始了。所以如果仅仅把模型当作数据库表的映射,一张数据库表对应一个模型是远远不够的。

分层次设计模型

  1. 多层模型的本质原因是由于数据库和业务逻辑之间的差异性,比如关系型数据库中的数据都是存在表中,以一行行数据的形式进行存取的,而程序运行却是一个个对象,实现数据的过滤,数据的处理等业务逻辑,一个对象的数据一般都对应了多张表。如果把业务处理逻辑和数据存取逻辑完全混杂在一块,甚至比把业务逻辑放在控制器里更难维护。
  2. 模型的层级:
    • 一层应该是每个模型映射一张数据表,比如一篇文章对应一个文章表,文章分类对应一个分类表,这里就是两个模型,想必大多数同学都是这样设计模型的,这里就不多说了,我这里把这个成为A层模型。
    • 一些可以复用的业务逻辑块可以封装成模型,供控制器或者模型调用,比如页面的搜索功能,可以继承最相关的A层模型,然后独立成模型,供不同页面都要这个查询功能的控制器调用。
    • 每个表单或者API需要独立的模型,这里面包含了这个表单或者API的数据校验和不可复用的业务逻辑,这个比较关键,也是本文的重点。比如注册表单或者API,需要独立的注册模型,这里面就包含了账号,验证码各种的校验,校验通过之后注册的逻辑,注册之后用户表需要添加一条数据,用户详情表也需要添加一条数据,这就对应了2个A模型,这些都只是注册特有的逻辑,独立出来做成单独的模型,这样业务修改需求主要修改这里,简单清晰。

后话

随着业务的发展,仅仅MVC这样的分层划分已经不能满足需求了,但更强大的架构本质都是抽象出更多的层级,毕竟计算机中的所有问题,都可以通过向上抽象封装一层来解决,这超过本文的讨论范围。