npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@faceunity/cnama

v0.1.2

Published

CNAMASDK addon of nodejs

Downloads

1

Readme

安装

在容器中进行安装前需要以下前置需求:

  1. 开发容器启动使用-v /usr/include/GL:/usr/include/GL-v /usr/include/X11:/usr/include/X11将宿主机的相关头文件挂载进容器内,部署容器经过CI后可以不需要宿主机头文件挂载
  2. 确认容器内的DISPLAY环境变量为:0,使用env | grep DISPLAY进行确认;
  3. 确认~/.Xauthority存在,如果不存在使用ln -s /root/auth/:0 /root/.Xauthority
  4. 确认宿主机的X服务正常,已执行xhost +允许所有用户链接X服务
  5. 容器内需执行过ulimit -c unlimited或添加该行至/etc/profile文件

开发环境容器启动:

#注意替换SSH端口号
sudo docker run --privileged -d --gpus all --pid=host -e CNAMA_GPU=true -v /var/run/lightdm/root/:/root/auth/ -v /tmp/.X11-unix:/tmp/.X11-unix -p xxxx:22 harbor.faceunity.com/cnama/base:gpu-1.1 sh -c "apt install ssh -y&&service ssh start&&sleep infinity"

生产环境容器启动:

#注意替换目标镜像
sudo docker run --privileged -d --gpus all --pid=host -v /var/run/lightdm/root/:/root/auth/ -v /tmp/.X11-unix:/tmp/.X11-unix xxxxx
# GPU环境需要在安装前设置环境变量CNAMA_GPU为true,初始GPU容器内部已经内置了该变量不需要主动设置
# 需要硬解码的话需要安装前设置环境变量HW_DECODE为true,默认为CPU软解
npm install cnama -S --registry=http://47.96.88.190:4873

# CPU环境需要在安装前设置环境变量CPU_LIBRARY_PREFIX路径,包含OSMesa和libGL等库,初始CPU容器内部已经内置了该变量不需要主动设置
npm install cnama -S --registry=http://47.96.88.190:4873

!!注意

目前本项目仅为CNAMASDK的API子集

使用

写图片

const {Setup,CreateItemFromPackage,BindItem,RenderBundles} = require('cnama');
const auth_pack = require("auth_pack.json").auth_pack;
Setup(Buffer.from(auth_pack));
const controller = CreateItemFromPackage(readFileSync(resolve(__dirname, '../assets/controller_cpp.bundle')));
const avatar = CreateItemFromPackage(readFileSync(resolve(__dirname, '../assets/STA_avatar_kt_def_book.bundle')));
const controller_config = CreateItemFromPackage(readFileSync(resolve(__dirname, '../assets/controller_config.bundle')));
BindItem(controller, controller_config);
BindItem(controller, avatar);
const frame = RenderBundles(1920, 1080, new Int32Array([controller]), {
            p_translation: Buffer.from([0, 0, 350]),
            p_rotation: Buffer.from([0, 0, 0, 1]),
            pupil_pos: Buffer.from([0, 0, 0]),
            p_expression: Buffer.from(new Array(57).fill(0)),
            rotation_mode: Buffer.from([0]),
            is_valid: 1,
        });
frame.write("./out.png");

写视频

const {Setup,CreateItemFromPackage,BindItem,RenderBundles,VideoWriter} = require('cnama');
const auth_pack = require("auth_pack.json").auth_pack;
Setup(Buffer.from(auth_pack));
const controller = CreateItemFromPackage(readFileSync(resolve(__dirname, '../assets/controller_cpp.bundle')));
const avatar = CreateItemFromPackage(readFileSync(resolve(__dirname, '../assets/STA_avatar_kt_def_book.bundle')));
const controller_config = CreateItemFromPackage(readFileSync(resolve(__dirname, '../assets/controller_config.bundle')));
BindItem(controller, controller_config);
BindItem(controller, avatar);

const videowriter = new VideoWriter("out.mp4",{ fps:25,width:1920,height:1080 });

for(let i=0;i<100;i++){
    const frame = RenderBundles(1920, 1080, new Int32Array([controller]), {
            p_translation: Buffer.from([0, 0, 350]),
            p_rotation: Buffer.from([0, 0, 0, 1]),
            pupil_pos: Buffer.from([0, 0, 0]),
            p_expression: Buffer.from(new Array(57).fill(0)),
            rotation_mode: Buffer.from([0]),
            is_valid: 1,
        });
    videowriter.write(frame);   
}

videowriter.release();