LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-29-2005, 12:04 AM   #1
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Rep: Reputation: 30
xlib question


I want to "stick" a timestamp image onto the original image taken from the webcam. While doing this programmatically, I wonder if xlib could help in any way.
I sort of set up the thang like this

#include <X11/Xlib.h>
void WebCam::AddTimeStamp(void)
{
graphics_context gc(get_display(), id());
gc.draw_text(point(100,100), "testing");
}

and that doesn't compile, what other information should I have next?
Thanks
Jack
 
Old 12-29-2005, 12:13 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Yes, if you're programming in Xlib, and if you have access to the Xlib Display and a Drawable (such as a window), then you can most definitely add a label to that drawable with DrawText().

So what the heck is "gc.draw_text()" or "gc (get_display (), id ())"? You're certainly not going to find any APIs that look like these inside of <X11/Xlib.h>!

And how are things coming with your libCURL build?

PS:
"wlan0" is another pop favorite for wireless device names. Use "ifconfig -a" to determine what interfaces you've actually got, and "iwconfig" to configure them...
 
Old 12-29-2005, 12:45 AM   #3
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
Still wandering in the sea
 
Old 12-29-2005, 12:46 AM   #4
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
I think I have to pick up some references. What do you recommend?
Thanks Paul
Jack
 
Old 12-29-2005, 12:53 AM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
References for what?

As far as the libCURL stuff, just go for it. If you're lucky (pun unintended ;-)), it'll just be "./configure - make - make install - Done!". Otherwise, if you're not so fortunate ... post the error message and your questions to LQ.

As far as the wireless - there are plenty of FAQs and "howto's" on setup, configuration and troubleshooting. And, of course, there's LQ.

As far as graphics: it depends on a) the requirements of your project, b) the programming tools at your disposal, c) which particular graphics libraries can be cross-compiled and d) your personal tastes and preferences. I would assume your project is using at least one graphics library (such as Qt or GTK+) already - perhaps you might be best off better familiarizing yourself with it.

IMHO .. PSM
 
Old 12-29-2005, 01:13 AM   #6
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
Dear Paul,
maybe I just list down all problems I've got so far

1) libcURLpp - the compiler was choosing the wrong version of callback in which 3 parameters method was chosen instead of 4, so didn't compile

2) Wireless - still did not get the interface name, searching in and out of Linux
tried man wireless to no avail.

3) timestamp superimposition - still wandering, have to take a in-depth study on the library

In case all these 3 problems are overcome, I would say "cheers!"


Thanks
Jack
 
Old 12-29-2005, 01:17 AM   #7
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
http://www.linuxgazette.com/issue78/tougher.html

For the xlib stuff
 
Old 12-29-2005, 09:47 AM   #8
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
1. Graphics library:
Aha! That explains the "gc.draw_text()" stuff! This link: is NOT Xlib!. It's just a little wrapper around a few Xlib calls. I doubt it's very complete, I doubt you'll be able to get much support - either from the Open Source community, or from the author.

Personally, I'd urge you to avoid it. At least until you become familiar with a more conventional (more widely used) alternative.

Try to find out what graphics library your project is already using.

2. Gameplan:
I'd focus on libcURLpp first.

a) Verify that you definitely have a C++ compiler (please: write that C++-only "hello world", e.g. something with a little "cout << "Hello world"", and verify that it works.

b) Try cross-compiling the libcURLpp library itself, and verify that it's OK.

c) Then (and ONLY then) focus on specific build errors in your libcURLpp-based app.

IMHO .. PSM
 
Old 12-29-2005, 08:34 PM   #9
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
I built a standalone program to test libcurlpp. The shrinked version still causing errors... I used g++ -o test libcurlpptest.cpp -lcurlpp

/usr/local/include/utilspp/functor/FunctorHandler.hpp:50: error: too few arguments to function

Thx
Jack
 
