Re: libwy-0.69.4 is released

Liste des GroupesRevenir à cl c++ 
Sujet : Re: libwy-0.69.4 is released
De : wyniijj5 (at) *nospam* gmail.com (wij)
Groupes : comp.lang.c++
Date : 30. Dec 2024, 14:41:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <f654d47103ee2fb56f04aeea4873eae63e1b0572.camel@gmail.com>
References : 1
User-Agent : Evolution 3.54.2 (3.54.2-1.fc41)
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;
};



Date Sujet#  Auteur
30 Dec14:37 * libwy-0.69.4 is released2wij
30 Dec14:41 `- Re: libwy-0.69.4 is released1wij

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal