Karthik Shiraly

+ Follow
since Apr 04, 2009
Karthik likes ...
Android Python PHP C++ Java Linux
Merit badge: grant badges
For More
Bangalore, India
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Karthik Shiraly

DirectX - Microsoft's framework for games and graphics - used to be a heavy user of COM.
Since I haven't touched DirectX from a loooong time, I went looking for C++ sample code for the latest DirectX version (v12) out of curiosity if it's still using COM.
And sure enough, it's still using ComPtr safe pointer wrappers over DirectX COM interfaces!

It also looks like WinRT - the successor to Win32 API - is also based on COM according to its wikipedia article .
So yeah, COM seems to be doing surprisingly well in the Windows ecosystem, both at the system layers and at the application layers. Or atleast a lot better than RMI.

It occurs to me that system and game programming are both rather specialized areas and represent relatively lesser number of developers.
What about the majority of Windows application developers?
I suspect they are using higher level technologies like C# / VB.NET on .NET and don't use COM much. Just like the average Java developer doesn't use RMI much directly.
7 years ago
This is an excellent question, and deserves a detailed answer.

Firstly, I would not equate basic data structures like arrays and linked lists, with more complex data structures like queues
and graphs whose characteristics are not just the relationships within their data but also the operations they define on that data.
These complex data structures are fundamental to many AI algorithms:

  • A large number of AI problems reduce to tree and graph search problems where the nodes are different states and the AI should
    calculate the "best" path from current state to a particular state.
    Most of the well known graph algorithms for best first search - like A* or Djikstra's - use both graphs and priority queues
    as their fundamental data structures.

  • In supervised machine learning, regression and classification of inputs are common tasks. Algorithms like artificial neural networks,
    decision trees classifiers, boosted tree classifiers, and random forest classifiers all use weighted graphs as their
    fundamental data structures.

    ML itself is a cross cutting field that has applications in different areas like computer vision, linguistic interpretation, audio, signal and speech processing.
    So any data structure that is used by an ML algorithm is also getting indirectly used in the area where that algorithm itself is being used.

  • In natural language processing, parse trees are a fundamental concept.

  • In speech recognition, markov chains are modelled as weighted graphs.

  • Can you model all data as arrays and all algorithms to use only arrays? Sure. But often it involves some kind of unacceptable space vs time trade offs.
    That's the reason alternative structures like linked lists are used.

    What you should take away from this semester class is the intuition to calculate and understand things like algorithmic complexity and space time trade offs.
    That knowledge is golden and something which will come up often especially in an algorithm intensive field like yours.

    If you want to build an appreciation and motivation for data structures and algorithms, my suggestion is to explore and implement algorithms like the above from scratch.
    The main reason most software engineers can't appreciate their importance is because we tend to use libraries where all the data structure and algorithm thinking has already been done by somebody else.
    Strive to be one of those thinkers, not just one of the users.
    7 years ago
    Since it's an SQLGrammarException, check the SQL queries generated by Hibernate. Either set hibernate configuration's "hibernate.show_sql" to true, or set the logging category "org.hibernate.SQL" to debug or trace.
    See Hibernate Logging.

    There are many ways in which queries that work in a dev machine may fail in a production machine.
    One possibility is that the database versions on dev and production are very different, and what is valid in newer version dialect may not be in the older one.

    Another example is a MySQL gotcha related to how OSes handle filename cases that I had run into a long time back.
    My dev machine was a Windows machine and production was a Linux machine. MySQL stores each database and table as files.
    Since Windows ignores filename cases, "mydir/mytable" and "mydir/MyTable" are the same file in Windows. An SQL query can use any case variation on that and still work because the OS finds the table file just fine.
    But not so in case sensitive Linux.
    I had to change the schema creation scripts and my queries to use the same case. Everything in lower case always is a good rule to follow.
    I don't know if that's the problem here, but verify once that cases are consistent, especially if your dev machine is Windows.
    7 years ago
    It's not a valid JSON string. This railroad diagram shows what is valid:

    As you can see, there is no ";" after "\". If your JSON strings should contain backslashes (or newlines or tabs or ...), they should be escaped using prefix backslashes by whichever component is producing the JSON:
    7 years ago
    There is nothing abnormal about UTF-8.
    Please read these 2 articles on characters and related concepts like encodings and glyphs - article #1 and article #2.
    With that understanding, come back and explain what exactly is the problem you are having. "Convert UTF-8 to normal characters" is highly unlikely to be the actual problem or a solution to the problem.
    7 years ago
    When things are getting increasingly confusing, I try to reduce the number of unfamiliar things by using something I know, and solve just 1 unknown at a time before taking up the next.
    Here, it looks to me like C++, IDE, opencv, and QT are all relative unfamiliar to you.
    I don't know anything about xcode, but googling says it's capable of building C++ projects. So if you're familiar with Xcode, I suggest building a simple procedural C++ hello world level highgui application using Xcode itself.
    You don't need to switch to a new IDE like QT creator to use highgui or QT; QT can be used like any other library in any project and IDE.
    In fact you don't even need to know anything about QT at this point, since highgui only uses it internally. Highgui APIs are enough to start off a simple GUI application that shows images and videos.
    7 years ago
    Unfortunately, I have not come across any one single comprehensive tutorial that covers all of highgui. But since highgui API is small and quite limited in what it can do, it's not that hard to pick it up from here and there.
    See if these tutorials and links help:
    - Basic tutorial that shows creating window and trackbar controls.
    Highgui can be built to use either the GTK framework or QT framework. This tutorial will work regardless of which framework was used at build time.
    API documentation's here

    - Tutorial that shows some more controls like push buttons, checkboxes, radio buttons and status bars
    This works only if Highgui was built to use the QT framework. It doesn't work if GTK was used.

    While highgui is fine for quick prototyping, eventually you'd want to build full fledged GUIs for production apps. For that, you should learn the QT GUI framework and then display OpenCV outputs in QT controls like QLabel. See what QT is capable of here and have a look at this beginner's tutorial.

    What errors are you seeing with highgui?
    7 years ago
    The C API hasn't got much love from a couple of years now, actually.

    Some of the modules that have been around a while still support the C API and they work fine. These C functions and types are usually prefixed with a "cv...".
    For example, the C equivalent of C++ imread() is cvLoadImage().
    If the C++ module documentation - such as the imgcodecs module for image file reading and writing - has a C API URL at top, use that as the documentation. Otherwise, you're out of luck.

    Not all features available in C++ API may be available for C programs, which is why you're better off using C++ for OpenCV.
    If you want to stick to C constructs, just don't use any C++ features in your own code.
    Mat objects can be directly assigned to C IplImage or CvMat structs; so using the C++ API should not be much of a problem.
    7 years ago
    Glad to. OpenCV build and installation are rather OS dependent. If it's Linux or Windows, I can help. What OS are you on and what have you tried so far?
    7 years ago
    Welcome to CodeRanch !

    Spring itself started supporting Hibernate 5 only from Spring v4.2.
    So Spring 3 + Hibernate 5 is an untested, unsupported and likely incompatible combination of versions.
    Worst case, you may end up wasting time trying to solve tons of vague errors due to such incompatibility.
    I think you should consider migrating to latest Spring 4.2 too. What features of Hibernate 5 are you interested in?
    7 years ago
    I tried to reproduce your problem in a Eclipse dynamic web project - copy pasted all your configuration files, created matching package structure, added Spring 4.1 and hibernate 5.1.0 libs.
    It's all working fine for me. I don't think there is anything wrong with your configuration files now.

    Googling some parts of the exception traces leads to this discussion where somebody has got the same exception as you.
    Apparently, one possible cause is if Hibernate and/or Spring are added to the Eclipse build path as a "User library" with "System library" checkbox checked.
    Have you added them as a "User Library" or something? In my case, I just copied all the JARs into WebContent/lib and refreshed the project. Maybe you can remove any User Libraries you have added and try this approach.
    7 years ago
    Check the filenames. Resources say "userdetails.hbm.xml" but the file structure says it's "userdetails.xml".
    7 years ago
    If you are specifying mapping resources using <mappingResources> tag, don't prefix with "classpath:".
    Items in <mappingResources> are passed as they are to Hibernate without Spring pre-processing the "classpath:" prefixes, and Hibernate doesn't understand what to do with the "classpath:" prefixes. Hence your error.

    A better option is to use <mappingLocations> instead of <mappingResources>, because you can specify "classpath:" in them. It's a subtle difference.

    PS: Welcome to CodeRanch ! Please change your username to a real name as per our naming policy http://www.javaranch.com/name.jsp.
    7 years ago
    The problem with f.readline() is that it retains the newline character in return value.
    You get that error if your file has empty lines and f.readline() returns just "\n". int() doesn't know what to do with a "\n".

    A more pythonic way of doing this:
    7 years ago
    I assume this is targeted at Windows since you mention MinGW, .
    Well, it's not mandatory in Windows that DLLs have to be installed in common system paths.
    I'd use an installer software like NSIS and deploy them as DLLs in the same directory as the EXE.
    One benefit is that if an update or patch has to be released that does not affect the dependencies, it can contain just the updated EXE and be a smaller download than a bloated statically linked version.
    7 years ago