[SOLVED] can any one help me in solving my problem with c programme
Linux MintThis forum is for the discussion of Linux Mint.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
now i need to open an image file present in my hard disk using c-programme
As with your previous questions, I don't know how to interpret the above question. You should try to start your threads with a clearer description of what you're trying to do and what part of it you don't understand.
Your should also try to do more reading on your own and learn some of what you need. I think (from your other threads) you are trying to do a difficult project and you are asking questions about trivial parts of that project. If you try to get through the harder parts the same way, you'll take forever to finish.
You can open any kind of file (it doesn't matter that it is an image file) trivially in C using fopen.
But the point of opening a file must be to do something with the contents. Then the fact that it is an image file matters and which specific format of image file matters and what you want to do with the contents matters.
I don't currently know how to write a program to do anything interesting with the contents of any format of image file.
If I wanted to write such a program, I would first either need to learn about that image format by finding and studying online documentation of the format, or learn about available libraries of functions for reading and manipulating that format, maybe by examining open source programs that display or edit that format.
there are a few image libraries out there for reading images, like libpng and libjpeg. I think imagemagik also has a library that knows a few different formats.
i am doing a project which is based on linux mint using gcc, i need to work on two machines one is my PC and other i need to connect it through network, and the other system is a linux based security systems which records continously, i need to grab images from that recording system and apply filtering techniques for the grabbed frame.
now i need to execute a programme on my PC with mint for opening an image and apply some filtering techniques, i want to learn new things very much, so even i am new to all these things i am trying very hardly to do these things,
Hi, it's generally a good idea trying to create some programs yourself. But this sounds a little like "reinventing the wheel", because there are excellent tools to do this sort of things, just look for imagemagick. The "convert" command is probably what you would need.
PS: Of course, if you're interested in HOW this is done, you could take a look in imagemagick's source.
the format of the files stored will be in a different format and i need it to be in jpeg
Do I understand you correctly? You want to:
1) Read an image file in some other format (what format?)
2) Modify the contents (some "filter")
3) Save the result in jpeg format
If I misunderstood, please explain.
For operations such as compressing an image into jpeg format, it is usually better to invoke an existing program, rather invoking a library function linked into your own program (and certainly rather than writing your own code to do that step).
In Linux it is pretty easy for a program to invoke another program to run in a child process.
I just did a google search for +linux +"convert to jpeg" to find out what programs and/or functions are available to convert other formats to jpeg. You might want to try a similar search. The first item it found was an online copy of the man page for the program cjpeg http://linux.die.net/man/1/cjpeg
That looks like it would be a good choice if you want to invoke a program as a child process to do the compression into jpeg format.
1) Read an image file in some other format (what format?)
it is a raw format and the video is stored in .flm format and i need to xtract 1 frame from that video
2) Modify the contents (some "filter")
i need compress the raw format using jpeg compressioner for this i need to use jpeg library files
3) Save the result in jpeg format
yaa i need to save that in jpeg format and this is all from a live recording system
If I misunderstood, please explain.
For operations such as compressing an image into jpeg format, it is usually better to invoke an existing program, rather invoking a library function linked into your own program (and certainly rather than writing your own code to do that step).
yaaa you are right
"the bad thing is i cannot install any thing on the recording system i just have the access to store the required files on the storage and i can login into that system using ssh"
Last edited by badriinvenkat; 08-05-2010 at 08:54 AM.
when i am going to execute this programme using gcc the out put is like this
badri@linuxmint ~/Desktop/proj $ gcc sample2.c -o out
sample2.c: In function ‘main’:
sample2.c:11: warning: incompatible implicit declaration of built-in function ‘exit’
sample2.c:15: warning: incompatible implicit declaration of built-in function ‘exit’
badri@linuxmint ~/Desktop/proj $ ./out
Usage: ./out user.jpgbadri@linuxmint ~/Desktop/proj $ gcc sample2.c -o out
sample2.c: In function ‘main’:
sample2.c:11: warning: incompatible implicit declaration of built-in function ‘exit’
sample2.c:15: warning: incompatible implicit declaration of built-in function ‘exit’
badri@linuxmint ~/Desktop/proj $ ./out
Usage: ./out home/badri/Desktop/proj/user.jpgbadri@linuxmint ~/Desktop/proj $ gcc sample2.cgcc sample2.c -o out
sample2.c: In function ‘main’:
sample2.c:11: warning: incompatible implicit declaration of built-in function ‘exit’
sample2.c:15: warning: incompatible implicit declaration of built-in function ‘exit'
sorry man it is not working properly, can any one give me a sample c programme for opening an image, i was really struggling for this since 2 days, please help me friends...
@ estabroo thanks for u r valuable reply, when i am trying to execute it
it is displaying the following errors
"badri@linuxmint ~/Desktop/proj/sample $ gcc jpeg_sample.c -o out
/tmp/cclJRLSI.o: In function `read_jpeg_file':
jpeg_sample.c:(.text+0x82): undefined reference to `jpeg_std_error'
jpeg_sample.c:(.text+0xa6): undefined reference to `jpeg_CreateDecompress'
jpeg_sample.c:(.text+0xbe): undefined reference to `jpeg_stdio_src'
jpeg_sample.c:(.text+0xd4): undefined reference to `jpeg_read_header'
jpeg_sample.c:(.text+0xe2): undefined reference to `jpeg_start_decompress'
jpeg_sample.c:(.text+0x146): undefined reference to `jpeg_read_scanlines'
jpeg_sample.c:(.text+0x1ba): undefined reference to `jpeg_finish_decompress'
jpeg_sample.c:(.text+0x1c8): undefined reference to `jpeg_destroy_decompress'
/tmp/cclJRLSI.o: In function `write_jpeg_file':
jpeg_sample.c:(.text+0x26e): undefined reference to `jpeg_std_error'
jpeg_sample.c:(.text+0x292): undefined reference to `jpeg_CreateCompress'
jpeg_sample.c:(.text+0x2aa): undefined reference to `jpeg_stdio_dest'
jpeg_sample.c:(.text+0x2e4): undefined reference to `jpeg_set_defaults'
jpeg_sample.c:(.text+0x2fa): undefined reference to `jpeg_start_compress'
jpeg_sample.c:(.text+0x343): undefined reference to `jpeg_write_scanlines'
jpeg_sample.c:(.text+0x361): undefined reference to `jpeg_finish_compress'
jpeg_sample.c:(.text+0x36f): undefined reference to `jpeg_destroy_compress'
collect2: ld returned 1 exit status"
when i execute this programme
programme:
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
badri@linuxmint ~/Desktop/proj $ gcc sample3.c -o out
sample3.c:1:16: error: cv.h: No such file or directory
sample3.c:2:21: error: highgui.h: No such file or directory
sample3.c: In function ‘main’:
sample3.c:6: error: ‘IplImage’ undeclared (first use in this function)
sample3.c:6: error: (Each undeclared identifier is reported only once
sample3.c:6: error: for each function it appears in.)
sample3.c:6: error: ‘image’ undeclared (first use in this function)
Last edited by badriinvenkat; 08-07-2010 at 04:06 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.