Forwarded from See you at @fishing_daily ! | (Archived) YuutaW 的版聊频道 (台长)
Media is too big
VIEW IN TELEGRAM
完成了!
使用纯 Java 实现(视频解码和音频不是自己写的)
视频由于性能原因进行了压缩
视频由于性能原因会稍有一秒左右落后
音频是程序放的,不是后期加的
手持手机拍摄,质量不佳见谅
别骂了,我知道这很简单。
源码 https://gist.github.com/Trumeet/fd4e93d69d78dc4ac14d5cac42dfff7e
使用纯 Java 实现(视频解码和音频不是自己写的)
视频由于性能原因进行了压缩
视频由于性能原因会稍有一秒左右落后
音频是程序放的,不是后期加的
手持手机拍摄,质量不佳见谅
别骂了,我知道这很简单。
源码 https://gist.github.com/Trumeet/fd4e93d69d78dc4ac14d5cac42dfff7e
duangsuse::Echo
#Cplusplus #CV 🤔 讲真,我真的不喜欢 OpenCV 的动态属性,它把本来可以轻易自动补齐的东西变成了还要查会文档、本来可以更强类型的东西做成了一堆 int 不仅使用动态属性,还不对常见 prop (比如 fps, position) 做些辅助属性…… In [1]: from cv2 import CAP_PROP_POS_MSEC CAP_PROP_POS_AVI_RATIO CAP_PROP_POS_FRAMES CAP_PROP_POS_MSEC OpenCV…
之前记下的 API 都是什么情况…… 要完成这些,我必须得到按 行/字 迭代每帧像素的方法
https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html 找到官方文档了(话说一般 CV 都是 #Python 写应用……
https://docs.opencv.org/4.5.0/d3/d63/classcv_1_1Mat.html 还有这个,单帧图像接口
看了半天找到
相关链接:
[Linux Terminal has the capability of displaying 8-bit colour, so why not play something on it?](https://gist.github.com/Trumeet/fd4e93d69d78dc4ac14d5cac42dfff7e)
[OpenCV - Colored Images to GrayScale - Tutorialspoint](https://www.tutorialspoint.com/opencv/opencv_colored_images_to_grayscale.htm)
[OpenCV: cv::VideoCapture Class Reference](https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html)
[Tutorial 6 - Assessing the pixel values of an image OpenCv C++ | ProgTpoint](https://progtpoint.blogspot.com/2017/02/tutorial-6-assessing-pixel-values-of.html)
[duangsuse-valid-projects/Essay-DIP-BMP-SIMD-Operation: C11 BMP Image Reading / Writing, SIMD using GCC xmminstric.h operations like AND / XOR / Dense](https://github.com/duangsuse-valid-projects/Essay-DIP-BMP-SIMD-Operation#my-machine)
[duangsuse-valid-projects/Essay-CSharp-DIP.Performance.Parallel: 🐔 versus 👨🏻🎓: WHO is faster? Is CSharp "slow"?](https://github.com/duangsuse-valid-projects/Essay-CSharp-DIP.Performance.Parallel/)
https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html 找到官方文档了(话说一般 CV 都是 #Python 写应用……
https://docs.opencv.org/4.5.0/d3/d63/classcv_1_1Mat.html 还有这个,单帧图像接口
看了半天找到
opencv2/videoio.hpp, highgui/highgui.hpp 和 imread/imwrite, empty, cvNamedWindow,waitKey, CV_WINDOW_AUTOSIZE, imshow, VideoCapture, read, operator>>, Mat ,channels, at, Scalar,uchar,Vec3b,val[] 这样的符号 #cplusplus #api #doc 🤔Mat img(/*.rows*/1920, /*.cols*/1080, CV_8UC3);好了,找到了 Video 的 nextImage 和 Image 的 n[row/col], pixelAt 操作我就可以写了……
typedef cv::Point3_<uint8_t> Pixel;
for (int i=0; i<img.rows; i++) { // raw access
Pixel *p = image.ptr<Pixel>(i, 0), *p1 = p + image.cols;
for (; p!=p1; p++) { *p.x = 255; }
}
for (Pixel &p : cv::Mat_<Pixel>(img)) { p.x = 255; } // mat iter
img.forEach<Pixel>([](Pixel &pixel, const int* position) { p.x = 255; }); // parallel forEach
//C++11 lambda, old:
struct Operator { operator()/*^above*/ }
相关链接:
[Linux Terminal has the capability of displaying 8-bit colour, so why not play something on it?](https://gist.github.com/Trumeet/fd4e93d69d78dc4ac14d5cac42dfff7e)
[OpenCV - Colored Images to GrayScale - Tutorialspoint](https://www.tutorialspoint.com/opencv/opencv_colored_images_to_grayscale.htm)
[OpenCV: cv::VideoCapture Class Reference](https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html)
[Tutorial 6 - Assessing the pixel values of an image OpenCv C++ | ProgTpoint](https://progtpoint.blogspot.com/2017/02/tutorial-6-assessing-pixel-values-of.html)
[duangsuse-valid-projects/Essay-DIP-BMP-SIMD-Operation: C11 BMP Image Reading / Writing, SIMD using GCC xmminstric.h operations like AND / XOR / Dense](https://github.com/duangsuse-valid-projects/Essay-DIP-BMP-SIMD-Operation#my-machine)
[duangsuse-valid-projects/Essay-CSharp-DIP.Performance.Parallel: 🐔 versus 👨🏻🎓: WHO is faster? Is CSharp "slow"?](https://github.com/duangsuse-valid-projects/Essay-CSharp-DIP.Performance.Parallel/)
Gist
Linux Terminal has the capability of displaying 8-bit colour, so why not play something on it?
Linux Terminal has the capability of displaying 8-bit colour, so why not play something on it? - JPlayer.java
duangsuse::Echo
之前记下的 API 都是什么情况…… 要完成这些,我必须得到按 行/字 迭代每帧像素的方法 https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html 找到官方文档了(话说一般 CV 都是 #Python 写应用…… https://docs.opencv.org/4.5.0/d3/d63/classcv_1_1Mat.html 还有这个,单帧图像接口 看了半天找到 opencv2/videoio.hpp, highgui/highgui.hpp…
int sizes[] = { 255, 255, 255 };
typedef cv::Point3_<uint8_t> Pixel;
Mat_<Pixel> image = Mat::zeros(3, sizes, CV_8UC3);
image.forEach<Pixel>([&](Pixel& pixel, const int position[]) -> void {
pixel.x = position[0];
pixel.y = position[1];
pixel.z = position[2];
}); emmm... 3D 矩阵
See you at @fishing_daily ! | (Archived) YuutaW 的版聊频道
完成了! 使用纯 Java 实现(视频解码和音频不是自己写的) 视频由于性能原因进行了压缩 视频由于性能原因会稍有一秒左右落后 音频是程序放的,不是后期加的 手持手机拍摄,质量不佳见谅 别骂了,我知道这很简单。 源码 https://gist.github.com/Trumeet/fd4e93d69d78dc4ac14d5cac42dfff7e
经甚的工笔画,描绘出来啦;算法就懒得讲了,区别在于 (1)没有用
https://paste.ubuntu.com/p/tZqTRNgNRm/
javax.audio 所以无声音输出 (2)ANSI 没有指定 xy 而是用换行符https://paste.ubuntu.com/p/tZqTRNgNRm/
asciiv.cpp
2.1 KB
Screenshot_20210116_153204.png
283.5 KB
./a.out '[file]'Geo: [379 x 104]
[ INFO:0] VIDEOIO: Enabled backends(6, sorted by priority): GSTREAMER(1000); V4L2(990); OPENNI(980); CV_IMAGES(970); CV_MJPEG(960); FIREWIRE(950)
[ INFO:0] OpenCV | GStreamer: /home/DuangSUSE/下载/Telegram Desktop/video_2021-01-16_14-23-05.mp4
[ INFO:0] OpenCV | GStreamer: mode - FILE
[ WARN:0] OpenCV | GStreamer warning: unable to query duration of stream
[ WARN:0] OpenCV | GStreamer warning: Cannot query video position: status=1, value=0, duration=-1
mvn.py
1.1 KB
#Python #tools #cli #code #Java #Maven
开发过程中处理
为了解决这个问题,我尝试用函数式 cps (编程风格,就是不 return 而带 callback)结果发现很难提供——首先 callsite 也必须提供 [op() for ...] 的上下文,Py 里这个改动是侵入式的,不能隐式传参,其次那必须要
后来提出先
from lxml import builder, etree
def gavTo(e, g,a,v): [e.append(builder.E(t, s)) for t,s in {"groupId":g, "artifactId":a, "version":v}]
root = builder.E("project", builder.E("modelVersion", "4.0.0"))
root.append(builder.E("build", listE("plugin", gavTo, [("org.apache.maven.plugins", "maven-compiler-plugin", "3.1")] ) ))
root.append(listE("dependency", gavTo, [f"org.jcodec:{s}:0.2.3" for s in "jcodec", "jcodec-javase"]))
gavTo(root, "trumeet","asciiart","1.0-SNAPSHOT")
print(etree.tostring(root)) ...https://paste.ubuntu.com/p/K29vXcjY87/开发过程中处理
org.jcodec:-,--javase:0.2.3 这种转换时我咧嘴了——在 gavTo 发现要展开简写时,listE 无法提供重新 add 的方法,因为它是面向 ops.forEach { it(data) } 的映射!为了解决这个问题,我尝试用函数式 cps (编程风格,就是不 return 而带 callback)结果发现很难提供——首先 callsite 也必须提供 [op() for ...] 的上下文,Py 里这个改动是侵入式的,不能隐式传参,其次那必须要
def 里另起一行 后来提出先
gavSplit 再 flatten (Py 不能 flatMap 但有对 map(f,xs) 参数的 starmap... 兼容不到我这面),包括结构的类型都很完美。
duangsuse::Echo
mvn.py
Screenshot_20210116_172723.png
39.7 KB
mvn.py trumeet:asciiart:1.0-SNAPSHOT org.jcodec:-,--javase:0.2.3|diff pom.xml - 最讨厌冗余代码了,辣鸡数据结构不该手写
duangsuse::Echo
mvn.py
刚才说完这个我突然想到关于这个 CPS(continuation-passing-style) 的一点不对…… #functional
看起来要么然之前在那篇文章上看的说法是错的,要么然 CPS 是一个类
刚才说的
程序可组合性的关键点在于,
如果不知道 return-side 的 type (接收什么变量),就是说这种 cps 式编程,必须显式定义回转方类型,或类型不安全(形式参数列表意义--)
看来只有 yield/resume continuation 是好的(
不对啊, CPS 哪里来的 forEach 😂?看来我还不够了解真正纯的函数式……
看起来要么然之前在那篇文章上看的说法是错的,要么然 CPS 是一个类
longjmp() 的控制流概念,不是函数式概念刚才说的
listE("item", ) = <items>$=<item> op($)</items> 是这样定义的(#Python 的压行技巧,不过之前说的 walrud operator 发现根本不能用):def listE(tag, op, xs): e = E(tag+"s" if tag[-1]!='y' else tag[:-1]+"ies"); [lets(E(tag), lambda ee: op(ee,x), e.append) for x in xs]; return e如果
lets(E(tag), lambda ee: op(ee,x), e.append)是 cps call-site ,那交给 callee 调用前的 continuation 应该是从 lets() 的头部(?)
程序可组合性的关键点在于,
op “返回”后要能覆盖 x 才能算够用,但此例 op 也得能覆盖(而且要实现仅改 gavTo(e,coord) 的“单至多项展开”,这还远远不够吧)如果不知道 return-side 的 type (接收什么变量),就是说这种 cps 式编程,必须显式定义回转方类型,或类型不安全(形式参数列表意义--)
看来只有 yield/resume continuation 是好的(
不对啊, CPS 哪里来的 forEach 😂?看来我还不够了解真正纯的函数式……
Telegram
duangsuse::Echo
https://epsil.github.io/gll/#continuation-passing-style-section
#FP #scheme #parser 想了解 continuation-passing-style (没有 return 如何编程?)的大佬们可以看看这人的文章,我觉得相当好。实用性,王垠那几十行代码不就是 CPS 优化吗。
照例个人观点:
0. 上文定义了 success/failure 的 union ,以及 (successed val rest) failure ,还有添加回调的…
#FP #scheme #parser 想了解 continuation-passing-style (没有 return 如何编程?)的大佬们可以看看这人的文章,我觉得相当好。实用性,王垠那几十行代码不就是 CPS 优化吗。
照例个人观点:
0. 上文定义了 success/failure 的 union ,以及 (successed val rest) failure ,还有添加回调的…
pom.xml
934 B
目标是生成一个兼容这个的POM文件(别喷为什么不用Gradle,我只管理依赖懒得被开daemon),16 行感觉还是太多了(吐嘈:结果文件是30行+啊),我本来是想复制粘贴两三行代码就可以创建项目的(虽然不知意义何在),看来还是 LiteratePy 的 way 正确一些,尽量少些模板化“代码”,共用一个项目生成工具是必须的(
当然不会像某些J2EE程序员一样弱智到随地XML),只有重视代码复用才能看到代码的许多其它用途和价值。其实可能只是习惯性提取出几个参数,再加上几个本来能省去的参数而已,整个程序员的走向却会大有不同…… 🤔
root = proj(argv[1], argv[2:])$
mvn.py trumeet:asciiart:1.0-SNAPSHOT org.jcodec:-,--javase:0.2.3>pom.xml
感觉自己的编程习惯就有一点好,非常重视可配置性(Screenshot_20210116_201051.png
122.9 KB
https://www.simplexacode.ch/en/blog/2018/08/the-problem-with-creating-generic-arrays/
https://softwareengineering.stackexchange.com/questions/257257/suppresswarnings-in-generic-array-declaration
#recommended #java #types #dev
https://softwareengineering.stackexchange.com/questions/257257/suppresswarnings-in-generic-array-declaration
#recommended #java #types #dev
Software Engineering Stack Exchange
@SuppressWarnings in generic array declaration
While doing a coding test, I ran into a problem where I need to initialize an array of generic type in Java. While trying to figure out how to do that, I looked at this Stack Overflow question and it
Screenshot_20210116_212315.png
219 KB
#Java 为什么啊…… 比 Yuuta 还多一行,而且看起来贼乱,明明我有很认真做简化功课了的说……
有的时候真的羡慕 Yuuta 那样的开发者,即便是很麻烦的工作,也能用很简单短篇的代码实现,哪怕会有一大堆类似的行居然也会比我的短
像我要省行数,总是在可读性或算法与面向对象模式上极限1换1……
是应该改一下套路,之前习惯的是有语义区别可以不换行不空格,究竟是 Java 该换的肯定要换,不换的话没有眼力看啦……
像我要省行数,总是在可读性或算法与面向对象模式上极限1换1……
是应该改一下套路,之前习惯的是有语义区别可以不换行不空格,究竟是 Java 该换的肯定要换,不换的话没有眼力看啦……
for (String fp : args) u.tryRun(() -> play(new File(fp)), fp); 🌚 我脑子瓦特了写了这么个函数(() -> 内仍需 checked exception...)方法引用中抛出的类型java.io.IOException不兼容 啊啊啊啊啊 🌝我就不该觉得 Java 会不检查,比民政局管得宽……
世 界 级 检 查
满 贯 类 型 安 全