Using video/image files in C - c

I'm trying to look through and find a way to annotate a video in C with polygons bounding boxes, however I'm stuck at a very elementary step.
Assuming I know how to break a .MPEG movie up into multiple JPEG images, how do I manipulate that file in C? The things I'll eventually need to draw on are text, points, and lines, but I am having a hard time figuring out how to get started with this.
If I declare:
FILE* img = fopen('foo.jpeg', 'r');
then what could I do with img? Is there a way to access certain pixels in the drawing?

What you did in your code sample is just opening a file. You didn't even read any data from it yet.
The simplest way to load an image file is to use dedicated library, such as SOIL.
If you weren't able to do it by yourself, however, I really don't think you will be able to accomplish your project goals - it is really advanced stuff you want to create, and you failed, as you already noticed, on the most basic of steps.

Related

Looping through materials and meshes (and animations) in a gltf file and importing into three js

I'm sure this has probably been asked before, but I'm fairly new to threejs (and React Fiber), so part of my problem here is not really knowing how to phrase what I need..
I know what I want to do must be possible, because it is possible to drag and drop any gltf file here: https://gltf-viewer.donmccurdy.com/ and see it rendered correctly.
So, what I want to do, is create a loop which will traverse all parts (nodes?) of a gltf model with/without animations (such as this one) and output it as part of a webpage.
Currently, I find myself tediously trying to add a <mesh> for each and every part of a model, and I know there must be an easier way.
I have found the source-code for the viewer here, but as mentioned, I'm still quite new to this library, so any help (or link to a similar question), would be appreciated.

Is there a way to store either animation data or arbitrary data in a Collada file from SceneKit?

I'm building a tool to convert an old proprietary mesh+animations file format into Collada DAE files, and so I have been using SceneKit to cheat a bit and just build the geometry and run [scene writeToUrl].
I am able to build correct CABasicAnimations for all the model animations, which are basically sets of morph targets (no bone definitions exist in the original file - only mesh morph targets).
Is there a way to include SceneKit-generated CAAnimationGroup or animations in the file export? Relatedly, is there a way to write and read arbitrary information to and from the export? If I can write and read the total animation duration and the FPS rate then I can reproduce the animations on the game engine side.
All animations should be exported automatically. You can verify that they are correctly exported by opening the Collada file as a xml file. If they are not exporte correctly, then it's a good idea to file a bug.
As for arbitrary data you can maybe use tricks such as using node names to store that information.

How to compare two .mp4 files?

I would like to compare two mp4 files, does somebody has an idea?
Maybe by interposing the video spectrum?
Thanks.
I had an idea for this a while back. I never implemented it, but it went something like this:
Get a good video library to do the heavy lifting for you, I like Aforge.NET
Use the library to walk through the video and extract bitmap frames, get a few hundred
Fix the resolution to a single aspect ratio
Reduce the images to something low-res like 16x16 or 64x64, using a nearest neighbor approach. This will blur the image such that two similar images will reduce to the same
Gather a chunk of these images by relative video timestamp and hash them to further reduce the data
Compare said hashes
Again, I never implemented this, so I don't know if it works, but the thing it has going for it is that video is very complex. While comparing any given frame to another won't work, based on different formats, resolutions, etc., the odds of a series of reduced hashes being the same from two different videos seems very low. Thus, few false positives. Also it seems like it could also tell you if one span of video was contained in another.
If I get around to making something like this I'll circle back here and post about it.

Is it possible to embed dynamic text into Keynote'09?

I wonder if it is possible to embed dynamic text into Keynote'09? I want to create a new presentation and run this presentation with different text messages (depending on the time of the day and day of the month).
You can insert formulas in tables. I don't have the english version of keynote open, so I can't tell you the exact names of the functions (guessing). You can do something like
=IF(MINUTE(NOW()) > 30; "> 30" ; "<= 30")
See the formula help. If you tell me what you want to achieve, I can give you further details.
I'm not aware of any direct or easy method to achieve what you are asking for.
However, with AppleScript you can access and change at least the title and the body boxes of the slides. This should be done prior to the presentation.
If the 'dynamic' text is to appear in a text box, you could use some scripting to modify the presentation's XML directly. An older Keynote's XML schema should be reasonably well (but not wholly) documented in the iWork Programming Guide, but as the '09 file format is not backwards compatible I don't know how much that would help.
You could try using an encapsulated post script image file. Postscript is a real programming language. I don't know if Keynote will accept it (or if it will cache a bitmap), but Cocoa loads EPS, and Keynote is cocoa.
On Mac OS X, an EPS file gets evaluated when it is opened and converted to a PDF in memory. This process can take a really long time, like 30 seconds, if this is the first time you've tried to open an EPS file since logging in.
Ah! Someone pointed out to me that you can embed Quartz Composer compositions into keynote. This is a good way to do it.

Read Pdf with C

I want to be able to read the content of pdf files. I need to do that with C on Linux.
The closer i can get to this was here but I think Haru can only create pdf and is not able to read them (not 100% sure).
PS: I only need the plain text from pdf
Check out libpoppler. I've never used it work extracting text, just querying PDF attributes. It's pretty easy to use.
How well do you need to parse them?
Just extracting strings should be relatively easy, fully accurate rendering is harder.
Take a look at the source for evince or ghostscript?
This is for C++ but might be a good starting point for understanding PDF structure http://www.codeproject.com/KB/cpp/ExtractPDFText.aspx (sorry wrong link before)
Another possible, though I've never used it is VersyPDF. It claims to allow you to edit PDFs ... http://versypdf.sybrex-systems-ltd.qarchive.org/

Resources