Old 12-29-2005, 08:37 PM   #10
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
#include <curlpp/cURLpp.hpp>
#include <curlpp/Options.hpp>

size_t write_data1 (void *buf, size_t size, size_t nmemb, FILE *FileStream);

size_t write_data1 (void *buf, size_t size, size_t nmemb, FILE *FileStream)
{
}

int main (int argc, char *argv[])
{
cURLpp::Cleanup myCleanup;


// Creation of the URL option
cURLpp::Options::Url myUrl("192.168.0.124/oneshotimage.jpg");

cURLpp::Options::Port myPort(80);


cURLpp::Easy myRequest;


myRequest.setOpt(myUrl.clone());


cURLpp::Types::WriteFunctionFunctor functor(write_data1);

cURLpp::Options::WriteFunction *test = new cURLpp::Options::WriteFunction(functor);
myRequest.setOpt(test);

myRequest.perform();

}
 
Old 12-29-2005, 09:09 PM   #11
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
The entire include file

/*
* Copyright (c) <2002-2005> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef UTILSPP_FUNCTORHANDLER_HPP
#define UTILSPP_FUNCTORHANDLER_HPP

namespace utilspp
{
template <class ParentFunctor, typename Fun>
class FunctorHandler : public FunctorImpl< typename ParentFunctor::ResultType,
typename ParentFunctor::ParmList >
{
public:
typedef typename ParentFunctor::ResultType ResultType;

FunctorHandler(Fun fun) : mFun(fun) {}
FunctorHandler* clone() const
{return new FunctorHandler(*this);}

ResultType operator()()
{return mFun();}

ResultType operator()(typename ParentFunctor::Parm1 p1)
{return (mFun)(p1);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2)
{return (mFun)(p1, p2);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3)
{return (mFun)(p1, p2, p3);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4)
{return (mFun)(p1, p2, p3, p4);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5)
{return (mFun)(p1, p2, p3, p4, p5);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6)
{return (mFun)(p1, p2, p3, p4, p5, p6);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9, typename ParentFunctor::Parm10 p10)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9, typename ParentFunctor::Parm10 p10, typename ParentFunctor::Parm11 p11)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9, typename ParentFunctor::Parm10 p10, typename ParentFunctor::Parm11 p11, typename ParentFunctor::Parm12 p12)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9, typename ParentFunctor::Parm10 p10, typename ParentFunctor::Parm11 p11, typename ParentFunctor::Parm12 p12, typename ParentFunctor::Parm13 p13)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9, typename ParentFunctor::Parm10 p10, typename ParentFunctor::Parm11 p11, typename ParentFunctor::Parm12 p12, typename ParentFunctor::Parm13 p13, typename ParentFunctor::Parm14 p14)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14);}

ResultType operator()(typename ParentFunctor::Parm1 p1, typename ParentFunctor::Parm2 p2, typename ParentFunctor::Parm3 p3, typename ParentFunctor::Parm4 p4, typename ParentFunctor::Parm5 p5, typename ParentFunctor::Parm6 p6, typename ParentFunctor::Parm7 p7, typename ParentFunctor::Parm8 p8, typename ParentFunctor::Parm9 p9, typename ParentFunctor::Parm10 p10, typename ParentFunctor::Parm11 p11, typename ParentFunctor::Parm12 p12, typename ParentFunctor::Parm13 p13, typename ParentFunctor::Parm14 p14, typename ParentFunctor::Parm15 p15)
{return (mFun)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15);}

private:
Fun mFun;
};
};

#endif
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xlib: connection to ":0.0" refused by server Xlib: No protocol specified eyalkz Linux - Newbie 12 11-27-2018 01:30 PM
Xlib and images question SciYro Programming 2 06-14-2005 12:29 PM
Xlib question memory_leak Programming 0 12-05-2003 10:05 AM
Xlib question me01 Programming 0 09-26-2003 04:56 PM
Xlib-Windows Manager question amilici Programming 1 09-11-2003 11:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration