Is a co-advisor a good solution if my advisor is not very familiar with part of my research area? I am currently a 4th year PhD student and have no publication so far. I switched project after 1.5 years after realizing I don't want to have a PhD in that topic.

The new project is really interesting for me. I feel much more motivated and believe I have the analytical skills to solve it. The project is composed of two parts: image analysis (A) and machine learning (B). Eventhough my advisor is very knowledgable about the first part, he is not familiar with the other part, which is actually the most important cue to solve the problem. 

That results in lacking of general research guidance from him. He would points me to unfruitful direction, and when I present literature's approaches he is not interested in. A metaphor is that like doing programming big project without the knowledge of data structures. Would a co-advisor be the best solution?
It sounds like there are two related issues: 


convincing your advisor about the directions you want to take
finding someone to talk to about your research directions. 


For the first one, I'm not sure what you mean by "he's not interested". Does that mean that your advisor doesn't want you to pursue directions even though he's not familiar with them, or that he's not giving you rousing encouragement ? If you have a direction you think might bear fruit for your problem based on your literature scan, why not try it out and show him the results ? Since you imply that your advisor is an expert in the application domain (image analysis), you should be able to demonstrate the quality of the results even if he doesn't fully understand the methods being used. Or is it that he is requiring you to follow certain directions and does not want you to follow other directions ? 

For the second, a co-advisor is one possible outcome, but even a colleague in the relevant area (another professor who could be on your committee, or even a fellow student you can brainstorm with) might suffice. You didn't indicate whether your advisor is aware of his shortcomings in the techniques area (ML): if he is, then he might even be able to introduce you to the right people, thus opening doors that might be difficult for you to open yourself. 

as always, talking to the advisor would help. You can approach it as "I'm looking for some extra help in topic XYZ: do you know who I could talk with ?". Of course, how you approach this precisely depends hugely on the interactions you currently have with your advisor.