Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #121341
| From | wij <wyniijj5@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: libwy-0.69.4 is released |
| Date | 2024-12-30 21:41 +0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <f654d47103ee2fb56f04aeea4873eae63e1b0572.camel@gmail.com> (permalink) |
| References | <ea4d8394c90783a3c756e9ecc6e5a87991a553bc.camel@gmail.com> |
On Mon, 2024-12-30 at 21:37 +0800, wij wrote:
> With the support of Packet Based Protocol in this version, I think the function
> of c++std library is no way to catch up (it relates to 'process', graphics and
> file format, just function side). https://sourceforge.net/projects/cscall/
>
> Take the 'graphics' for example, "Small is beauty":
>
> ------- manpage of namespace Face
> Wy(3wy) Wy(3wy)
>
> NAME
> Face - namespace of utilities based on Packet-Based communication Proto‐
> col
>
> SYNOPSIS
> Except POD types, C structures, particularly marked, all types are de‐
> clared in namespace Wy.
>
> #include <CSCall/Face.h>
>
> Namespace Face provides basic utilities for the implement of PBP
> (Packet-based communication Protocol), particularly for graphics capa‐
> bilities (but, it actually does more than graphics). For full GUI, ap‐
> plications just need to define their own 'GUI language' between
> processes.
>
> namespace Face {
> constexpr WeeStr RGB32("RGB32")
> typedef Vect<unsigned char,4> RGB32_Pixel
> constexpr RGB32_Pixel RGB32_White
> constexpr RGB32_Pixel RGB32_Blue
> constexpr RGB32_Pixel RGB32_Green
> constexpr RGB32_Pixel RGB32_Red
> constexpr RGB32_Pixel RGB32_Black
>
> constexpr unsigned int LeftButton
> constexpr unsigned int MiddleButton
> constexpr unsigned int RightButton
>
> constexpr size_t HeadPktSize=16
> char* write_headpkt(char*, size_t)
> const char* getsize_from_headpkt(const char*, size_t&)
>
> String mkpkt_RS(size_t, int, int, WeeStr)
> String mkpkt_MO(size_t, WeeStr, int, int, unsigned int)
>
> class Receiver (ref. Face.Receiver(3wy))
>
> Errno put_image(ByteFlow&, const Hdr2D<const RGB32_Pixel>&)
> Errno put_image(ByteFlow&, const RGB32_Pixel*, unsigned int, unsigned
> int) };
>
> ---- [cut]
>
>
A short example for video display (webcam, maybe):
/* Copyright is licensed by GNU LGPL, see file COPYING. by I.J.Wang 2010
Get and display image frames from v4l2 device (webcam...)
Build: make q_v4l2
Note: If error message says "No space left on device"(ENOSPC), try plug to
different USB port (it is probably the bandwidth problem).
*/
#include <Wy.stdio.h>
#include <Wy.stdlib.h>
#include <CSCall/Array2D.h>
#include <CSCall/Face.h>
#include "V4L2Capture.h"
using namespace Wy;
typedef Face::RGB32_Pixel Pixel;
const char GrSvr[]="../face/face";
const char* find_any_v4l_device()
{
const char* flist[]={"/dev/video","/dev/video0","/dev/video1","/dev/vdieo2"};
for(size_t i=0; i<WY_CARRLEN(flist); ++i) {
if(Wy::access(flist[i],F_OK)==Ok) {
return flist[i];
}
}
return NULL;
};
void capture_video(const char* dpath, unsigned int cap_w, unsigned int cap_h) {
Errno r;
V4L2Capture v4l2dev(dpath,cap_w,cap_h);
Array2D<Pixel> img(v4l2dev.frame_width(),v4l2dev.frame_height());
if((r=v4l2dev.start_capture(V4L2Capture::RGB32))!=Ok) {
WY_THROW(r);
}
ProcessID cpid;
FifoFile frd,fwr;
if((r=popen(GrSvr,cpid,frd,fwr))!=Ok) {
WY_THROW(r);
}
for(;;) {
if((r=v4l2dev.capture(img.header()))!=Ok) {
WY_THROW(r);
}
if((r=Face::put_image(fwr, img.header()))!=Ok) {
WY_THROW(r);
}
}
};
int main(int argc, char *argv[])
try {
const char* devfile=find_any_v4l_device();
if(devfile==NULL) {
cerr << "V4L device is not found" WY_ENDL;
return -1;
}
capture_video(devfile,1600,1200);
return 0;
}
catch(const Errno& e) {
cerr << wrd(e) << WY_ENDL;
return -1; // e.c_errno();
}
catch(...) {
cerr << "main() caught(...)" WY_ENDL;
throw;
};
Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread
libwy-0.69.4 is released wij <wyniijj5@gmail.com> - 2024-12-30 21:37 +0800 Re: libwy-0.69.4 is released wij <wyniijj5@gmail.com> - 2024-12-30 21:41 +0800
csiph-web